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

The following examples show how to use javax.swing.JButton#setPressedIcon() . 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: SwitchablePane.java    From DroidUIBuilder with Apache License 2.0 6 votes vote down vote up
private JButton createPageButton(final String key, String toolTipText)
{
	JButton btn = createImageButton(key, true);
	btn.setIcon(new NinePatchIcon(29, DEFAULT_BUTTON_HEIGHT, 
					NPIconFactory.getInstance().getSwitchable_btn_nornal()));
	btn.setPressedIcon(new NinePatchIcon(29, DEFAULT_BUTTON_HEIGHT, 
					NPIconFactory.getInstance().getSwitchable_btn_pressed()));
	btn.setToolTipText(toolTipText);
	btn.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e)
		{
			((CardLayout)cardPane.getLayout()).show(cardPane, key);
			// 把当前所显示的卡片的顺序号存起来
			currrentCardIndex = Integer.parseInt(key);// key就是该 card对应的顺序号
			// 刷新按钮面板用于更新当前显示card对应按钮的小图标的绘制
			btnPane.repaint();
		}
	});
	return btn;
}
 
Example 3
Source File: SwitchablePane.java    From DroidUIBuilder with Apache License 2.0 6 votes vote down vote up
private JButton initNextButton()
{
	JButton btnNext = createImageButton("", false);
	btnNext.setIcon(new NinePatchIcon(36, DEFAULT_BUTTON_HEIGHT, 
					NPIconFactory.getInstance().getSwitchable_next_normal()));
	btnNext.setPressedIcon(new NinePatchIcon(36, DEFAULT_BUTTON_HEIGHT, 
					NPIconFactory.getInstance().getSwitchable_next_pressed()));
	btnNext.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e)
		{
			((CardLayout)cardPane.getLayout()).next(cardPane);
			
			// 更新当前所显示的卡片的顺序号
			autoCalculateCurrrentCardIndex(+1);
			// 刷新按钮面板用于更新当前显示card对应按钮的小图标的绘制
			btnPane.repaint();
		}
	});
	return btnNext;
}
 
Example 4
Source File: SwitchablePane.java    From DroidUIBuilder with Apache License 2.0 6 votes vote down vote up
private JButton initPreviousButton()
{
	JButton btnPrevious = createImageButton("", false);
	btnPrevious.setIcon(new NinePatchIcon(36, DEFAULT_BUTTON_HEIGHT, 
					NPIconFactory.getInstance().getSwitchable_previous_normal()));
	btnPrevious.setPressedIcon(new NinePatchIcon(36, DEFAULT_BUTTON_HEIGHT, 
					NPIconFactory.getInstance().getSwitchable_previous_pressed()));
	btnPrevious.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e)
		{
			((CardLayout)cardPane.getLayout()).previous(cardPane);
			// 更新当前所显示的卡片的顺序号
			autoCalculateCurrrentCardIndex(-1);
			// 刷新按钮面板用于更新当前显示card对应按钮的小图标的绘制
			btnPane.repaint();
		}
	});
	return btnPrevious;
}
 
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: 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 7
Source File: CGraphToolBar.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a button to the toolbar.
 * 
 * @param action The action associated with the button.
 * @param rolloverIcon Path to the icon to be used when the mouse hovers over the button.
 * @param pressedIcon Path to the icon to be used when the button is pressed.
 * 
 * @return The created button.
 */
private JButton addButton(final AbstractAction action, final String rolloverIcon,
    final String pressedIcon) {
  final JButton button = add(CActionProxy.proxy(action));

  button.setFocusable(false);
  button.setBorder(new EmptyBorder(new Insets(1, 0, 1, 0)));
  button.setRolloverIcon(new ImageIcon(CMain.class.getResource(rolloverIcon)));
  button.setPressedIcon(new ImageIcon(CMain.class.getResource(pressedIcon)));

  return button;
}
 
Example 8
Source File: CTrackingResultsToolbar.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Small helper function for adding buttons to the toolbar.
 *
 * @param 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.
 */
