/* * 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) { /* Equivalent to code below class MyRun implements Runnable { public void run() { new Main (); } } MyRun myRun = new MyRun (); java.awt.EventQueue.invokeLater (myRun); { */ java.awt.EventQueue.invokeLater (new Runnable() { public void run() { new Main (); } }); } public Main () { // Window setup setSize (300, 300); setLayout (new FlowLayout()); setDefaultCloseOperation (EXIT_ON_CLOSE); // Put a scrollbar in it, don't bother remembering add (new ScrollBar (1)); // Put another scrollbar add (new ScrollBar (2)); // And a button, for good measure add (new Button ("Push me")); // Show the window setVisible (true); } }