Java Code Examples for javax.swing.JButton#setRolloverEnabled()

The following examples show how to use javax.swing.JButton#setRolloverEnabled() . 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: StatusLineComponent.java    From netbeans with Apache License 2.0 8 votes vote down vote up
private void createCloseButton() {
    discardCloseButton();
    closeButton = new JButton();
    closeButton.setBorderPainted(false);
    closeButton.setBorder(BorderFactory.createEmptyBorder());
    closeButton.setOpaque(false);
    closeButton.setContentAreaFilled(false);
    
    Object img = UIManager.get("nb.progress.cancel.icon");
    if( null != img ) {
        closeButton.setIcon( ListComponent.iconOrImage2icon( img ) );
    }
    img = UIManager.get("nb.progress.cancel.icon.mouseover");
    if( null != img ) {
        closeButton.setRolloverEnabled(true);
        closeButton.setRolloverIcon( ListComponent.iconOrImage2icon( img ) );
    }
    img = UIManager.get("nb.progress.cancel.icon.pressed");
    if( null != img ) {
        closeButton.setPressedIcon( ListComponent.iconOrImage2icon( img ) );
    }
}
 
Example 2
Source File: WatchAnnotationProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void addActions(JToolBar tb, Action[] actions) {
    tb.removeAll();
    boolean visible = false;
    if (actions != null) {
        for (Action a : actions) {
            if (a != null) {
                JButton btn = tb.add(a);
                btn.setBorder(new javax.swing.border.EmptyBorder(0, 2, 0, 2));
                btn.setBorderPainted(false);
                btn.setContentAreaFilled(false);
                btn.setRolloverEnabled(false);
                btn.setOpaque(false);
                btn.setFocusable(false);
                visible = true;
            } else {
                tb.add(new JSeparator(JSeparator.VERTICAL));
            }
        }
    }
    tb.setVisible(visible);
}
 
Example 3
Source File: BrowserMenu.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JComponent createConfigureButton() {
    if( null == browserProvider || !browserProvider.hasCustomizer() )
        return null;
    JButton button = new JButton(NbBundle.getMessage(BrowserMenu.class, "Ctl_ConfigurePhoneGap"));
    button.addActionListener( new ActionListener() {

        @Override
        public void actionPerformed( ActionEvent e ) {
            browserProvider.customize();
        }
    });
    button.setBorder( new EmptyBorder(1, 1, 1, 1) );
    button.setMargin( new Insets(0, 0, 0, 0) );

    button.setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
    button.setHorizontalAlignment( JLabel.LEFT );
    button.setFocusable( false );

    button.setBorderPainted( false );
    button.setFocusPainted( false );
    button.setRolloverEnabled( true );
    button.setContentAreaFilled( false );

    return button;
}
 
Example 4
Source File: ControlsToolbar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void addImpl( Component comp, Object constraints, int index ) {
    super.addImpl( comp, constraints, index ); 
    if( comp instanceof JButton ) {
        JButton btn = (JButton) comp;
        btn.setContentAreaFilled( false );
        btn.setOpaque( false );
        btn.setBorder( BorderFactory.createEmptyBorder(2,2,2,2) );
        btn.setFocusable( false );
        btn.setBorderPainted( false );
        btn.setRolloverEnabled( UIManager.getBoolean("nb.multitabs.button.rollover") );
    }
}
 
Example 5
Source File: CloseButtonFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a small 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel
 *
 * @return JButton with close icons.
 */
public static JButton createCloseButton() {
    JButton closeButton = new JButton();
    int size = 16;
    closeButton.setPreferredSize(new Dimension(size, size));
    closeButton.setContentAreaFilled(false);
    closeButton.setFocusable(false);
    closeButton.setBorder(BorderFactory.createEmptyBorder());
    closeButton.setBorderPainted(false);
    closeButton.setRolloverEnabled(true);
    closeButton.setIcon(getCloseTabImage());
    closeButton.setRolloverIcon(getCloseTabRolloverImage());
    closeButton.setPressedIcon(getCloseTabPressedImage());
    return closeButton;
}
 
Example 6
Source File: CloseButtonFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a big 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel
 *
 * @return JButton with close icons.
 */
public static JButton createBigCloseButton() {
    JButton closeButton = new JButton();
    int size = 19;
    closeButton.setPreferredSize(new Dimension(size, size));
    closeButton.setContentAreaFilled(false);
    closeButton.setFocusable(false);
    closeButton.setBorder(BorderFactory.createEmptyBorder());
    closeButton.setBorderPainted(false);
    closeButton.setRolloverEnabled(true);
    closeButton.setIcon(getBigCloseTabImage());
    closeButton.setRolloverIcon(getBigCloseTabRolloverImage());
    closeButton.setPressedIcon(getBigCloseTabPressedImage());
    return closeButton;
}
 
