/* * Like simple button, but showing Silder */ import java.awt.Frame; import java.awt.FlowLayout; import java.awt.EventQueue; import java.awt.event.ActionListener; import java.awt.event.AdjustmentListener; import javax.swing.JFrame; public class Main extends JFrame { public static void main (String [] args) { //*3 New startup procedure: equivalent code /* Equivalent to code below class MyRun implements Runnable { //*3 public void run() { //*3 new Main (); //*3 } //*3 } //*3 //*3 MyRun myRun = new MyRun (); //*3 //*3 java.awt.EventQueue.invokeLater (myRun); { //*3 */ java.awt.EventQueue.invokeLater (new Runnable() { //*4 New startup procedure: actual code public void run() { //*4 new Main (); //*4 } //*4 }); //*4 } public Main () { // Window setup setSize (300, 300); setLayout (new FlowLayout()); setDefaultCloseOperation (EXIT_ON_CLOSE); //*2 Quit process when close window // Put a scrollbar in it, don't bother remembering add (new ScrollBar (1)); //*1 Just create it and add() it in // Put another scrollbar add (new ScrollBar (2)); //*1 // And a button, for good measure add (new Button ("Push me")); //*1 // Show the window setVisible (true); } }