Java 类javax.swing.ButtonModel 实例源码

项目:incubator-netbeans    文件:EditMediator.java   
public static void register(Project project,
                            AntProjectHelper helper,
                            ReferenceHelper refHelper,
                            ListComponent list,
                            ButtonModel addJar,
                            ButtonModel addLibrary, 
                            ButtonModel addAntArtifact,
                            ButtonModel remove, 
                            ButtonModel moveUp,
                            ButtonModel moveDown, 
                            ButtonModel edit,
                            Document libPath,
                            ClassPathUiSupport.Callback callback) {    
    register(project, helper, refHelper, list, addJar, addLibrary, 
            addAntArtifact, remove, moveUp, moveDown, edit, false, libPath,
            callback);
}
项目:incubator-netbeans    文件:EditMediator.java   
public static void register(Project project,
                            AntProjectHelper helper,
                            ReferenceHelper refHelper,
                            ListComponent list,
                            ButtonModel addJar,
                            ButtonModel addLibrary,
                            ButtonModel addAntArtifact,
                            ButtonModel remove,
                            ButtonModel moveUp,
                            ButtonModel moveDown,
                            ButtonModel edit,
                            boolean allowRemoveClassPath,
                            Document libPath,
                            ClassPathUiSupport.Callback callback) {
    register(project, helper, refHelper, list, addJar, addLibrary,
            addAntArtifact, remove, moveUp, moveDown, edit, allowRemoveClassPath, libPath,
            callback, DEFAULT_ANT_ARTIFACT_TYPES, JAR_ZIP_FILTER,
            JFileChooser.FILES_AND_DIRECTORIES);
}
项目:incubator-netbeans    文件:EditMediator.java   
public static void register(Project project,
                            AntProjectHelper helper,
                            ReferenceHelper refHelper,
                            ListComponent list,
                            ButtonModel addJar,
                            ButtonModel addLibrary,
                            ButtonModel addAntArtifact,
                            ButtonModel remove,
                            ButtonModel moveUp,
                            ButtonModel moveDown,
                            ButtonModel edit,
                            Document libPath,
                            ClassPathUiSupport.Callback callback,
                            String[] antArtifactTypes,
                            FileFilter filter,
                            int fileSelectionMode) {
    register(project, helper, refHelper, list, addJar, addLibrary, addAntArtifact, remove, moveUp, moveDown, edit, false, libPath, callback, antArtifactTypes, filter, fileSelectionMode);
}
项目:incubator-netbeans    文件:ToggleBookmarkAction.java   
@Override
public void setModel(ButtonModel model) {
    ButtonModel oldModel = getModel();
    if (oldModel != null) {
        oldModel.removeChangeListener(this);
    }

    super.setModel(model);

    ButtonModel newModel = getModel();
    if (newModel != null) {
        newModel.addChangeListener(this);
    }

    stateChanged(null);
}
项目:incubator-netbeans    文件:ProfilerPopup.java   
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);

    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }

    return c;
}
项目:incubator-netbeans    文件:FileSearchAction.java   
@Override
@NonNull
public ListCellRenderer getListCellRenderer(
        @NonNull final JList list,
        @NonNull final Document nameDocument,
        @NonNull final ButtonModel caseSensitive,
        @NonNull final ButtonModel colorPrefered) {
    Parameters.notNull("list", list);   //NOI18N
    Parameters.notNull("nameDocument", nameDocument);   //NOI18N
    Parameters.notNull("caseSensitive", caseSensitive); //NOI18N
    return ItemRenderer.Builder.create(
                list,
                caseSensitive,
                new FileDescriptorConvertor(nameDocument)).
            setCamelCaseSeparator(CAMEL_CASE_SEPARATOR).
            setColorPreferedProject(colorPrefered).
            build();
}
项目:incubator-netbeans    文件:MnemonicsTest.java   
public void testSetLocalizedTextWithModel() throws Exception {
    ButtonModel m = new DefaultButtonModel();
    JButton b = new JButton();
    Mnemonics.setLocalizedText(b, "Hello &There");
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
    b.setModel(m);
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
}
项目:rapidminer    文件:CheckBoxMenuItemIcon.java   
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    JMenuItem b = (JMenuItem) c;
    ButtonModel model = b.getModel();

    g.translate(x, y);

    boolean isSelected = model.isSelected();
    boolean isEnabled = model.isEnabled();

    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // draw check mark
    if (isSelected) {
        g2.setStroke(CHECKBOX_STROKE);
        if (isEnabled) {
            g2.setColor(Colors.CHECKBOX_CHECKED);
        } else {
            g2.setColor(Colors.CHECKBOX_CHECKED_DISABLED);
        }
        g2.drawLine(2, 6, 5, 8);
        g2.drawLine(5, 8, 9, 1);
    }
    g.translate(-x, -y);
}
项目:json2java4idea    文件:SettingsPanel.java   
@Nonnull
@CheckReturnValue
public Style getStyle() {
    final ButtonModel selected = styleGroup.getSelection();
    return getStyleButtonStream()
            .filter(button -> {
                final ButtonModel model = button.getModel();
                return model.equals(selected);
            })
            .map(button -> {
                final String name = button.getText();
                return Style.fromName(name, Style.NONE);
            })
            .findFirst()
            .orElse(Style.NONE);
}
项目:openjdk-jdk10    文件:DefaultButtonModelCrashTest.java   
private void go() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container contentPane = frame.getContentPane();
        ButtonModel model = new DefaultButtonModel();

        JCheckBox check = new JCheckBox("a bit broken");
        check.setModel(model);
        panel = new JPanel(new BorderLayout());
        panel.add(new JTextField("Press Tab (twice?)"), BorderLayout.NORTH);
        panel.add(check);
        contentPane.add(panel);
        frame.setLocationRelativeTo(null);
        frame.pack();
        frame.setVisible(true);
    }
项目:xdman    文件:XDMMenuUI.java   
@Override
    protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
        ButtonModel model = menuItem.getModel();
        Color oldColor = g.getColor();
        if (model.isArmed()
                || (menuItem instanceof JMenu && model.isSelected())) {
            paintButtonPressed(g, menuItem);
        } else {
            g.setColor(this.colorBg);
            //g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());//(0, 0, gap + 1, menuItem.getHeight());
//          g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
//          if (menuItem.getIcon() != null) {
//              int gap = menuItem.getIcon().getIconWidth() + 2;
//              g.setColor(this.darkColor);
//              g.drawLine(gap, 0, gap, menuItem.getHeight());
//              g.setColor(this.lightColor);
//              g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
//          }
        }
        g.setColor(oldColor);
    }
项目:btrace.nb    文件:DeployAction.java   
@Override
public void setModel(ButtonModel model) {
    ButtonModel oldModel = getModel();
    if (oldModel != null) {
        oldModel.removeChangeListener(this);
    }

    super.setModel(model);

    ButtonModel newModel = getModel();
    if (newModel != null) {
        newModel.addChangeListener(this);
    }

    stateChanged(null);
}
项目:btrace.nb    文件:DeployAction.java   
@Override
public void setModel(ButtonModel model) {
    ButtonModel oldModel = getModel();
    if (oldModel != null) {
        oldModel.removeChangeListener(this);
    }

    super.setModel(model);

    ButtonModel newModel = getModel();
    if (newModel != null) {
        newModel.addChangeListener(this);
    }

    stateChanged(null);
}
项目:DataRecorder    文件:ToolBarButtonUI.java   
/**
 * Paints the Button
 * 
 * @param g
 *            The graphics
 * @param c
 *            The component
 */
