View Javadoc

1   package hep.wired.util.test;
2   
3   import java.awt.*;
4   import javax.swing.*;
5   
6   import hep.wired.util.TristateCheckBox;
7   
8   /***
9    * Test for TristateCheckBox.
10   *
11   * Taken from 2003-12-02 The Java Specialists' Newsletter [Issue 082] - 
12   * TristateCheckBox based on the Swing JCheckBox
13   * http://www.javaspecialists.co.za/archive/Issue082.html
14   *
15   * @author Mark Donszelmann
16   * @version $Id: TristateCheckBoxTest.java 551 2004-11-02 00:34:59Z duns $
17   */
18  public class TristateCheckBoxTest {
19    
20      public static void main(String args[]) throws Exception {
21          JFrame frame = new JFrame("TristateCheckBoxTest");
22          frame.getContentPane().setLayout(new GridLayout(0, 1, 5, 5));
23          final TristateCheckBox swingBox = new TristateCheckBox("Testing the tristate checkbox");
24          swingBox.setMnemonic('T');
25          frame.getContentPane().add(swingBox);
26          frame.getContentPane().add(new JCheckBox("The normal checkbox"));
27          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
28          final TristateCheckBox winBox = new TristateCheckBox("Testing the tristate checkbox", TristateCheckBox.SELECTED);
29          frame.getContentPane().add(winBox);
30          final JCheckBox winNormal = new JCheckBox("The normal checkbox");
31          frame.getContentPane().add(winNormal);
32      
33          // wait for 3 seconds, then enable all check boxes
34          new Thread() { {start();}
35              public void run() {
36                  try {
37                      winBox.setEnabled(false);
38                      winNormal.setEnabled(false);
39                      Thread.sleep(3000);
40                      winBox.setEnabled(true);
41                      winNormal.setEnabled(true);
42                  } catch (InterruptedException ex) { 
43                  }
44              }
45          };
46          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
47          frame.pack();
48          frame.setVisible(true);
49      }
50  }