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

The following examples show how to use javax.swing.JButton#setRolloverIcon() . 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: DocumentSwitcherTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JButton createCloseButton() {
    JButton res = CloseButtonFactory.createBigCloseButton();
    res.setModel( new DefaultButtonModel() {
        @Override
        public boolean isRollover() {
            return inCloseButtonRect;
        }
    });
    //allow third party look and feels to provide their own icons
    Icon defaultIcon = UIManager.getIcon( "nb.popupswitcher.closebutton.defaultIcon" ); //NOI18N
    if( null != defaultIcon )
        res.setIcon( defaultIcon );
    Icon rolloverIcon = UIManager.getIcon( "nb.popupswitcher.closebutton.rolloverIcon" ); //NOI18N
    if( null != rolloverIcon )
        res.setRolloverIcon( rolloverIcon );
    return res;
}
 
Example 3
Source File: PlayerFunctions.java    From aurous-app with GNU General Public License v2.0 6 votes vote down vote up
public static void pause(final JButton mediaStateButton) {
	try {
		if (UISession.getMediaPlayer() != null) {
			final Image playBackPaused = ImageIO.read(mediaStateButton
					.getClass().getResource("/resources/btplay2.png"));
			final Image playBackPausedHover = ImageIO.read(mediaStateButton
					.getClass().getResource("/resources/btplay2_h.png"));
			mediaStateButton.setIcon(new ImageIcon(playBackPaused));
			mediaStateButton.setRolloverIcon(new ImageIcon(
					playBackPausedHover));
			UISession.getMediaPlayer().pause();
			isPaused = true;
			mediaStateButton.setToolTipText("Play");
		}
	} catch (final IOException e) {
		e.printStackTrace();
	}
}
 
Example 4
Source File: ClockTabPanel.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private JPanel createHeaderPanel(String title, String type, boolean largePadding, ActionListener actionListener)
{
	JPanel panel = new JPanel(new BorderLayout());
	panel.setBorder(new EmptyBorder(largePadding ? 11 : 0, 0, 0, 0));
	panel.setBackground(ColorScheme.DARK_GRAY_COLOR);

	JLabel headerLabel = new JLabel(title);
	headerLabel.setForeground(Color.WHITE);
	headerLabel.setFont(FontManager.getRunescapeSmallFont());
	panel.add(headerLabel, BorderLayout.CENTER);

	JButton addButton = new JButton(ADD_ICON);
	addButton.setRolloverIcon(ADD_ICON_HOVER);
	SwingUtil.removeButtonDecorations(addButton);
	addButton.setPreferredSize(new Dimension(14, 14));
	addButton.setToolTipText("Add a " + type);
	addButton.addActionListener(actionListener);
	panel.add(addButton, BorderLayout.EAST);

	return panel;
}
 
Example 5
Source File: PlayerFunctions.java    From aurous-app with GNU General Public License v2.0 6 votes vote down vote up
public static void play(final JButton mediaStateButton) {
	try {
		if (UISession.getMediaPlayer() != null) {
			final Image playBackPaused = ImageIO.read(mediaStateButton
					.getClass().getResource("/resources/btpause2.png"));
			final Image playBackPausedHover = ImageIO.read(mediaStateButton
					.getClass().getResource("/resources/btpause2_h.png"));
			mediaStateButton.setIcon(new ImageIcon(playBackPaused));
			mediaStateButton.setRolloverIcon(new ImageIcon(
					playBackPausedHover));

			UISession.getMediaPlayer().play();
			isPaused = false;
			mediaStateButton.setToolTipText("Pause");
		}
	} catch (final IOException e) {
		e.printStackTrace();
	}
}
 
Example 6
Source File: ConfigPanel.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void toggleSection(ConfigSectionDescriptor csd, JButton button, JPanel contents)
{
	boolean newState = !contents.isVisible();
	contents.setVisible(newState);
	button.setIcon(newState ? SECTION_RETRACT_ICON : SECTION_EXPAND_ICON);
	button.setRolloverIcon(newState ? SECTION_RETRACT_ICON_HOVER : SECTION_EXPAND_ICON_HOVER);
	button.setToolTipText(newState ? "Retract" : "Expand");
	sectionExpandStates.put(csd, newState);
	SwingUtilities.invokeLater(contents::revalidate);
}
 
