Java Code Examples for javax.swing.AbstractButton#setFocusPainted()

The following examples show how to use javax.swing.AbstractButton#setFocusPainted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockComponent.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * 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));
		}
	}
}
 
Example 2
Source File: Inspector.java    From pumpernickel with MIT License 6 votes vote down vote up
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;
}
 
Example 3
Source File: MockComponent.java    From pumpernickel with MIT License 5 votes vote down vote up
/** 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));
		}
	}
}
 
Example 4
Source File: SwingUtil.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example 5
Source File: TGToolBar.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
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;
}
 
Example 6
Source File: ProductSceneView.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
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;
}