public JSlider setSlider(JPanel panel, int orientation, int minimumValue,
                             int maximumValue, int initValue, int majorTickSpacing,
                             int minorTickSpacing) {
        JSlider slider = new JSlider(orientation, minimumValue, maximumValue,
                initValue);
        slider.setPaintTicks(true);
        slider.setMajorTickSpacing(majorTickSpacing);
        slider.setMinorTickSpacing(minorTickSpacing);
        slider.setPaintLabels(true);
        slider.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                JSlider tempSlider = (JSlider) e.getSource();

                if (tempSlider.equals(sliderTransX)) {
                    transX = sliderTransX.getValue() - 150.0;
                    canvas.repaint();
                } else if (tempSlider.equals(sliderTransY)) {
                    transY = sliderTransY.getValue() - 150.0;
                    canvas.repaint();
                } else if (tempSlider.equals(sliderRotateTheta)) {
                    rotateTheta = sliderRotateTheta.getValue() * Math.PI / 180;
                    canvas.repaint();
                } else if (tempSlider.equals(sliderRotateX)) {
                    rotateX = sliderRotateX.getValue();
                    canvas.repaint();
                } else if (tempSlider.equals(sliderRotateY)) {
                    rotateY = sliderRotateY.getValue();
                    canvas.repaint();
                } else if (tempSlider.equals(sliderScaleX)) {
                    if (sliderScaleX.getValue() != 0.0) {
                        scaleX = sliderScaleX.getValue() / 100.0;
                        canvas.repaint();
                    }
                } else if (tempSlider.equals(sliderScaleY)) {
                    if (sliderScaleY.getValue() != 0.0) {
                        scaleY = sliderScaleY.getValue() / 100.0;
                        canvas.repaint();
                    }
                }
            }
        });
        panel.add(slider);

        return slider;
    }