Implementing a slider and graphics in an applet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rorykin
    New Member
    • Jul 2014
    • 1

    #1

    Implementing a slider and graphics in an applet

    Code:
    import javax.swing.JApplet;
    import java.awt.BorderLayout;
    import javax.swing.JSlider;
    
    import java.awt.*;
    import java.applet.*;
    
    public class SliderTest extends JApplet {
        public void init() {
            createGUI();
        }
    
        private void createGUI() {
            JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 50);
            
            slider.setMajorTickSpacing(10);
            slider.setMinorTickSpacing(5);
            slider.setPaintTicks(true);
            slider.setPaintLabels(true);
            
            getContentPane().add(slider, BorderLayout.WEST);
        }
        
        public void paint (Graphics g) {
          g.setColor (Color.black);
          
          g.drawArc (250, 250, 100, 100, 0, 90);
        }
    }

    So essentially what I'm trying to do is draw an arc (or rectangle or really any shape) then place a slider on one of the sides of the window (west,east, north, south, etc.)

    Any help you can give me is greatly appreciated! (sorry, if this is a stupid question...I'm new to programming)
Working...