Example 7
Source File: CBreakpointToolbar.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new button and adds it to the toolbar.
 *
 * @param action The action object to execute when the button is clicked.
 * @param defaultIconPath Path to the icon that is shown on the button.
 * @param rolloverIconPath Path to the rollover icon of the button.
 * @param pressedIconPath Path to the icon that is shown when the button is pressed.
 *
 * @return The created button.
 */
private JButton createAndAddButtonToToolbar(final AbstractAction action,
    final String defaultIconPath, final String rolloverIconPath, final String pressedIconPath) {
  final JButton button = add(CActionProxy.proxy(action));
  button.setBorder(new EmptyBorder(0, 0, 0, 0));

  button.setIcon(new ImageIcon(CMain.class.getResource(defaultIconPath)));
  button.setRolloverIcon(new ImageIcon(CMain.class.getResource(rolloverIconPath)));
  button.setPressedIcon(new ImageIcon(CMain.class.getResource(pressedIconPath)));

  return button;
}
 
Example 8
Source File: hover_press_utilclass.java    From java-QQ- with Apache License 2.0 5 votes vote down vote up
public static JButton getbtnClose()
{
	JButton btnclose=new JButton();
	btnclose.setIcon(new ImageIcon("image/close.png"));
	btnclose.setRolloverIcon(new ImageIcon("image/close_hover.png"));
	btnclose.setPressedIcon(new ImageIcon("image/close_press.png"));
	btnclose.setBorder(null);
	return btnclose;
}
 
Example 9
Source File: hover_press_utilclass.java    From java-QQ- with Apache License 2.0 5 votes vote down vote up
public static JButton getbtnShezhi() {
	JButton button=new JButton();
	button.setIcon(new ImageIcon("image/shezhi.png"));
	button.setPressedIcon(new ImageIcon("image/shezhi_press.png"));
	button.setRolloverIcon(new ImageIcon("image/shezhi_hover.png"));
	button.setToolTipText("����");
	button.setBorder(null);
	button.setFocusPainted(false);
	button.setContentAreaFilled(false);
	return button;
}
 
Example 10
Source File: hover_press_utilclass.java    From java-QQ- with Apache License 2.0 5 votes vote down vote up
public static JButton getbtnMin() {
	
	JButton button=new JButton();
	button.setIcon(new ImageIcon("image/min.png"));
	button.setPressedIcon(new ImageIcon("image/min_press.png"));
	button.setRolloverIcon(new ImageIcon("image/min_hover.png"));
	button.setToolTipText("����");
	button.setBorder(null);
	button.setFocusPainted(false);
	button.setContentAreaFilled(false);
	return button;
	
}
 
Example 11
Source File: hover_press_utilclass.java    From java-QQ- with Apache License 2.0 5 votes vote down vote up
public static JButton getbtnButton(String iconpath,String rolloverIconpath,String pressIconpath)
{ 

	JButton button=new JButton();
	button.setIcon(new ImageIcon(iconpath));
	button.setRolloverIcon(new ImageIcon(rolloverIconpath));
    button.setPressedIcon(new ImageIcon(pressIconpath));
    button.setBorder(null);
    button.setFocusPainted(false);
    button.setContentAreaFilled(false);
  
    return button;	

}
 
Example 12
Source File: FrameConfig.java    From JAVA-MVC-Swing-Monopoly with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * ͼ�갴ť
 * 
 * */
public JButton createButton(int x, int y, ImageIcon[] img, char keyLinstenr) {
	JButton add = new JButton("", img[0]);
	add.setPressedIcon(img[3]);
	add.setRolloverIcon(img[2]);
	add.setMnemonic(keyLinstenr);
	add.setBounds(x, y, img[0].getIconWidth(), img[0].getIconHeight());
	return add;
}
 
