Advertisement
Guest User

Untitled

a guest
Nov 21st, 2009
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3. import java.awt.event.*;
  4.  
  5. public class AwtTest extends Frame{
  6.  
  7.  
  8.     public Panel createCalibrationPanel() {
  9.     final Panel panel = new Panel();
  10.     panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
  11.     panel.add(Box.createHorizontalStrut(20));
  12.     final Checkbox checkbox = new Checkbox(
  13.            "Use image spatial calibration for q scale", true);
  14.     final Button button = new Button("Set scale");
  15.     //useCalibration = checkbox.getState();
  16.     button.setEnabled(checkbox.getState());
  17.     panel.add(checkbox);
  18.     panel.add(button);
  19.     checkbox.addItemListener(new ItemListener() {
  20.         public void itemStateChanged(final ItemEvent e) {
  21.             boolean state = checkbox.getState();
  22.             //setUseCalibration(state);
  23.             button.setEnabled(state);
  24.             System.out.println("checkbox state " + checkbox.getState());
  25.         }
  26.         });
  27.     button.addActionListener(new ActionListener() {
  28.         public void actionPerformed(final ActionEvent e) {
  29.             //imp.unlock();
  30.             System.out.println("Set Scale...");
  31.             //imp.lock();
  32.         }
  33.         });
  34.     return panel;
  35.     }
  36.     public static void main(String[] a){
  37.     AwtTest foo = new AwtTest();
  38.     foo.add(foo.createCalibrationPanel());
  39.     foo.setSize(200,200);
  40.     foo.setVisible(true);
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement