List of usage examples for javax.swing AbstractButton setIcon
@BeanProperty(visualUpdate = true, description = "The button's default icon") public void setIcon(Icon defaultIcon)
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java
protected void prepareButton(AbstractButton button, String actionKey, String iconResource, String toolTipText) { button.setActionCommand(actionKey);// w w w .ja va 2s. com button.setToolTipText(toolTipText); button.addActionListener(this); try { button.setIcon(ImageFactory.getIcon(iconResource)); } catch (ImageFactoryException i) { MsgBox.error(i.getMessage()); } }
From source file:org.pentaho.ui.xul.swing.tags.SwingButton.java
@Override public void layout() { // check type to see if it's a toggleButton if (type == Type.CHECKBOX || type == Type.RADIO) { final AbstractButton oldButton = getButton(); final AbstractButton button = new JToggleButton(); button.setText(oldButton.getText()); button.setIcon(oldButton.getIcon()); button.setEnabled(oldButton.isEnabled()); button.setSelected(this.selected); setButton(button);/* ww w.ja va2 s . co m*/ if (this.getOnclick() != null) { this.setOnclick(this.getOnclick()); } } final AbstractButton button = getButton(); // adjust orientation of label and icon if (this.orientation == Orient.VERTICAL) { button.setHorizontalTextPosition(JButton.CENTER); if (this.dir == Direction.FORWARD) { button.setVerticalTextPosition(JButton.BOTTOM); } else { button.setVerticalTextPosition(JButton.TOP); } } else { button.setVerticalTextPosition(JButton.CENTER); if (this.dir == Direction.FORWARD) { button.setHorizontalTextPosition(JButton.RIGHT); } else { button.setHorizontalTextPosition(JButton.LEFT); } } // Square button patch. if no label and icon is square, set min/max to square up button final Icon icon = button.getIcon(); if ("".equals(button.getText()) && icon != null && icon.getIconHeight() == icon.getIconWidth()) { Dimension dim = button.getPreferredSize(); button.setMinimumSize(new Dimension(dim.height, dim.height)); button.setPreferredSize(new Dimension(dim.height, dim.height)); } button.setToolTipText(this.getTooltiptext()); super.layout(); }
From source file:se.trixon.almond.GraphicsHelper.java
public static void setImageIcon(AbstractButton abstractButton, URL url) { if (url != null) { abstractButton.setIcon(new ImageIcon(url)); } else {//w w w.jav a 2 s .c o m abstractButton.setIcon(null); } }