Package javax.swing

Examples of javax.swing.ButtonModel


     * levels are created. Unfortunately, Swing doesn't have an easy way to get the actual button from the group.
     *
    *  @return the selected stack trace level
    */
    private StartParameter.ShowStacktrace getSelectedStackTraceLevel() {
        ButtonModel selectedButtonModel = stackTraceButtonGroup.getSelection();
        if (selectedButtonModel != null) {
            Enumeration<AbstractButton> buttonEnumeration = stackTraceButtonGroup.getElements();
            while (buttonEnumeration.hasMoreElements()) {
                JRadioButton radioButton = (JRadioButton) buttonEnumeration.nextElement();
                if (radioButton.getModel() == selectedButtonModel) {
View Full Code Here


        int offset;

        if (type == RELATED) {
            if (sourceCID == "ToggleButtonUI" &&
                      targetCID == "ToggleButtonUI") {
                ButtonModel sourceModel = ((JToggleButton)source).getModel();
                ButtonModel targetModel = ((JToggleButton)target).getModel();
                if ((sourceModel instanceof DefaultButtonModel) &&
                    (targetModel instanceof DefaultButtonModel) &&
                    (((DefaultButtonModel)sourceModel).getGroup() ==
                     ((DefaultButtonModel)targetModel).getGroup()) &&
                        ((DefaultButtonModel)sourceModel).getGroup() != null) {
View Full Code Here

      private boolean rollover = false;

      @Override
      public void stateChanged(final ChangeEvent e) {
        final JButton btn = (JButton) e.getSource();
        final ButtonModel model = btn.getModel();
        if (model.isRollover() && !rollover) {
          btn.setForeground(Color.LIGHT_GRAY);
          rollover = true;
        } else if (rollover && !model.isRollover()) {
          btn.setForeground(Color.GRAY);
          rollover = false;
        }
      }
    });
    // previous.setIcon(new ImageIcon(previousButtonIcon));
    // previous.setRolloverIcon(new ImageIcon(previousRollOver));

    play = new JButton("");
    play.addActionListener(e -> {
      final boolean isPaused = PlayerFunctions.isPaused;
      if (!isPaused) {
        PlayerFunctions.pause(play);
      } else {
        PlayerFunctions.play(play);
      }
    });
    ((WebButtonUI) play.getUI()).setUndecorated(true);
    play.setFont(fontAwesome);
    play.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    play.setBorderPainted(false);
    play.setBorder(null);
    play.setText("\uf04b");

    play.setMargin(new Insets(0, 0, 0, 0));
    play.setContentAreaFilled(false);
    play.addChangeListener(new ChangeListener() {
      private boolean rollover = false;

      @Override
      public void stateChanged(final ChangeEvent e) {
        final JButton btn = (JButton) e.getSource();
        final ButtonModel model = btn.getModel();
        if (model.isRollover() && !rollover) {
          btn.setForeground(Color.LIGHT_GRAY);
          rollover = true;
        } else if (rollover && !model.isRollover()) {
          btn.setForeground(Color.GRAY);
          rollover = false;
        }
      }
    });

    // play.setIcon(new ImageIcon(playBackPaused));
    // play.setRolloverIcon(new ImageIcon(playBackPausedHover));

    final JButton next = new JButton("");
    ((WebButtonUI) next.getUI()).setUndecorated(true);
    next.addActionListener(e -> PlayerFunctions.seekNext());
    next.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    next.setBorderPainted(false);

    next.setBorder(null);
    next.setFont(fontAwesome);
    next.setMargin(new Insets(0, 0, 0, 0));
    next.setContentAreaFilled(false);
    next.setText("\uF04E");
    // next.setIcon(new ImageIcon(forwardButtonIcon));
    // next.setRolloverIcon(new ImageIcon(forwardButtonHover));
    next.setToolTipText("Next");
    next.addChangeListener(new ChangeListener() {
      private boolean rollover = false;

      @Override
      public void stateChanged(final ChangeEvent e) {
        final JButton btn = (JButton) e.getSource();
        final ButtonModel model = btn.getModel();
        if (model.isRollover() && !rollover) {
          btn.setForeground(Color.LIGHT_GRAY);
          rollover = true;
        } else if (rollover && !model.isRollover()) {
          btn.setForeground(Color.GRAY);
          rollover = false;
        }
      }
    });

    final JButton mute = new JButton("");
    ((WebButtonUI) mute.getUI()).setUndecorated(true);
    mute.setFont(fontAwesome);
    mute.setText("\uF028");
    mute.addActionListener(e -> MediaUtils.muteToggle());
    mute.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    mute.setBorderPainted(false);

    mute.setBorder(null);
    mute.setMargin(new Insets(0, 0, 0, 0));
    mute.setContentAreaFilled(false);
    mute.addChangeListener(new ChangeListener() {
      private boolean rollover = false;

      @Override
      public void stateChanged(final ChangeEvent e) {
        final JButton btn = (JButton) e.getSource();
        final ButtonModel model = btn.getModel();
        if (model.isRollover() && !rollover) {
          btn.setForeground(Color.LIGHT_GRAY);
          rollover = true;
        } else if (rollover && !model.isRollover()) {
          btn.setForeground(Color.GRAY);
          rollover = false;
        }
      }
    });
View Full Code Here

               }
            });
    }

        private void perform() {
            final ButtonModel bm = b.getModel();
            if( bm.isPressed() != onOff ) bm.setPressed( onOff );
            if( bm.isArmed()   != onOff ) bm.setArmed(   onOff );
        }
View Full Code Here

  public void paint(Graphics g, JComponent c) {
    Graphics2D g2d = (Graphics2D)g;
    g2d.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
   
    AbstractButton button = (AbstractButton) c;
    ButtonModel model = button.getModel();
    if(model.isRollover()) {
      paintBackground(g2d, button);
      paintRoundBorder(g2d, button);
    }
   
    g.translate(3, 5);
View Full Code Here

  }

  @Override
  public void paint(Graphics g, JComponent c) {
        AbstractButton button = (AbstractButton) c;
        ButtonModel model = button.getModel();
    Dimension size = button.getSize();
    if (!model.isPressed() || !model.isArmed()) {
      paintButtonUnpressed(g, size);
    }
    super.paint(g, button);
    paintBorder(g, size);
  }
View Full Code Here

    static class CameraButtonGroup extends ButtonGroup {
        public void next() {
            int curIdx = 0;

            // find the index of the current button
            ButtonModel cur = getSelection();
            for (int i = 0; i < buttons.size(); i++) {
                if (buttons.get(i).getModel().equals(cur)) {
                    curIdx = i;
                    break;
                }
View Full Code Here

  {
    final ElementMetaData elementMetaData = ElementTypeRegistry.getInstance().getElementType(elementName);
    final ElementMetaDataTransferable transferable = new ElementMetaDataTransferable(elementMetaData);
    anEvent.startDrag(DragSource.DefaultCopyNoDrop, EMPTY_DRAG_IMAGE, new Point(), transferable, null);

    final ButtonModel model = getModel();
    model.setArmed(false);
    model.setPressed(false);
  }
View Full Code Here

  }

  public void test(TestHarness h)
  {
    MyButton b = new MyButton();
    ButtonModel m = b.getModel();
    h.check(m, null);
    h.check(b.getText(), "");
  }
View Full Code Here

  public void test(TestHarness harness)
  {
   
    ButtonGroup g1 = new ButtonGroup();
    JToggleButton b1 = new JToggleButton("B1");
    ButtonModel m1 = b1.getModel();
    g1.add(b1);
    harness.check(m1.isSelected(), false);
    g1.setSelected(m1, false);
    harness.check(b1.isSelected(), false);
    harness.check(g1.isSelected(m1), false);
    harness.check(g1.getSelection(), null);
   
    ButtonGroup g2 = new ButtonGroup();
    JToggleButton b2 = new JToggleButton("B2");
    ButtonModel m2 = b2.getModel();
    g2.add(b2);
    harness.check(m2.isSelected(), false);
    g2.setSelected(m2, true);
    harness.check(b2.isSelected(), true);
    harness.check(g2.isSelected(m2), true);
    harness.check(g2.getSelection(), m2);

    ButtonGroup g3 = new ButtonGroup();
    JToggleButton b3 = new JToggleButton("B3");
    b3.setSelected(true);
    ButtonModel m3 = b3.getModel();
    g3.add(b3);
    harness.check(m3.isSelected(), true);
    g3.setSelected(m3, false);
    harness.check(b3.isSelected(), true);
    harness.check(g3.isSelected(m3), true);
    harness.check(g3.getSelection(), m3);

    ButtonGroup g4 = new ButtonGroup();
    JToggleButton b4 = new JToggleButton("B4");
    b4.setSelected(true);
    ButtonModel m4 = b4.getModel();
    g4.add(b4);
    harness.check(m4.isSelected(), true);
    g4.setSelected(m4, false);
    harness.check(b4.isSelected(), true);
    harness.check(g4.isSelected(m4), true);
    harness.check(g4.getSelection(), m4);

    // now work with a second button...
    JToggleButton b5 = new JToggleButton("B5");
    ButtonModel m5 = b5.getModel();
    g4.add(b5);
    harness.check(g4.isSelected(m5), false);
    // the following does nothing, because 'false' says we don't change the
    // state of the incoming model...
    g4.setSelected(m5, false);
View Full Code Here

TOP

Related Classes of javax.swing.ButtonModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.