当前位置: 首页>>代码示例>>Java>>正文


Java ButtonModel类代码示例

本文整理汇总了Java中javax.swing.ButtonModel的典型用法代码示例。如果您正苦于以下问题:Java ButtonModel类的具体用法?Java ButtonModel怎么用?Java ButtonModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ButtonModel类属于javax.swing包,在下文中一共展示了ButtonModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: register

import javax.swing.ButtonModel; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EditMediator.java

示例2: setModel

import javax.swing.ButtonModel; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ToggleBookmarkAction.java

示例3: getDefaultComponent

import javax.swing.ButtonModel; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProfilerPopup.java

示例4: getListCellRenderer

import javax.swing.ButtonModel; //导入依赖的package包/类
@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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FileSearchAction.java

示例5: testSetLocalizedTextWithModel

import javax.swing.ButtonModel; //导入依赖的package包/类
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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MnemonicsTest.java

示例6: paintIcon

import javax.swing.ButtonModel; //导入依赖的package包/类
@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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:CheckBoxMenuItemIcon.java

示例7: getStyle

import javax.swing.ButtonModel; //导入依赖的package包/类
@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);
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:17,代码来源:SettingsPanel.java

示例8: go

import javax.swing.ButtonModel; //导入依赖的package包/类
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);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DefaultButtonModelCrashTest.java

示例9: paintBackground

import javax.swing.ButtonModel; //导入依赖的package包/类
@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);
	}
 
开发者ID:kmarius,项目名称:xdman,代码行数:22,代码来源:XDMMenuUI.java

示例10: paint

import javax.swing.ButtonModel; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:chadbeaudin,项目名称:DataRecorder,代码行数:29,代码来源:ToolBarButtonUI.java

示例11: paintIcon

import javax.swing.ButtonModel; //导入依赖的package包/类
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);
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:24,代码来源:FilledButtonUI.java

示例12: paintText

import javax.swing.ButtonModel; //导入依赖的package包/类
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);
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:27,代码来源:FilledButtonUI.java

示例13: paintBackground

import javax.swing.ButtonModel; //导入依赖的package包/类
@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 );
		}
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:22,代码来源:TexturedButtonUI.java

示例14: getPreImg

import javax.swing.ButtonModel; //导入依赖的package包/类
/**
 * <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();
    }
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:29,代码来源:LuckCheckboxIcon.java

示例15: paint

import javax.swing.ButtonModel; //导入依赖的package包/类
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);
    }
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:23,代码来源:LuckButtonUI.java


注:本文中的javax.swing.ButtonModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。