예제 #1
0
  public ControlWindow(String title) {
    props = Property.getProps();

    locale = new Locale(props.getProperty("resourcebundle"));
    rb = ResourceBundle.getBundle("language", locale);

    this.setBackground(new Color(1, 1, 1));
    container = this.getContentPane();
    container.setLayout(new FlowLayout());
    container.setSize(500, 300);

    // build the window frame
    createComponents();

    this.setSize(600, 400);
    this.setLocation(300, 200);

    // Now this will set the LAF(Look & Feel)
    setLookAndFeel();
    SwingUtilities.updateComponentTreeUI(this);
    this.pack();

    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (monitor != null) {
              monitor.interrupt();
            }
            System.exit(0);
          }
        });

    this.setVisible(true);
  }
예제 #2
0
  private void createComponents() {

    Box box0 = Box.createVerticalBox();
    Box box1 = Box.createVerticalBox();
    Box box2 = Box.createVerticalBox();
    Box box3 = Box.createHorizontalBox();
    Box box4 = Box.createVerticalBox();
    Box box5 = Box.createHorizontalBox();

    lMonitor = new JLabel(rb.getString("lbl_folder"));
    // lMonitor.setAlignmentX(Component.CENTER_ALIGNMENT);
    // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    lClearFolder = new JLabel(rb.getString("lbl_clear_folder"));
    lTimer = new JLabel(rb.getString("lbl_timer"));

    jTxtFolderMonitorName = new JTextField(props.getProperty(Property.MONITORFOLDER), 20);
    jTxtFolderMonitorName.addActionListener(new MyActionListener(ComponentID.TXTF_FOLDER));
    jTxtFolderMonitorName.addKeyListener(new MyKeyListener());
    jTxtFolderMonitorName.addFocusListener(new MyFocusListener(ComponentID.TXTF_FOLDER));

    jTxtTimer = new JTextField(props.getProperty(Property.TIMER), 20);
    jTxtTimer.addActionListener(new MyActionListener(ComponentID.TXTF_TIMER));
    jTxtTimer.addKeyListener(new MyKeyListener());
    jTxtTimer.addFocusListener(new MyFocusListener(ComponentID.TXTF_TIMER));

    JCheckBox jCBClearFolder = new JCheckBox();
    jCBClearFolder.addActionListener(new MyActionListener(ComponentID.CHK_CLEAR_FOLDER));
    jCBClearFolder.addKeyListener(new MyKeyListener());

    buttonPanel = new JPanel();
    buttonPanel.setBorder(new TitledBorder(new EtchedBorder(), rb.getString("brd_monitor_button")));

    jbnStop = new JButton(rb.getString("b_stop"));
    jbnStop.setMnemonic(KeyEvent.VK_P);
    jbnStart = new JButton(rb.getString("b_start"));
    jbnStart.setMnemonic(KeyEvent.VK_S);

    buttonPanel.add(jbnStart);
    buttonPanel.add(jbnStop);

    jbnStop.addActionListener(new MyActionListener(ComponentID.B_STOP));
    jbnStop.addKeyListener(new MyKeyListener());
    jbnStart.addActionListener(new MyActionListener(ComponentID.B_START));
    jbnStart.addKeyListener(new MyKeyListener());

    box0.add(lMonitor);
    box0.add(Box.createVerticalStrut(10));
    box0.add(lClearFolder);
    box0.add(Box.createVerticalStrut(10));
    box0.add(lTimer);

    box1.add(jTxtFolderMonitorName);
    box1.setAlignmentX(LEFT_ALIGNMENT);
    box1.add(jCBClearFolder);
    box1.add(jTxtTimer);
    //		box1.setBorder(new BevelBorder(BevelBorder.LOWERED));

    box3.add(box0);
    box3.add(Box.createHorizontalStrut(10));
    box3.add(box1);
    //		box3.add(box2);

    //		box4.add(box3);
    //		box4.setBorder(new BevelBorder(BevelBorder.LOWERED));
    //		box4.add(box1);
    box5.add(box3);
    box5.add(Box.createHorizontalStrut(10));
    //		box5.setBorder(new BevelBorder(BevelBorder.LOWERED));
    box5.add(buttonPanel);
    container.add(box5);

    ControlWindowMenuBar cwm = new ControlWindowMenuBar();
    Property.getInstance().addPropertyChangeListener(Property.RESOURCEBUNDLE, cwm);
    Property.getInstance().addPropertyChangeListener(Property.RESOURCEBUNDLE, new MyKeyListener());

    setJMenuBar(cwm);
  }