javax.swing.JButton#setRolloverIcon ( )源码实例Demo

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

源代码1 项目: netbeans   文件: StatusLineComponent.java
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 ) );
    }
}
 
源代码2 项目: netbeans   文件: DocumentSwitcherTable.java
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;
}
 
源代码3 项目: aurous-app   文件: PlayerFunctions.java
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();
	}
}
 
源代码4 项目: aurous-app   文件: PlayerFunctions.java
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();
	}
}
 
源代码5 项目: runelite   文件: ClockTabPanel.java
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;
}
 
源代码6 项目: zap-extensions   文件: CloseTabPanel.java
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));
}
 
源代码7 项目: plugins   文件: StopwatchPanel.java
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);
}
 
源代码8 项目: filthy-rich-clients   文件: VistaSearchDialog.java
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);
}
 
源代码9 项目: netbeans   文件: CloseButtonFactory.java
/**
 * 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;
}
 
源代码10 项目: runelite   文件: KourendLibraryPanel.java
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();
}
 
源代码11 项目: runelite   文件: ConfigPanel.java
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);
}
 
源代码12 项目: runelite   文件: StopwatchPanel.java
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);
}
 
源代码13 项目: JAVA-MVC-Swing-Monopoly   文件: FrameConfig.java
/**
 * 
 * ͼ�갴ť
 * 
 * */
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;
}
 
源代码14 项目: java-QQ-   文件: hover_press_utilclass.java
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;	

}
 
源代码15 项目: java-QQ-   文件: hover_press_utilclass.java
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;
	
}
 
源代码16 项目: java-QQ-   文件: hover_press_utilclass.java
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;
}
 
源代码17 项目: java-QQ-   文件: hover_press_utilclass.java
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;
}
 
源代码18 项目: binnavi   文件: CBreakpointToolbar.java
/**
 * 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;
}
 
源代码19 项目: runelite   文件: ConfigPanel.java
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);
}
 
源代码20 项目: binnavi   文件: CDebuggerToolbar.java
/**
 * 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;
}