// ESCA-JAVA0138:
private static JButton createAndAddIconToToolbar(final JToolBar toolBar,
    final AbstractAction action, final String defaultIconPath, final String rolloverIconPath,
    final String pressedIconPath) {
  final JButton button = toolBar.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 9
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 10
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 11
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 12
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 13
Source File: hover_press_utilclass.java    From java-QQ- with Apache License 2.0 5 votes vote down vote up
public static JButton getbtniconpresspress(String Iconpath1,String pressIconpath2,String pressIconpath3)
{ 

	JButton button=new JButton();
	button.setIcon(new ImageIcon(Iconpath1));
	button.setPressedIcon(new ImageIcon(pressIconpath2));
    button.setPressedIcon(new ImageIcon(pressIconpath3));
    button.setBorder(null);
    button.setFocusPainted(false);
    button.setContentAreaFilled(false);
  
    return button;	

}
 
Example 14
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 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: LuckInternalFrameTitlePane.java    From littleluck with Apache License 2.0 4 votes vote down vote up
/**
 * set Button attribute.
 *
 * @param btn Button object.
 * @param normalIcon  button icon properties.
 * @param rollverIcon button icon properties when mouse over.
 * @param pressedIcon button icon properties when mouse click.
 */
private void setBtnAtrr(JButton btn,
                        String normalIcon,
                        String rollverIcon,
                        String pressedIcon)
{
    btn.setBorder(null);

    btn.setFocusPainted(false);

    btn.setFocusable(false);

    btn.setBackground(null);

    btn.setContentAreaFilled(false);

    btn.setEnabled(false);

    btn.setIcon(UIManager.getIcon(normalIcon));

    btn.setRolloverIcon(UIManager.getIcon(rollverIcon));

    btn.setPressedIcon(UIManager.getIcon(pressedIcon));

    btn.setEnabled(true);
}
 
Example 17
Source File: LaconicTip.java    From DroidUIBuilder with Apache License 2.0 4 votes vote down vote up
protected void initGUI()
{
	// 左图标
	lbTipIcon = new JLabel(TEXT_INFO)
	{
		public void paintComponent(Graphics g) {
			// 绘制一个大圆角背景
			BEUtils.setAntiAliasing((Graphics2D)g, true);
			Color oldColor = g.getColor();
			g.setColor(this.getBackground());
			g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 20, 20);
			g.setColor(oldColor);
			BEUtils.setAntiAliasing((Graphics2D)g, false);
			
			super.paintComponent(g);
		}
	};
	Font lbTipIconFont = lbTipIcon.getFont().deriveFont(Font.BOLD);
	lbTipIcon.setFont(lbTipIconFont);
	lbTipIcon.setBorder(BorderFactory.createEmptyBorder(1, 6, 1, 6));
	lbTipIcon.setForeground(Color.white);
	lbTipIcon.setBackground(COLOR_INFO);// default bg color
	
	// 文本信息显示组件
	lbTipContent = new JLabel("");
	lbTipContent.setBorder(BorderFactory.createEmptyBorder(1, 4, 1, 4));
	
	// 关闭按钮
	btnClose = new JButton("");
	btnClose.setContentAreaFilled(false);
	btnClose.setFocusable(false);
	btnClose.setMargin(new Insets(0,0,0,0));
	btnClose.setIcon(IconFactory.getInstance().getLaconicTipCloseIcon_normal());
	btnClose.setRolloverIcon(IconFactory.getInstance().getLaconicTipCloseIcon_rover());
	btnClose.setPressedIcon(IconFactory.getInstance().getLaconicTipCloseIcon_rover());
	
	// 总体布局
	add(lbTipIcon,BorderLayout.WEST);
	add(lbTipContent,BorderLayout.CENTER);
	add(btnClose,BorderLayout.EAST);
	
	// 设置一个border,使总体视觉效果更佳
	this.setBorder(BorderFactory.createCompoundBorder(new LaconicBorder()
		, BorderFactory.createEmptyBorder(2, 4, 3, 4)));
}
 
Example 18
Source File: OptionMenu.java    From Math-Game with Apache License 2.0 4 votes vote down vote up
public OptionMenu(MathGame mathGame) {
	this.mathGame = mathGame;
	this.tm = mathGame.getTypeManager();
	
	this.setLayout(new GridBagLayout());
	// this.setLayout(new FlowLayout(FlowLayout.CENTER));
	gbc = new GridBagConstraints();
	 
	// Set size
	Dimension size = getPreferredSize();
	size.width = mathGame.getWidth();
	size.height = mathGame.getHeight();
	setPreferredSize(size);
	
	// Image initialization
	background = new ImageIcon(OptionMenu.class.getResource(BACKGROUND_FILE));
	buttonImage = new ImageIcon(OptionMenu.class.getResource(BUTTON_IMAGE_FILE));
	buttonRollOverImage = new ImageIcon(OptionMenu.class.getResource(BUTTON_ROLLOVER_IMAGE_FILE));
	buttonPressedImage = new ImageIcon(OptionMenu.class.getResource(BUTTON_PRESSED_IMAGE_FILE));
	
	// Button creation
	buttonMap = new HashMap<String, JToggleButton>();
	initModes();
	initTypes();
	initDiffs();
	
	// Default selections
	modes.get(0).setSelected(true);
	types.get(0).setSelected(true);
	diffs.get(0).setSelected(true);
	mathGame.setGameState(GameState.PRACTICE);
	
	play = new JButton("Play");
	play.setFont(eurostile24);
    play.setHorizontalTextPosition(JButton.CENTER);
    play.setVerticalTextPosition(JButton.CENTER);
    play.setBorderPainted(false);
    play.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
	play.addActionListener(this);
	
	try {
	    play.setIcon(buttonImage);
	    play.setRolloverIcon(buttonRollOverImage);
	    play.setPressedIcon(buttonPressedImage);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	
	gbc.insets = new Insets(5, 5, 5, 5);
	gbc.gridwidth = 3;
	gbc.gridheight = 3;
	gbc.gridx = 0;
	gbc.gridy = 0;
	add(modePanel, gbc);
	gbc.gridx = 4;
	gbc.gridy = 0;
	gbc.gridwidth = 3;
	gbc.gridheight = 3;
	add(typePanel, gbc);
	gbc.gridx = 8;
	gbc.gridy = 0;
	gbc.weighty = 1;
	gbc.gridwidth = 3;
	gbc.gridheight = 3;
	add(diffPanel, gbc);
	gbc.gridx = 4;
	gbc.gridy = 3;
	add(play, gbc);
}
 
Example 19
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;
}