Example 7
Source File: MyToolBar.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
protected JButton makeNavigationButton(String action, ImageIcon i, ActionListener a) {
  JButton button = WebButton.createIconWebButton(i, StyleConstants.smallRound, true);
  button.setToolTipText(action);
  button.addActionListener(a);
  button.setFocusable(false);
  button.setBorderPainted(false);
  button.setRolloverEnabled(false);
  return button;
}
 
Example 8
Source File: CloseTabPanel.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public CloseTabPanel(String tabName, NumberedTabbedPane ntp) {
    super();
    this.ntp = ntp;
    this.setOpaque(false);
    JLabel lblTitle = new JLabel(tabName);
    JButton btnClose = new JButton();
    btnClose.setOpaque(false);

    // Configure icon and rollover icon for button
    btnClose.setRolloverIcon(CLOSE_TAB_RED_ICON);
    btnClose.setRolloverEnabled(true);
    btnClose.setContentAreaFilled(false);
    btnClose.setToolTipText(Constant.messages.getString("all.button.close"));
    btnClose.setIcon(CLOSE_TAB_GREY_ICON);
    // Set a border only on the left side so the button doesn't make the tab too big
    btnClose.setBorder(new EmptyBorder(0, 6, 0, 0));
    // This is needed to Macs for some reason
    btnClose.setBorderPainted(false);

    // Make sure the button can't get focus, otherwise it looks funny
    btnClose.setFocusable(false);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1;

    this.add(lblTitle, gbc);

    gbc.gridx++;
    gbc.weightx = 0;
    this.add(btnClose, gbc);

    btnClose.addActionListener(new CloseActionHandler(this.ntp, tabName));
}
 
Example 9
Source File: DefaultSyntaxKit.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add all pop-up menu items to a Toolbar.  <b>You need to call the validate method
 * on the toolbar after this is done to layout the buttons.</b>
 * Only Actions which have a SMALL_ICON property will be added to the toolbar
 * There are three Configuration Keys that affect the appearance of the added buttons:
 * CONFIG_TOOLBAR_ROLLOVER, CONFIG_TOOLBAR_BORDER, CONFIG_TOOLBAR_OPAQUE
 * 
 * @param editorPane
 * @param toolbar
 */
public void addToolBarActions(JEditorPane editorPane, JToolBar toolbar) {
	String[] toolBarItems = getConfig().getPropertyList(CONFIG_TOOLBAR);
	if (toolBarItems == null || toolBarItems.length == 0) {
		toolBarItems = getConfig().getPropertyList(CONFIG_MENU);
		if (toolBarItems == null || toolBarItems.length == 0) {
			return;
		}
	}
	boolean btnRolloverEnabled = getConfig().getBoolean(CONFIG_TOOLBAR_ROLLOVER, true);
	boolean btnBorderPainted = getConfig().getBoolean(CONFIG_TOOLBAR_BORDER, false);
	boolean btnOpaque = getConfig().getBoolean(CONFIG_TOOLBAR_OPAQUE, false);
	int btnBorderSize = getConfig().getInteger(CONFIG_TOOLBAR_BORDER_SIZE, 2);
	for (String menuString : toolBarItems) {
		if (menuString.equals("-") ||
			menuString.startsWith("<") ||
			menuString.startsWith(">")) {
			toolbar.addSeparator();
		} else {
			Action action = editorPane.getActionMap().get(menuString);
			if (action != null && action.getValue(Action.SMALL_ICON) != null) {
				JButton b = toolbar.add(action);
				b.setRolloverEnabled(btnRolloverEnabled);
				b.setBorderPainted(btnBorderPainted);
				b.setOpaque(btnOpaque);
				b.setFocusable(false);
				b.setBorder(BorderFactory.createEmptyBorder(btnBorderSize,
					btnBorderSize, btnBorderSize, btnBorderSize));
			}
		}
	}
}
 
Example 10
Source File: MainFrame.java    From ios-image-util with MIT License 5 votes vote down vote up
/**
 * Set preferences to Menu button.
 *
 * @param button
 * @param foregroundColor
 * @param backgroundColor
 * @param font
 * @return
 */
private JButton initMenuButton(JButton button, Color foregroundColor, Color backgroundColor, Font font) {
	button.setBackground(backgroundColor);
	button.setForeground(foregroundColor);
	button.setBorderPainted(false);
	button.setFocusPainted(false);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setFont(font);
	button.setMargin(new Insets(2, 16, 2, 16));
	button.setOpaque(true);
	button.setDoubleBuffered(true);
	button.setRolloverEnabled(true);
	return button;
}