Example 13
Source File: StopwatchPanel.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
StopwatchPanel(ClockManager clockManager, Stopwatch stopwatch)
{
	super(clockManager, stopwatch, "stopwatch", false);

	this.stopwatch = stopwatch;

	lapsContainer = new JPanel(new GridBagLayout());
	lapsContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	rebuildLapList();

	contentContainer.add(lapsContainer);

	JButton lapButton = new JButton(ClockTabPanel.LAP_ICON);
	lapButton.setRolloverIcon(ClockTabPanel.LAP_ICON_HOVER);
	SwingUtil.removeButtonDecorations(lapButton);
	lapButton.setPreferredSize(new Dimension(16, 14));
	lapButton.setToolTipText("Add lap time");

	lapButton.addActionListener(e ->
	{
		stopwatch.lap();
		rebuildLapList();
		clockManager.saveStopwatches();
	});

	leftActions.add(lapButton);

	JButton deleteButton = new JButton(ClockTabPanel.DELETE_ICON);
	deleteButton.setRolloverIcon(ClockTabPanel.DELETE_ICON_HOVER);
	SwingUtil.removeButtonDecorations(deleteButton);
	deleteButton.setPreferredSize(new Dimension(16, 14));
	deleteButton.setToolTipText("Delete stopwatch");
	deleteButton.addActionListener(e -> clockManager.removeStopwatch(stopwatch));
	rightActions.add(deleteButton);
}
 
Example 14
Source File: KourendLibraryPanel.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void init()
{
	setLayout(new BorderLayout(0, 5));
	setBorder(new EmptyBorder(10, 10, 10, 10));
	setBackground(ColorScheme.DARK_GRAY_COLOR);

	JPanel books = new JPanel(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.HORIZONTAL;
	c.weightx = 1;
	c.gridx = 0;
	c.gridy = 0;
	Stream.of(Book.values())
		.filter(b -> !b.isDarkManuscript())
		.filter(b -> !config.hideVarlamoreEnvoy() || b != Book.VARLAMORE_ENVOY)
		.sorted(Comparator.comparing(Book::getShortName))
		.forEach(b ->
		{
			BookPanel p = new BookPanel(b);
			bookPanels.put(b, p);
			books.add(p, c);
			c.gridy++;
		});

	JButton reset = new JButton("Reset", RESET_ICON);
	reset.setRolloverIcon(RESET_HOVER_ICON);
	reset.addActionListener(ev ->
	{
		library.reset();
		update();
	});

	add(reset, BorderLayout.NORTH);
	add(books, BorderLayout.CENTER);
	update();
}
 
Example 15
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 16
Source File: VistaSearchDialog.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private TitleBar(String title) {
    this.title = title;
    setName("vistaTitleBar");
    setFont(new Font("Dialog", Font.BOLD, 12));
    setLayout(new GridBagLayout());

    JButton button = new JButton();
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorder(null);
    button.setIconTextGap(0);
    button.setVerticalAlignment(SwingConstants.TOP);
    button.setContentAreaFilled(false);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setIcon(new ImageIcon(getClass().getResource("close-title-bar.png")));
    button.setRolloverIcon(new ImageIcon(getClass().getResource("close-title-bar-rollover.png")));
    button.setOpaque(false);
    button.setName("vistaCloseButton");
    add(Box.createVerticalStrut(24),
        new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
                               GridBagConstraints.LINE_START,
                               GridBagConstraints.HORIZONTAL,
                               new Insets(0, 0, 0, 0), 0, 0));
    add(button, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
                                       GridBagConstraints.FIRST_LINE_END,
                                       GridBagConstraints.VERTICAL,
                                       new Insets(0, 0, 0, 0), 0, 0));
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VistaSearchDialog.this.setVisible(false);
        }
    });

    Locator locator = new Locator();
    addMouseListener(locator);
    addMouseMotionListener(locator);
}
 
