Exemplo n.º 1
0
 public void mouseClicked(MouseEvent e) {
   JComponent c = (JComponent) e.getSource();
   if (!(c instanceof AbstractButton)) {
     AbstractButton b = (AbstractButton) c.getComponent(0);
     b.doClick();
   }
 }
Exemplo n.º 2
0
 public void keyPressed(KeyEvent e) {
   int code = e.getKeyCode();
   if (code == KeyEvent.VK_SPACE) {
     AbstractButton button = (AbstractButton) e.getSource();
     Boolean wasPressed = (Boolean) button.getClientProperty(SPACEBAR_PRESSED);
     if (wasPressed == null || wasPressed.booleanValue() == false) {
       button.putClientProperty(SPACEBAR_PRESSED, Boolean.TRUE);
       button.doClick();
     }
   }
 }
  /** Creates the And/Or radio buttons, their button group and a panel for them */
  private JComponent createLogicalButtons() {

    andButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalAnd"));
    andButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 10));
    andButton.setActionCommand(logicalRelationships[0]);
    andButton.doClick();

    orButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalOr"));
    orButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 5, 10));
    orButton.setActionCommand(logicalRelationships[1]);

    ActionListener bal =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JRadioButton rb = (JRadioButton) e.getSource();
            currentRelationship = rb.getActionCommand();
          }
        };
    andButton.addActionListener(bal);
    orButton.addActionListener(bal);

    ButtonGroup bg = new ButtonGroup();
    bg.add(andButton);
    bg.add(orButton);
    JPanel b = new JPanel();
    LayoutManager lm = new BoxLayout(b, BoxLayout.PAGE_AXIS);
    b.setLayout(lm);
    b.setAlignmentX(Component.LEFT_ALIGNMENT);
    b.setBorder(
        BorderFactory.createTitledBorder(I18N.getString("AttributeResearchPanel.logicalLink")));

    // add a bit of space
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(andButton);
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(orButton);
    b.setPreferredSize(new Dimension(150, 100));

    return b;
  }