@Override
public void paint(final Graphics g, final JComponent c) {
    // super.paint(g, c);
    final AbstractButton button = (AbstractButton) c;
    button.setRolloverEnabled(true);
    final ButtonModel model = button.getModel();
    final Rectangle bounds = button.getBounds();

    if (model.isPressed() && model.isArmed()) {
        g.translate(1, 1);
        super.paint(g, c);
        g.translate(-1, -1);
        downBorder.paintBorder(c, g, 0, 0, bounds.width, bounds.height);
    } else if (button.isRolloverEnabled() && model.isRollover()) {
        super.paint(g, c);
        upBorder.paintBorder(c, g, 0, 0, bounds.width, bounds.height);
    } else {
        super.paint(g, c);
    }
}
项目:pumpernickel    文件:FilledButtonUI.java   
public void paintIcon(Graphics2D g,ButtonInfo info) {
    AbstractButton button = info.button;
    Icon icon = button.getIcon();
    ButtonModel model = button.getModel();

    if(model.isRollover() && button.getRolloverIcon()!=null)
        icon = button.getRolloverIcon();
    if(model.isPressed() && button.getPressedIcon()!=null)
        icon = button.getPressedIcon();
    if(model.isSelected() && button.getSelectedIcon()!=null)
        icon = button.getSelectedIcon();
    if(model.isRollover() && model.isSelected() && button.getRolloverSelectedIcon()!=null)
        icon = button.getRolloverSelectedIcon();
    if(isEnabled(button)==false && button.getDisabledIcon()!=null)
        icon = button.getDisabledIcon();
    if(isEnabled(button)==false && model.isSelected() && button.getDisabledIcon()!=null)
        icon = button.getDisabledSelectedIcon();

    if(icon!=null) {
        g.setComposite(isEnabled(button) ? AlphaComposite.SrcOver : SRC_OVER_TRANSLUCENT);
        icon.paintIcon(button, g, info.iconRect.x, info.iconRect.y);
    }
}
项目:pumpernickel    文件:FilledButtonUI.java   
public void paintText(Graphics2D g,ButtonInfo info) {
    ButtonModel model = info.button.getModel();
    FontMetrics fm = info.button.getFontMetrics(info.button.getFont());
    int mnemonicIndex = info.button.getDisplayedMnemonicIndex();
    String text = info.button.getText();
    int textShiftOffset = 0;


    g.setComposite(AlphaComposite.SrcOver);
    /* Draw the Text */
    if(isEnabled(info.button)) {
        /*** paint the text normally */
        g.setColor(info.button.getForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                info.textRect.x + textShiftOffset,
                info.textRect.y + fm.getAscent() + textShiftOffset);
    } else {
        /*** paint the text disabled ***/
        g.setColor(info.button.getBackground().brighter());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                info.textRect.x, info.textRect.y + fm.getAscent());
        g.setColor(info.button.getBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                info.textRect.x - 1, info.textRect.y + fm.getAscent() - 1);
    }
}
项目:pumpernickel    文件:TexturedButtonUI.java   
@Override
public void paintBackground(Graphics2D g,ButtonInfo info) {
    super.paintBackground(g, info);
    if(info.button.isContentAreaFilled() || info.button.isBorderPainted()) {
        ButtonModel model = info.button.getModel();
        if(model.isSelected() || model.isArmed() || isSpacebarPressed(info.button)) {
            g = (Graphics2D)g.create();

            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
                    RenderingHints.VALUE_ANTIALIAS_ON);
            g.clip( info.fill);
            g.setColor(new Color(0,0,0,15));
            g.setStroke(outline1);
            g.draw( info.fill );
            g.setStroke(outline2);
            g.draw( info.fill );
            g.setStroke(outline3);
            g.draw( info.fill );
        }
    }
}
项目:littleluck    文件:LuckCheckboxIcon.java   
/**
 * <pre>
 * 根据按钮状态, 获取当前状态下图片信息。
 *
 * According to the button state, access to the current
 * state of the picture information.
 * </pre>
 *
 * @param c <code>CheckBoxMenuItem</code> object.
 * @param model <code>ButtonModel</code>
 * @return <code>Image</code> when is selected return current image, otherwise return null.
 */
public Image getPreImg(Component c, ButtonModel model)
{
    if (!model.isSelected())
    {
        return null;
    }

    if (model.isArmed())
    {
        return getRollverImg();
    }
    else
    {
        return getNormalImg();
    }
}
项目:littleluck    文件:LuckButtonUI.java   
public void paint(Graphics g, JComponent c)
{
    AbstractButton b = (AbstractButton) c;

    ButtonModel model = b.getModel();

    paintBg(g, (AbstractButton) c);

    // 设置组件偏移,以达到视觉上的按下和弹起效果
    // Set the component offsets to achieve visual depress and bounce
    if(model.isPressed() && model.isArmed() && b.getIcon() == null)
    {
        g.translate(2, 1);
    }

    super.paint(g, c);

    if(model.isPressed() && model.isArmed() && b.getIcon() == null)
    {
        g.translate(-2, -1);
    }
}
项目:littleluck    文件:LuckArrowIcon.java   
public Image getPreImg(Component c, ButtonModel model)
{
    JMenu menu = (JMenu) c;

    if (menu.getItemCount() > 0)
    {
        if (model.isSelected())
        {
            return getRollverImg();
        }
        else
        {
            return getNormalImg();
        }
    }

    return null;
}
项目:javify    文件:MetalToggleButtonUI.java   
/**
 * If the property <code>ToggleButton.gradient</code> is set, then a gradient
 * is painted as background, otherwise the normal superclass behaviour is
 * called.
 */