Example 17
Source File: StopwatchPanel.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
StopwatchPanel(ClockManager clockManager, Stopwatch stopwatch)
{
	super(clockManager, stopwatch, "stopwatch", false);

	this.stopwatch = stopwatch;

	lapsContainer = new JPanel(new GridBagLayout());
	lapsContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	rebuildLapList();

	contentContainer.add(lapsContainer);

	JButton lapButton = new JButton(ClockTabPanel.LAP_ICON);
	lapButton.setRolloverIcon(ClockTabPanel.LAP_ICON_HOVER);
	SwingUtil.removeButtonDecorations(lapButton);
	lapButton.setPreferredSize(new Dimension(16, 14));
	lapButton.setToolTipText("Add lap time");

	lapButton.addActionListener(e ->
	{
		stopwatch.lap();
		rebuildLapList();
		clockManager.saveStopwatches();
	});

	leftActions.add(lapButton);

	JButton deleteButton = new JButton(ClockTabPanel.DELETE_ICON);
	deleteButton.setRolloverIcon(ClockTabPanel.DELETE_ICON_HOVER);
	SwingUtil.removeButtonDecorations(deleteButton);
	deleteButton.setPreferredSize(new Dimension(16, 14));
	deleteButton.setToolTipText("Delete stopwatch");
	deleteButton.addActionListener(e -> clockManager.removeStopwatch(stopwatch));
	rightActions.add(deleteButton);
}
 
Example 18
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 19
Source File: ConfigPanel.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ConfigPanel()
{
	super(false);

	setLayout(new BorderLayout());
	setBackground(ColorScheme.DARK_GRAY_COLOR);

	JPanel topPanel = new JPanel();
	topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
	topPanel.setLayout(new BorderLayout(0, BORDER_OFFSET));
	add(topPanel, BorderLayout.NORTH);

	mainPanel = new FixedWidthPanel();
	mainPanel.setBorder(new EmptyBorder(8, 10, 10, 10));
	mainPanel.setLayout(new DynamicGridLayout(0, 1, 0, 5));
	mainPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

	JPanel northPanel = new FixedWidthPanel();
	northPanel.setLayout(new BorderLayout());
	northPanel.add(mainPanel, BorderLayout.NORTH);

	JScrollPane scrollPane = new JScrollPane(northPanel);
	scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	add(scrollPane, BorderLayout.CENTER);

	JButton topPanelBackButton = new JButton(BACK_ICON);
	topPanelBackButton.setRolloverIcon(BACK_ICON_HOVER);
	SwingUtil.removeButtonDecorations(topPanelBackButton);
	topPanelBackButton.setPreferredSize(new Dimension(22, 0));
	topPanelBackButton.setBorder(new EmptyBorder(0, 0, 0, 5));
	topPanelBackButton.addActionListener(e -> pluginList.getMuxer().popState());
	topPanelBackButton.setToolTipText("Back");
	topPanel.add(topPanelBackButton, BorderLayout.WEST);

	pluginToggle = new PluginToggleButton();
	topPanel.add(pluginToggle, BorderLayout.EAST);
	title = new JLabel();
	title.setForeground(Color.WHITE);

	topPanel.add(title);
}
 
Example 20
Source File: CDebuggerToolbar.java    From binnavi with Apache License 2.0 3 votes vote down vote up
/**
 * Small helper function for adding buttons to the toolbar.
 *
 * @param action Action associated with the new button.
 * @param defaultIconPath Path to the default icon for the button.
 * @param rolloverIconPath Path to the roll-over icon for the button.
 * @param pressedIconPath Path to the pressed icon for the button.
 *
 * @return The created button.
 */
private JButton createAndAddIconToToolbar(final Action action, final String defaultIconPath,
    final String rolloverIconPath, final String pressedIconPath) {
  final JButton button = add(CActionProxy.proxy(action));
  button.setBorder(new EmptyBorder(0, 0, 0, 0));
  button.setIcon(new ImageIcon(CMain.class.getResource(defaultIconPath)));
  button.setRolloverIcon(new ImageIcon(CMain.class.getResource(rolloverIconPath)));
  button.setPressedIcon(new ImageIcon(CMain.class.getResource(pressedIconPath)));
  return button;
}