import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * Main program for Incdec */ public class Main extends JFrame implements ActionListener { public static void main (String [] args) { java.awt.EventQueue.invokeLater (new Runnable() { public void run() { new Main (); } }); } private Incdec id1, id2; public Main () { // Window setup setSize (700, 300); setLayout (new FlowLayout()); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // Create some Incdec's for testing id1 = new Incdec (); //*1 Add() it just like a standard widget add (id1); //*1 // Demonstrate our setBorderColor id2 = new Incdec (); //*1 id2.setBorderColor (Color.GREEN); //*2 Test our setBorderColor add (id2); //*1 // And a button to report the data from the Incdec's, for testing JButton b = new JButton ("Get data"); //*3 Button reports data b.addActionListener (this); add (b); setVisible (true); } /** * Callback from the test button */ public void actionPerformed (ActionEvent e) { //*3 System.out.println ("Value 1 = " + id1.getValue() + //*3 ", Value 2 = " + id2.getValue()); //*3 } }