public void update(Graphics g, JComponent c)
{
  AbstractButton b = (AbstractButton) c;
  ButtonModel m = b.getModel();
  if (b.getBackground() instanceof UIResource
      && b.isContentAreaFilled()
      && b.isEnabled() && ! m.isArmed() && ! m.isPressed()
      && UIManager.get(getPropertyPrefix() + "gradient") != null)
    {
      MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
                               SwingConstants.VERTICAL,
                               getPropertyPrefix() + "gradient");
      paint(g, c);
    }
  else
    super.update(g, c);
}
项目:javify    文件:BasicArrowButton.java   
/**
 * Paints the arrow button. The painting is delegated to the
 * paintTriangle method.
 *
 * @param g The Graphics object to paint with.
 */
public void paint(Graphics g)
{
  super.paint(g);

  int height = getHeight();
  int size = height / 4;

  int x = (getWidth() - size) / 2;
  int y = (height - size) / 2;

  ButtonModel m = getModel();
  if (m.isArmed())
    {
      x++;
      y++;
    }

  paintTriangle(g, x, y, size, direction, isEnabled());
}
项目:javify    文件:BasicBorders.java   
/**
 * Paints the ButtonBorder around a given component.
 *
 * @param c the component whose border is to be painted.
 * @param g the graphics for painting.
 * @param x the horizontal position for painting the border.
 * @param y the vertical position for painting the border.
 * @param width the width of the available area for painting the border.
 * @param height the height of the available area for painting the border.
 *
 * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
 */
public void paintBorder(Component c, Graphics  g,
                        int x, int y, int width, int height)
{
  ButtonModel bmodel = null;

  if (c instanceof AbstractButton)
    bmodel = ((AbstractButton) c).getModel();

  BasicGraphicsUtils.drawBezel(
    g, x, y, width, height,
    /* pressed */ (bmodel != null)
                    && /* mouse button pressed */ bmodel.isPressed()
                    && /* mouse inside */ bmodel.isArmed(),
    /* default */ (c instanceof JButton)
                    && ((JButton) c).isDefaultButton(),
    shadow, darkShadow, highlight, lightHighlight);
}
项目:javify    文件:BasicMenuItemUI.java   
/**
 * Paints background of the menu item
 *
 * @param g
 *          The graphics context used to paint this menu item
 * @param menuItem
 *          menu item to paint
 * @param bgColor
 *          Background color to use when painting menu item
 */
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
  // Menu item is considered to be highlighted when it is selected.
  // But we don't want to paint the background of JCheckBoxMenuItems
  ButtonModel mod = menuItem.getModel();
  Color saved = g.getColor();
  if (mod.isArmed() || ((menuItem instanceof JMenu) && mod.isSelected()))
    {
      g.setColor(bgColor);
      g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
    }
  else if (menuItem.isOpaque())
    {
      g.setColor(menuItem.getBackground());
      g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
    }
  g.setColor(saved);
}
项目:javify    文件:BasicButtonListener.java   
/**
 * Performs the action.
 */
public void actionPerformed(ActionEvent event)
{
  Object cmd = getValue("__command__");
  AbstractButton b = (AbstractButton) event.getSource();
  ButtonModel m = b.getModel();
  if (PRESSED.equals(cmd))
    {
      m.setArmed(true);
      m.setPressed(true);
      if (! b.isFocusOwner())
        b.requestFocus();
    }
  else if (RELEASED.equals(cmd))
    {
      m.setPressed(false);
      m.setArmed(false);
    }
}
项目:javify    文件:BasicButtonListener.java   
/**
 * Accept a mouse press event and arm the button.
 *
 * @param e The mouse press event to accept
 */
