Package javax.swing

Examples of javax.swing.ButtonModel


        private static Component createImageComponent(final Object model,
                                                      final AttributeSet attrs,
                                                      final FormView view) {

            ButtonModel imageModel = (ButtonModel) model;
            final JButton image = new JButton("");

            // Model
            if (imageModel == null) {
                imageModel = new FormButtonModel(new Form(SimpleAttributeSet.EMPTY),
View Full Code Here


    g.fillRoundRect(0, 0, c.getWidth() - 1, c.getHeight() - 1, 10, 10);
    g.setColor(Color.GRAY);
    g.drawRoundRect(0, 0, c.getWidth() - 1, c.getHeight() - 1, 10, 10);

    AbstractButton button = (AbstractButton) c;
    ButtonModel bmodel = button.getModel();
    if (bmodel.isPressed()) {
      g.translate(1, 1);
    }
    super.paint(g, c);
  }
View Full Code Here

    if (componentForTransitions != null) {
      ComponentUI ui = componentForTransitions.getUI();
      if (ui instanceof Trackable) {
        Trackable trackable = (Trackable) ui;
        ButtonModel transitionModel = trackable.getTransitionModel();
        state = ComponentState.getState(transitionModel,
            componentForTransitions);
        ComponentState prevState = (trackable == null) ? state
            : SubstanceCoreUtilities
                .getPrevComponentState(componentForTransitions);
View Full Code Here

        overwriteCheckbox.setSelected(false);
        thisPageTextField.setText("");
        nPagesTextField.setText("");
        outPrefixText.setText("pdfsam_");
        bLevelCombo.resetComponent();
        ButtonModel bmodel = splitOptionsRadioGroup.getSelection();
        if (bmodel != null) {
            bmodel.setSelected(false);
        }
        chooseAFolderRadio.setSelected(true);
    }
View Full Code Here

        if (SeaGlassLookAndFeel.selectedUI == this) {
            return SeaGlassLookAndFeel.selectedUIState | SynthConstants.ENABLED;
        }

        AbstractButton button = (AbstractButton) c;
        ButtonModel    model  = button.getModel();

        if (model.isPressed()) {
            if (model.isArmed()) {
                state = PRESSED;
            } else {
                state = MOUSE_OVER;
            }
        }

        if (model.isRollover()) {
            state |= MOUSE_OVER;
        }

        if (model.isSelected()) {
            state |= SELECTED;
        }

        if (c.isFocusOwner() && button.isFocusPainted()) {
            state |= FOCUSED;
View Full Code Here

     *
     * @return the icon.
     */
    protected Icon getIcon(AbstractButton b) {
        Icon        icon  = b.getIcon();
        ButtonModel model = b.getModel();

        if (!model.isEnabled()) {
            icon = getSynthDisabledIcon(b, icon);
        } else if (model.isPressed() && model.isArmed()) {
            icon = getPressedIcon(b, getSelectedIcon(b, icon));
        } else if (b.isRolloverEnabled() && model.isRollover()) {
            icon = getRolloverIcon(b, getSelectedIcon(b, icon));
        } else if (model.isSelected()) {
            icon = getSelectedIcon(b, icon);
        } else {
            icon = getEnabledIcon(b, icon);
        }

View Full Code Here

     * @param  defaultIcon DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon) {
        ButtonModel model = b.getModel();
        Icon        icon;

        if (model.isSelected()) {
            icon = getIcon(b, b.getRolloverSelectedIcon(), defaultIcon, SynthConstants.MOUSE_OVER | SynthConstants.SELECTED);
        } else {
            icon = getIcon(b, b.getRolloverIcon(), defaultIcon, SynthConstants.MOUSE_OVER);
        }

View Full Code Here

     * @param  defaultIcon DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon) {
        ButtonModel model = b.getModel();
        Icon        icon;

        if (model.isSelected()) {
            icon = getIcon(b, b.getDisabledSelectedIcon(), defaultIcon, SynthConstants.DISABLED | SynthConstants.SELECTED);
        } else {
            icon = getIcon(b, b.getDisabledIcon(), defaultIcon, SynthConstants.DISABLED);
        }

View Full Code Here

     * @param menuItem menu item to be painted
     * @param bgColor selection background color
     */
  protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {

    ButtonModel model = menuItem.getModel();
    Color oldColor = g.getColor();
    int menuItemWidth = menuItem.getWidth();
    int menuItemHeight = menuItem.getHeight();

    paintUnarmedBackground(g, menuItem);

    // 20061120 fabio: Highlight shouldn't be painted when item is disabled
    if (model.isArmed() && menuItem.isEnabled()) {

      int width = menuItemWidth - 3;
      int height = menuItemHeight - 2;

      g.setColor(UIManager.getColor("OfficeLnF.HighlightBorderColor"));
View Full Code Here

                                     Icon checkIcon, Icon arrowIcon,
                                     Color background, Color foreground,
                                     int defaultTextIconGap) {

    JMenuItem b = (JMenuItem) c;
    ButtonModel model = b.getModel();

    int menuWidth = b.getWidth();
    int menuHeight = b.getHeight();

    resetRects();

    viewRect.setBounds( 0, 0, menuWidth, menuHeight );

    Font holdf = g.getFont();
    Font f = c.getFont();
    g.setFont(f);
    FontMetrics fm = c.getFontMetrics(f);

    // get Accelerator text
    KeyStroke accelerator =  b.getAccelerator();
    String acceleratorText = "";
    if (accelerator != null) {
      int modifiers = accelerator.getModifiers();
      if (modifiers > 0) {
        acceleratorText = KeyEvent.getKeyModifiersText(modifiers);
        acceleratorText += "+";
      }

      int keyCode = accelerator.getKeyCode();
      if (keyCode != 0)
        acceleratorText += KeyEvent.getKeyText(keyCode);
              else
        acceleratorText += accelerator.getKeyChar();
    }

    // layout the text and icon
    String text = layoutMenuItem(
      fm, b.getText(), acceleratorText, b.getIcon(),
      checkIcon, arrowIcon,
      viewRect, iconRect, textRect, acceleratorRect,
      b.getText() == null ? 0 : defaultTextIconGap,
      defaultTextIconGap
    );

    // Paint background
    paintBackground(g, b, background);

    Color holdc = g.getColor();

    // Paint the Check
    boolean isCheckOrRadio = (c instanceof JCheckBoxMenuItem) ||
              (c instanceof JRadioButtonMenuItem);
    if (checkIcon != null && isCheckOrRadio)
      paintCheck(g, menuItem);

    // Paint the Icon
    if(b.getIcon()!=null && !isCheckOrRadio)
      paintIcon(g, menuItem);

    // Draw the Text
    paintText(g, b, textRect, text);

    // Draw the Accelerator Text
    if(!acceleratorText.equals("")) {

      //Get the maxAccWidth from the parent to calculate the offset.
      int accOffset = 0;
      Container parent = menuItem.getParent();
      if (parent != null && parent instanceof JComponent) {

        JComponent p = (JComponent) parent;
        Integer maxValueInt = (Integer) p.getClientProperty(OfficeXPMenuItemUI.MAX_ACC_WIDTH);
        int maxValue = maxValueInt != null ?
                maxValueInt.intValue() : acceleratorRect.width;

        //Calculate the offset, with which the accelerator texts will be drawn.
        accOffset = maxValue - acceleratorRect.width;

      }

      // Ensure all accelerators are right-aligned for RTL.
      if (!c.getComponentOrientation().isLeftToRight()) {
        Integer maxValueInt = null;
        if (parent!=null && parent instanceof JComponent) {
          maxValueInt = (Integer)((JComponent)b.getParent()).
            getClientProperty(OfficeXPMenuItemUI.MAX_ACC_WIDTH);
        }
        int maxValue = maxValueInt!=null ? maxValueInt.intValue() :
                      acceleratorRect.width;
        accOffset = 0;
        acceleratorRect.x = 20 + maxValue - acceleratorRect.width;
      }

      if(!model.isEnabled()) {
        // *** paint the acceleratorText disabled

        if ( disabledForeground != null ) {
          g.setColor( disabledForeground );
          OfficeXPGraphicsUtils.drawString(g,fm,acceleratorText,0,
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.