package slider; import java.awt.*; import javax.swing.*; // This application displays a simple slider. It takes 4 command line // arguments--a minimum value, maximum value, current value, and title. // An example invocation would be: // java slider.SliderApplication 10 90 60 "Simple Slider" public class SliderApplication { public SliderApplication(int minValue, int maxValue, int initialValue, String label) { SliderModel model = new SliderModel(minValue, maxValue, initialValue, label); JComponent slider = new SliderGraphicalView(model); JFrame sliderWindow = new JFrame("Slider Application"); // all components should be added to the content pane sliderWindow.getContentPane().add("Center", slider); // setDefaultCloseOperation tells Java what to do when the close button // in the main window is pressed sliderWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // calculate the size of the frame and layout its subcomponents sliderWindow.pack(); // display the frame sliderWindow.setVisible(true); } public static void main (String argv []) { final int minValue = Integer.parseInt(argv[0]); final int maxValue = Integer.parseInt(argv[1]); final int initialValue = Integer.parseInt(argv[2]); final String label = argv[3]; // standard code for making all drawing occur in the event thread // rather than the main thread java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new SliderApplication(minValue, maxValue, initialValue, label); } }); } }