本文整理了Java中javax.swing.AbstractButton.getIcon()
方法的一些代码示例,展示了AbstractButton.getIcon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractButton.getIcon()
方法的具体详情如下:
包路径:javax.swing.AbstractButton
类名称:AbstractButton
方法名:getIcon
暂无
代码示例来源:origin: com.github.insubstantial/substance
/**
* Checks whether the specified button has associated icon.
*
* @param button
* Button.
* @return If the button has associated icon, <code>true</code> is returned,
* otherwise <code>false</code>.
*/
public static boolean hasIcon(AbstractButton button) {
return (button.getIcon() != null);
}
代码示例来源:origin: com.synaptix/SynaptixSwing
private String layout(AbstractButton b, FontMetrics fm, int width,
int height) {
Insets i = b.getInsets();
viewRect.x = i.left;
viewRect.y = i.top;
viewRect.width = width - (i.right + viewRect.x);
viewRect.height = height - (i.bottom + viewRect.y);
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
// layout the text and icon
return SwingUtilities.layoutCompoundLabel(b, fm, b.getText(), b
.getIcon(), b.getVerticalAlignment(), b
.getHorizontalAlignment(), b.getVerticalTextPosition(), b
.getHorizontalTextPosition(), viewRect, iconRect, textRect, b
.getText() == null ? 0 : b.getIconTextGap());
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Checks whether the specified button has associated icon.
*
* @param button
* Button.
* @return If the button has associated icon, <code>true</code> is returned,
* otherwise <code>false</code>.
*/
public static boolean hasIcon(AbstractButton button) {
return (button.getIcon() != null);
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
private static void updateSize( AbstractButton button, Dimension size) {
Icon icon = button.getIcon();
if ( icon != null) {
size.width = Math.max( size.width, icon.getIconWidth());
size.height = Math.max( size.height, icon.getIconHeight());
}
}
}
代码示例来源:origin: violetumleditor/violetumleditor
@Override
public void installUI(JComponent c)
{
AbstractButton b = (AbstractButton) c;
this.originalIcon = b.getIcon();
super.installUI(c);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect
public void addButton(AbstractButton button) {
Icon icon = button.getIcon();
Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 10);
button.setMinimumSize(size);
button.setPreferredSize(size);
button.setMaximumSize(size);
button.setMargin(new Insets(5, 4, 5, 4));
toolbar.add(button);
}
代码示例来源:origin: UISpec4J/UISpec4J
public void check() {
Icon actual = abstractButton.getIcon();
if (expected != null) {
AssertAdapter.assertNotNull("The component contains no icon.", actual);
}
AssertAdapter.assertSame("The icon ", expected, actual);
}
};
代码示例来源:origin: bcdev/beam
@Override
public void actionPerformed(ActionEvent e) {
if (playButton.getIcon() == playIcon) {
timer.start();
playButton.setIcon(pauseIcon);
playButton.setRolloverIcon(pauseIcon);
} else { // pause
timer.stop();
int newValue = timeSlider.getValue() / stepsPerTimespan * stepsPerTimespan;
timeSlider.setValue(newValue);
playButton.setIcon(playIcon);
playButton.setRolloverIcon(playIcon);
}
}
});
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
private static void align( AbstractButton button, Dimension size, Border border) {
Icon icon = button.getIcon();
if ( border != null) {
button.setBorder( border);
}
if ( icon != null && icon.getIconWidth() < size.width) {
Insets insets = button.getMargin();
button.setBorder( new EmptyBorder( insets.top, insets.left+ (size.width - icon.getIconWidth()), insets.bottom, insets.right));
} else if ( icon == null) {
button.setIcon( new DummyIcon( size));
}
}
代码示例来源:origin: com.github.arnabk/pgslookandfeel
public void propertyChange(PropertyChangeEvent evt) {
if (button.getClientProperty("allow.no.icon") == null && button.getIcon() == null) {
button.setIcon(PgsIconFactory.getEmptyIcon());
}
}
}
代码示例来源:origin: com.github.insubstantial/substance
/**
* Tracks possible usage of glowing icon.
*
*/
protected void trackGlowingIcon() {
Icon currIcon = this.button.getIcon();
if (currIcon instanceof GlowingIcon)
return;
if (currIcon == null)
return;
this.glowingIcon = new GlowingIcon(currIcon,
this.substanceVisualStateTracker.getStateTransitionTracker()
.getIconGlowTracker());
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf
/**
* Description of the Method
*
* @param g Description of Parameter
* @param c Description of Parameter
*/
public void paint(Graphics g, JComponent c) {
AbstractButton b = (AbstractButton) c;
iconRect.x = iconRect.y = 0;
iconRect.width = b.getWidth();
iconRect.height = b.getHeight();
// Paint the Icon
if (b.getIcon() != null) {
paintIcon(g, c, iconRect);
}
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Tracks possible usage of glowing icon.
*
* @param b
* Button.
*/
protected void trackGlowingIcon() {
Icon currIcon = this.button.getIcon();
if (currIcon instanceof GlowingIcon)
return;
if (currIcon == null)
return;
this.glowingIcon = new GlowingIcon(currIcon,
this.substanceVisualStateTracker.getStateTransitionTracker()
.getIconGlowTracker());
}
代码示例来源:origin: khuxtable/seaglass
/**
* Returns the Icon used in calculating the pref/min/max size.
*
* @param b DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected Icon getSizingIcon(AbstractButton b) {
// NOTE: this is slightly different than BasicButtonUI, where it
// would just use getIcon, but this should be ok.
Icon icon = (b.isEnabled() || b.getDisabledIcon() == null) ? b.getIcon() : b.getDisabledIcon();
if (icon == null) {
icon = getDefaultIcon(b);
}
return icon;
}
代码示例来源:origin: violetumleditor/violetumleditor
/**
* Prepares icons to simulate button behaviour
*/
private void prepareIcons(AbstractButton b)
{
baseIcon = b.getIcon();
Image baseImage = getImage(baseIcon);
if (this.scalingValue > 0) {
baseImage = getScaledImage(baseImage,(int) (baseIcon.getIconWidth() * this.scalingValue), (int) (baseIcon.getIconHeight() * this.scalingValue));
baseIcon = getIcon(baseImage);
}
Image brightenImage = changeBrightness(baseImage, true, 30);
Image darkenImage = changeBrightness(baseImage, false, 20);
brighterIcon = getIcon(brightenImage);
darkerIcon = getIcon(darkenImage);
}
代码示例来源:origin: freeplane/freeplane
static void scaleIcon(final AbstractButton actionComponent) {
final Icon icon = actionComponent.getIcon();
final IconFactory imageIconFactory = IconFactory.getInstance();
if (icon != null && imageIconFactory.canScaleIcon(icon)) {
final Font font = actionComponent.getFont();
final int fontHeight = actionComponent.getFontMetrics(font).getHeight();
final Quantity<LengthUnits> iconHeight = new Quantity<LengthUnits>(1.2 * fontHeight, LengthUnits.px);
actionComponent.setIcon(FreeplaneIconFactory.toImageIcon(imageIconFactory.getScaledIcon(icon, iconHeight)));
}
}
}
代码示例来源:origin: net.sf.tinylaf/tinylaf
private void addButtonIcons(boolean b) {
if(b && exampleButton.getIcon() == null) {
getButtonIcon();
exampleButton.setIcon(buttonIcon);
exampleDisabledButton.setIcon(buttonIcon);
exampleToggleButton.setIcon(buttonIcon);
// We change the toggle button's text, so
// it will not require more space than before
exampleToggleButton.setText("JToggleBtn");
}
else if(!b && exampleButton.getIcon() != null) {
exampleButton.setIcon((Icon)null);
exampleDisabledButton.setIcon((Icon)null);
exampleToggleButton.setIcon((Icon)null);
exampleToggleButton.setText("JToggleButton");
}
}
代码示例来源:origin: org.fudaa.framework.ebli/ebli-2d
public void calqueInteractionChanged() {
btReprise_.setEnabled(edition_.isGele());
if (palette_.getSelectedButton() != null) {
btReprise_.setIcon(palette_.getSelectedButton().getIcon());
}
atomicChanged();
}
代码示例来源:origin: freeplane/freeplane
protected void configureComponent(final Component comp) {
if (!(comp instanceof AbstractButton)) {
return;
}
final AbstractButton abstractButton = (AbstractButton) comp;
final String actionName = (String) abstractButton.getAction().getValue(Action.NAME);
abstractButton.setName(actionName);
if (null != abstractButton.getIcon()) {
final String text = abstractButton.getText();
final String toolTipText = abstractButton.getToolTipText();
if (text != null) {
if (toolTipText == null) {
abstractButton.setToolTipText(text);
}
abstractButton.setText(null);
}
}
configureToolbarButtonSize(abstractButton);
}
代码示例来源:origin: cpesch/RouteConverter
public static void registerAction(AbstractButton component, String name) {
String text = component.getText();
String toolTipText = component.getToolTipText();
Icon icon = component.getIcon();
component.setAction(Application.getInstance().getContext().getActionManager().get(name));
component.setText(text);
component.setToolTipText(toolTipText);
component.setIcon(icon);
}
内容来源于网络,如有侵权,请联系作者删除!