public void mousePressed(MouseEvent e)
{
  if (e.getSource() instanceof AbstractButton)
    {
      AbstractButton button = (AbstractButton) e.getSource();
      ButtonModel model = button.getModel();
      if (SwingUtilities.isLeftMouseButton(e))
        {
          // It is important that these transitions happen in this order.
          model.setArmed(true);
          model.setPressed(true);

          if (! button.isFocusOwner() && button.isRequestFocusEnabled())
            button.requestFocus();
        }
    }
}
项目:javify    文件:BasicButtonUI.java   
/**
 * Paint the icon for this component. Depending on the state of the
 * component and the availability of the button's various icon
 * properties, this might mean painting one of several different icons.
 *
 * @param g Graphics context to paint with
 * @param c Component to paint the icon of
 * @param iconRect Rectangle in which the icon should be painted
 */
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect)
{
  AbstractButton b = (AbstractButton) c;
  Icon i = currentIcon(b);

  if (i != null)
    {
      ButtonModel m = b.getModel();
      if (m.isPressed() && m.isArmed())
        {
          int offs = getTextShiftOffset();
          i.paintIcon(c, g, iconRect.x + offs, iconRect.y + offs);
        }
      else
        i.paintIcon(c, g, iconRect.x, iconRect.y);
    }
}
项目:xdm    文件:XDMMenuItemUI.java   
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
   ButtonModel model = menuItem.getModel();
   Color oldColor = g.getColor();
   int menuWidth = menuItem.getWidth();
   int menuHeight = menuItem.getHeight();
   g.setColor(this.colorBg);
   g.fillRect(0, 0, menuWidth, menuHeight);
   if(model.isArmed() || menuItem instanceof JMenu && model.isSelected()) {
      this.paintButtonPressed(g, menuItem);
   }

   if(menuItem instanceof JCheckBoxMenuItem) {
      ((JCheckBoxMenuItem)menuItem).isSelected();
   }

   g.setColor(oldColor);
}
项目:xdm    文件:XDMButtonUI.java   
public void paint(Graphics g, JComponent c) {
   try {
      AbstractButton b = (AbstractButton)c;
      ButtonModel bm = b.getModel();
      if(bm.isRollover()) {
         this.paintButtonRollOver(g, b);
      } else {
         this.paintButtonNormal(g, b);
      }

      super.paint(g, c);
   } catch (Exception var5) {
      ;
   }

}
项目:seaglass    文件:SeaGlassButtonUI.java   
/**
 * Returns the Icon to use in painting the button.
 *
 * @param  b the button.
 *
 * @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);
    }

    if (icon == null) {
        return getDefaultIcon(b);
    }

    return icon;
}
项目:rapidminer-studio    文件:CheckBoxMenuItemIcon.java   
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    JMenuItem b = (JMenuItem) c;
    ButtonModel model = b.getModel();

    g.translate(x, y);

    boolean isSelected = model.isSelected();
    boolean isEnabled = model.isEnabled();

    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // draw check mark
    if (isSelected) {
        g2.setStroke(CHECKBOX_STROKE);
        if (isEnabled) {
            g2.setColor(Colors.CHECKBOX_CHECKED);
        } else {
            g2.setColor(Colors.CHECKBOX_CHECKED_DISABLED);
        }
        g2.drawLine(2, 6, 5, 8);
        g2.drawLine(5, 8, 9, 1);
    }
    g.translate(-x, -y);
}
项目:beautyeye    文件:BECheckBoxMenuItemUI.java   
public void paintIcon(Component c, Graphics g, int x, int y) 
        {
            AbstractButton b = (AbstractButton) c;
            ButtonModel model = b.getModel();

            Image selectedImg = __IconFactory__.getInstance().getCheckboxMenuItemSelectedNormalIcon().getImage();
            boolean isSelected = model.isSelected();
//          boolean isArmed = model.isArmed();
            if (isSelected) 
            {
//              if(isArmed)
//                  selectedImg = __IconFactory__.getInstance().getCheckboxMenuItemSelectedRoverIcon().getImage();
            }
            else
                selectedImg = __IconFactory__.getInstance().getCheckboxMenuItemNoneIcon().getImage();

            g.drawImage(selectedImg
                    , x+(usedForVista?5:-4)//* 注意:当用于windows平台专用主类且处于Vista及更高版win时要做不一样的处理哦
                    , y - 3
                    , null);
        }
项目:confluence.keygen    文件:PlasticXPBorders.java   
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 101:    */     {
/* 102:176 */       AbstractButton button = (AbstractButton)c;
/* 103:177 */       ButtonModel model = button.getModel();
/* 104:179 */       if (!model.isEnabled())
/* 105:    */       {
/* 106:180 */         PlasticXPUtils.drawDisabledButtonBorder(g, x, y, w, h);
/* 107:181 */         return;
/* 108:    */       }
/* 109:184 */       boolean isPressed = (model.isPressed()) && (model.isArmed());
/* 110:185 */       boolean isDefault = ((button instanceof JButton)) && (((JButton)button).isDefaultButton());
/* 111:    */       
/* 112:187 */       boolean isFocused = (button.isFocusPainted()) && (button.hasFocus());
/* 113:189 */       if (isPressed) {
/* 114:190 */         PlasticXPUtils.drawPressedButtonBorder(g, x, y, w, h);
/* 115:191 */       } else if (isFocused) {
/* 116:192 */         PlasticXPUtils.drawFocusedButtonBorder(g, x, y, w, h);
/* 117:193 */       } else if (isDefault) {
/* 118:194 */         PlasticXPUtils.drawDefaultButtonBorder(g, x, y, w, h);
/* 119:    */       } else {
/* 120:196 */         PlasticXPUtils.drawPlainButtonBorder(g, x, y, w, h);
/* 121:    */       }
/* 122:    */     }
项目:seaglass    文件:SeaGlassTabbedPaneUI.java   
/**
 * Paint the background for a tab scroll button.
 *
 * @param ss           the tab subregion SynthContext.
 * @param g            the Graphics context.
 * @param scrollButton the button to paint.
 */
protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) {
    Rectangle tabRect = scrollButton.getBounds();
    int       x       = tabRect.x;
    int       y       = tabRect.y;
    int       height  = tabRect.height;
    int       width   = tabRect.width;

    boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight());

    SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect);

    tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition",
                              ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last");

    int         oldState    = tabContext.getComponentState();
    ButtonModel model       = scrollButton.getModel();
    int         isPressed   = model.isPressed() && model.isArmed() ? PRESSED : 0;
    int         buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed;

    tabContext.setComponentState(buttonState);
    tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement);
    tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement);
    tabContext.setComponentState(oldState);
}
项目:jo-widgets    文件:JoArrowButton.java   
@Override
public void paintIcon(final Component component, final Graphics graphics, final int x, final int y) {
    final AbstractButton button = (AbstractButton) component;
    final ButtonModel buttonModel = button.getModel();

    final int width = WIDTH - 2;
    final int height = HEIGHT;

    graphics.translate(x, y);

    String colorUI = null;
    if (buttonModel.isEnabled()) {
        colorUI = "controlText";
    }
    else {
        colorUI = "textInactiveText";
    }
    graphics.setColor(UIManager.getColor(colorUI));

    for (int i = 0; i < height; i++) {
        graphics.drawLine(i + 1, i, width - i, i);
    }
    graphics.translate(-x, -y);
}
项目:confluence.keygen    文件:PlasticArrowButton.java   
private void paint3D(Graphics g)
/* 286:    */   {
/* 287:334 */     ButtonModel buttonModel = getModel();
/* 288:335 */     if (((buttonModel.isArmed()) && (buttonModel.isPressed())) || (buttonModel.isSelected())) {
/* 289:336 */       return;
/* 290:    */     }
/* 291:338 */     int width = getWidth();
/* 292:339 */     int height = getHeight();
/* 293:340 */     if (getDirection() == 3) {
/* 294:341 */       width -= 2;
/* 295:342 */     } else if (getDirection() == 5) {
/* 296:343 */       height -= 2;
/* 297:    */     }
/* 298:345 */     Rectangle r = new Rectangle(1, 1, width, height);
/* 299:346 */     boolean isHorizontal = (getDirection() == 3) || (getDirection() == 7);
/* 300:347 */     PlasticUtils.addLight3DEffekt(g, r, isHorizontal);
/* 301:    */   }
项目:SmartTokens    文件:HudCheckBoxUI.java   
/**
 * Draws the check in the check box using the appropriate color based on the
 * {@link ButtonModel#isPressed} state. Note that part of the check will be drawn outside
 * it's bounds. Because this icon is actually being drawn inside a larger component (a
 * {@link javax.swing.JCheckBox}), this shouldn't be an issue.
 */
