/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
 /** Select the strategy for matching. */
 public void selectStrategy() {
   _currentStrategy = _strategies.get(_strategyBox.getSelectedIndex());
   removeListener();
   _pim.setStrategy(_currentStrategy);
   updateTextField();
   updateExtensionLabel();
   updateList();
   addListener();
   _textField.requestFocus();
 }
 /** Toggle visibility of this frame. Warning, it behaves like a modal dialog. */
 public void setVisible(boolean vis) {
   assert EventQueue.isDispatchThread();
   validate();
   if (vis) {
     DrJavaRoot.installModalWindowAdapter(this, LambdaUtil.NO_OP, CANCEL);
     setOwnerEnabled(false);
     selectStrategy();
     _textField.requestFocus();
     toFront();
   } else {
     DrJavaRoot.removeModalWindowAdapter(this);
     setOwnerEnabled(true);
     if (_owner != null) {
       _owner.toFront();
     }
   }
   super.setVisible(vis);
 }
Example #4
0
  /**
   * Constructor for FindDialog
   *
   * @param type
   * @param ta Description of the Parameter
   */
  public FindDialog(JFrame parent, JTextComponent ta) {
    super(parent, "Find in Output", true);
    this.textarea = ta;
    textarea.requestFocus();

    JPanel panel = new JPanel();
    KappaLayout layout = new KappaLayout();
    panel.setLayout(layout);
    panel.setBorder(new javax.swing.border.EmptyBorder(11, 11, 11, 11));
    setContentPane(panel);

    JLabel find_label = new JLabel("Find:");
    final JTextField to_find = new JTextField(20);
    JButton find_btn = new JButton("Find");
    JButton find_next_btn = new JButton("Find Next");
    JButton cancel_btn = new JButton("Close");
    final JCheckBox wrap_cb = new JCheckBox("Wrap search");
    wrap_cb.setSelected(true);

    panel.add(find_label, "0, 0, 1, 1, W, w, 3");
    panel.add(to_find, "0, 1, 1, 1, 0, w, 3");
    panel.add(wrap_cb, "0, 2, 1, 1, 0, w, 3");

    JPanel btn_panel = new JPanel(new KappaLayout());
    btn_panel.add(find_btn, "0, 0, 1, 1, 0, w, 3");
    btn_panel.add(find_next_btn, "0, 1, 1, 1, 0, w, 3");
    btn_panel.add(cancel_btn, "0, 2, 1, 1, 0, w, 3");
    panel.add(btn_panel, "1, 0, 1, 3, 0, h, 5");

    find_btn.addActionListener(new Finder(to_find, textarea, false, wrap_cb.isSelected()));
    find_next_btn.addActionListener(new Finder(to_find, textarea, true, wrap_cb.isSelected()));
    cancel_btn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            setVisible(false);
            dispose();
          }
        });
    pack();
    to_find.requestFocus();
  }
 /** Selects the text on gaining the focus. */
 public void requestFocus() {
   super.requestFocus();
   selectAll();
 }
Example #6
0
 /** Invoked when the component has been made visible. */
 public void componentShown(ComponentEvent e) {
   searchparams.selectAll();
   searchparams.requestFocus();
 }
 /** Focus back in the text field. */
 public void resetFocus() {
   _textField.requestFocus();
 }