javax.swing.AbstractButton#setFocusPainted ( )源码实例Demo

下面列出了javax.swing.AbstractButton#setFocusPainted ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pumpernickel   文件: MockComponent.java
/**
 * Temporarily massage this component so it is visible, enabled, unselected,
 * unfocused, etc.
 */
private void storeState(JComponent c) {
	if (c instanceof AbstractButton) {
		AbstractButton b = (AbstractButton) c;
		b.putClientProperty(WAS_SELECTED, new Boolean(b.isSelected()));
		b.putClientProperty(WAS_FOCUS_PAINTED, new Boolean(b.isSelected()));
		b.setSelected(false);
		b.setFocusPainted(false);
	}
	if (c.isEnabled() == false) {
		c.putClientProperty(WAS_ENABLED, new Boolean(c.isEnabled()));
		c.setEnabled(true);
	}
	if (c.isVisible() == false) {
		c.putClientProperty(WAS_VISIBLE, new Boolean(c.isVisible()));
		c.setVisible(true);
	}
	for (int a = 0; a < c.getComponentCount(); a++) {
		if (c.getComponent(a) instanceof JComponent) {
			storeState((JComponent) c.getComponent(a));
		}
	}
}
 
源代码2 项目: pumpernickel   文件: Inspector.java
protected Insets prepareButton(AbstractButton b) {
	if (b.isFocusPainted()) {
		// if painting the focus makes a button larger: then we need
		// to acknowledge that so the getInsets method still
		// right-aligns our labels and checkboxes correctly.
		Dimension d1 = b.getPreferredSize();
		b.setFocusPainted(false);
		Dimension d2 = b.getPreferredSize();
		b.setFocusPainted(true);
		Insets negativeInsets = new Insets(0, 0, d2.width - d1.width,
				d2.height - d1.height);
		b.putClientProperty(PROPERTY_NEGATIVE_INSETS, negativeInsets);
		return negativeInsets;
	}
	return null;
}
 
源代码3 项目: pumpernickel   文件: MockComponent.java
/** Restore this component back to its original goodness. */
private void restoreState(JComponent c) {
	if (c instanceof AbstractButton) {
		AbstractButton b = (AbstractButton) c;
		if (b.getClientProperty(WAS_SELECTED) != null) {
			b.setSelected(((Boolean) b.getClientProperty(WAS_SELECTED))
					.booleanValue());
			b.putClientProperty(WAS_SELECTED, null);
		}
		if (b.getClientProperty(WAS_FOCUS_PAINTED) != null) {
			b.setFocusPainted(((Boolean) b
					.getClientProperty(WAS_FOCUS_PAINTED)).booleanValue());
			b.putClientProperty(WAS_FOCUS_PAINTED, null);
		}
	}
	if (c.getClientProperty(WAS_ENABLED) != null) {
		c.setEnabled(((Boolean) c.getClientProperty(WAS_ENABLED))
				.booleanValue());
		c.putClientProperty(WAS_ENABLED, null);
	}
	if (c.getClientProperty(WAS_VISIBLE) != null) {
		c.setVisible(((Boolean) c.getClientProperty(WAS_VISIBLE))
				.booleanValue());
		c.putClientProperty(WAS_VISIBLE, null);
	}
	for (int a = 0; a < c.getComponentCount(); a++) {
		if (c.getComponent(a) instanceof JComponent) {
			restoreState((JComponent) c.getComponent(a));
		}
	}
}
 
源代码4 项目: runelite   文件: SwingUtil.java
public static void removeButtonDecorations(AbstractButton button)
{
	button.setBorderPainted(false);
	button.setContentAreaFilled(false);
	button.setFocusPainted(false);
	button.setMargin(new Insets(0, 0, 0, 0));
	button.setOpaque(false);
}
 
源代码5 项目: tuxguitar   文件: TGToolBar.java
private AbstractButton getImageButton( AbstractButton button, String iconPrefix, String iconSuffix ){
	button.setHorizontalTextPosition(JButton.CENTER);
	button.setVerticalTextPosition(JButton.CENTER);
	button.setBorderPainted( false );
	button.setContentAreaFilled( false );
	button.setFocusPainted( false );
	button.setMargin( new Insets(0,0,0,0) );
	button.setIcon( TGResourceUtils.loadIcon( iconPrefix + iconSuffix ) );
	button.setPressedIcon( TGResourceUtils.loadIcon( iconPrefix + "_pressed" + iconSuffix ) );
	button.setRolloverIcon( TGResourceUtils.loadIcon( iconPrefix + "_over" + iconSuffix ) );
	button.setSelectedIcon( TGResourceUtils.loadIcon( iconPrefix + "_selected" + iconSuffix ) );
	button.setRolloverSelectedIcon( TGResourceUtils.loadIcon( iconPrefix + "_selected_over" + iconSuffix ) );
	return button;
}
 
源代码6 项目: snap-desktop   文件: ProductSceneView.java
private AdjustableViewScrollPane createScrollPane() {
    AbstractButton zoomAllButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomAll13.gif"),
            false);
    zoomAllButton.setFocusable(false);
    zoomAllButton.setFocusPainted(false);
    zoomAllButton.addActionListener(e -> getLayerCanvas().zoomAll());

    AdjustableViewScrollPane scrollPane = new AdjustableViewScrollPane(layerCanvas);
    // todo - use sceneImage.getConfiguration() (nf, 18.09.2008)
    scrollPane.setBackground(DEFAULT_IMAGE_BACKGROUND_COLOR);
    scrollPane.setCornerComponent(zoomAllButton);
    return scrollPane;
}