private void drawCheckMark(Graphics2D graphics, ButtonModel model) {
    int x1 = CHECK_BOX_SIZE / 4;
    int y1 = CHECK_BOX_SIZE / 3;
    int x2 = x1 + CHECK_BOX_SIZE / 6;
    int y2 = y1 + CHECK_BOX_SIZE / 4;
    int x3 = CHECK_BOX_SIZE - 2;
    int y3 = -1;

    Color color = model.isPressed() ?
            HudPaintingUtils.PRESSED_MARK_COLOR : fontColor;

    graphics.setStroke(new BasicStroke(1.65f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND));
    graphics.setColor(color);
    graphics.drawLine(x1, y1, x2, y2);
    graphics.drawLine(x2, y2, x3, y3);
}
项目:confluence.keygen    文件:PlasticBorders.java   
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 278:    */     {
/* 279:410 */       AbstractButton button = (AbstractButton)c;
/* 280:411 */       ButtonModel model = button.getModel();
/* 281:413 */       if (model.isEnabled())
/* 282:    */       {
/* 283:414 */         boolean isPressed = (model.isPressed()) && (model.isArmed());
/* 284:416 */         if (isPressed) {
/* 285:417 */           PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
/* 286:    */         } else {
/* 287:419 */           PlasticUtils.drawButtonBorder(g, x, y, w, h, false);
/* 288:    */         }
/* 289:    */       }
/* 290:    */       else
/* 291:    */       {
/* 292:421 */         PlasticUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
/* 293:    */       }
/* 294:    */     }
项目:confluence.keygen    文件:PlasticBorders.java   
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 497:    */     {
/* 498:598 */       JMenuItem b = (JMenuItem)c;
/* 499:599 */       ButtonModel model = b.getModel();
/* 500:601 */       if ((model.isArmed()) || (model.isSelected()))
/* 501:    */       {
/* 502:602 */         g.setColor(PlasticLookAndFeel.getControlDarkShadow());
/* 503:603 */         g.drawLine(0, 0, w - 2, 0);
/* 504:604 */         g.drawLine(0, 0, 0, h - 1);
/* 505:    */         
/* 506:    */ 
/* 507:607 */         g.setColor(PlasticLookAndFeel.getPrimaryControlHighlight());
/* 508:608 */         g.drawLine(w - 1, 0, w - 1, h - 1);
/* 509:    */       }
/* 510:609 */       else if (model.isRollover())
/* 511:    */       {
/* 512:610 */         g.translate(x, y);
/* 513:611 */         PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
/* 514:612 */         g.translate(-x, -y);
/* 515:    */       }
/* 516:    */     }
项目:confluence.keygen    文件:PlasticBorders.java   
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 585:    */     {
/* 586:666 */       AbstractButton b = (AbstractButton)c;
/* 587:667 */       ButtonModel model = b.getModel();
/* 588:669 */       if (!model.isEnabled()) {
/* 589:670 */         return;
/* 590:    */       }
/* 591:672 */       if (!(c instanceof JToggleButton))
/* 592:    */       {
/* 593:673 */         if ((model.isRollover()) && ((!model.isPressed()) || (model.isArmed()))) {
/* 594:674 */           super.paintBorder(c, g, x, y, w, h);
/* 595:    */         }
/* 596:676 */         return;
/* 597:    */       }
/* 598:683 */       if (model.isRollover())
/* 599:    */       {
/* 600:684 */         if ((model.isPressed()) && (model.isArmed())) {
/* 601:685 */           PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
/* 602:    */         } else {
/* 603:687 */           PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
/* 604:    */         }
/* 605:    */       }
/* 606:689 */       else if (model.isSelected()) {
/* 607:690 */         PlasticUtils.drawDark3DBorder(g, x, y, w, h);
/* 608:    */       }
/* 609:    */     }