本文整理了Java中javax.swing.JToggleButton.setSelectedIcon()
方法的一些代码示例,展示了JToggleButton.setSelectedIcon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JToggleButton.setSelectedIcon()
方法的具体详情如下:
包路径:javax.swing.JToggleButton
类名称:JToggleButton
方法名:setSelectedIcon
暂无
代码示例来源:origin: org.netbeans.api/org-openide-awt
@Override
public void setSelectedIcon(Icon icon) {
Icon arrow = updateIcons( icon, ICON_SELECTED );
super.setSelectedIcon( hasPopupMenu() ? arrow : icon );
}
代码示例来源:origin: magefree/mage
tbRed.setFocusable(false);
tbRed.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbRed.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_red.png"))); // NOI18N
tbRed.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbRed.addActionListener(new java.awt.event.ActionListener() {
tbGreen.setFocusable(false);
tbGreen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbGreen.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_green.png"))); // NOI18N
tbGreen.setVerifyInputWhenFocusTarget(false);
tbGreen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbBlue.setFocusable(false);
tbBlue.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbBlue.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_blue.png"))); // NOI18N
tbBlue.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbBlue.addActionListener(new java.awt.event.ActionListener() {
tbBlack.setFocusable(false);
tbBlack.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbBlack.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_black.png"))); // NOI18N
tbBlack.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbBlack.addActionListener(new java.awt.event.ActionListener() {
tbWhite.setFocusable(false);
tbWhite.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbWhite.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_white.png"))); // NOI18N
tbWhite.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbWhite.addActionListener(new java.awt.event.ActionListener() {
代码示例来源:origin: stackoverflow.com
ImageIcon selectedIcon = new ImageIcon("Image.png");
Image image = selectedIcon.getImage();
PlaceHolderIcon placeHolderIcon = new PlaceHolderIcon(image.getWidth(this), image.getHeight(this));
JToggleButton layoutButton = new JToggleButton();
layoutButton.setIcon(placeHolderIcon);
layoutButton.setFocusPainted(false);
layoutButton.setSelectedIcon(selectedIcon);
代码示例来源:origin: stackoverflow.com
JToggleButton btn = new JToggleButton();
btn.setModel(new StickyModel());
btn.setIcon(new ImageIcon(ImageIO.read(getClass().getResource("/Blank.png"))));
btn.setSelectedIcon(new ImageIcon(ImageIO.read(getClass().getResource("/Bomb.png"))));
代码示例来源:origin: org.gephi/ui-components
@Override
public void setSelectedIcon(Icon icon) {
Icon arrow = updateIcons(icon, ICON_SELECTED);
super.setSelectedIcon(hasPopupMenu() ? arrow : icon);
}
代码示例来源:origin: RPTools/maptool
private JToggleButton createButton(final String icon, final String offIcon, final OptionPanel panel, String tooltip) {
final JToggleButton button = new JToggleButton();
button.setToolTipText(tooltip);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (button.isSelected()) {
panel.activate();
((CardLayout) optionPanel.getLayout()).show(optionPanel, icon);
}
}
});
try {
button.setIcon(new ImageIcon(ImageUtil.getImage(offIcon)));
button.setSelectedIcon(new ImageIcon(ImageUtil.getImage(icon)));
} catch (IOException ioe) {
ioe.printStackTrace();
}
optionPanel.add(panel, icon);
buttonGroup.add(button);
return button;
}
代码示例来源:origin: net.sf.sfac/sfac-core
private JToggleButton createDefaultButton() {
if (DEFAULT_ICONS[0] == null) {
// load default icons
for (int i = 0; i
DEFAULT_ICONS[i] = new ImageIcon(getClass().getResource(iconName));
}
}
JToggleButton button = new JToggleButton();
button.setBorderPainted(false);
button.setContentAreaFilled(false);
button.setMargin(new Insets(0, 0, 0, 0));
button.setOpaque(false);
button.setIcon(DEFAULT_ICONS[ICON_NORMAL]);
button.setSelectedIcon(DEFAULT_ICONS[ICON_SELECTED]);
// button.setRolloverIcon(DEFAULT_ICONS[ICON_ROLL_OVER]) ;
// button.setPressedIcon(DEFAULT_ICONS[ICON_PRESSED]) ;
// button.setDisabledIcon(DEFAULT_ICONS[ICON_DISABLED]) ;
// button.setDisabledSelectedIcon(DEFAULT_ICONS[ICON_DISABLED_SELECTED]) ;
// button.setRolloverSelectedIcon(DEFAULT_ICONS[ICON_ROLL_OVER_SELECTED]) ;
return button;
}
代码示例来源:origin: RPTools/maptool
public JToggleButton getScrollLockButton() {
if (scrollLockButton == null) {
scrollLockButton = new JToggleButton();
scrollLockButton.setIcon(new ImageIcon(AppStyle.chatScrollImage));
scrollLockButton.setSelectedIcon(new ImageIcon(AppStyle.chatScrollLockImage));
scrollLockButton.setToolTipText("Scroll lock");
scrollLockButton.setUI(new BasicToggleButtonUI());
scrollLockButton.setBorderPainted(false);
scrollLockButton.setFocusPainted(false);
scrollLockButton.setPreferredSize(new Dimension(16, 16));
}
return scrollLockButton;
}
代码示例来源:origin: com.fifesoft.rtext/fife.common
if (isArrow) {
JToggleButton tb = new BreadcrumbBarToggleButton(horizArrowIcon);
tb.setSelectedIcon(downArrowIcon);
tb.addChangeListener(new ChangeListener() {
代码示例来源:origin: org.icepdf.os/icepdf-viewer
protected JToggleButton makeToolbarToggleButton(
String title, String toolTip, String imageName,
int imageWidth, int imageHeight, java.awt.Font font) {
JToggleButton tmp = new JToggleButton(showButtonText ? title : "");
tmp.setFont(font);
tmp.setToolTipText(toolTip);
tmp.setRolloverEnabled(false);
tmp.setPreferredSize(new Dimension(imageWidth, imageHeight));
try {
tmp.setIcon(new ImageIcon(Images.get(imageName + "_d.png")));
tmp.setPressedIcon(new ImageIcon(Images.get(imageName + "_d.png")));
tmp.setSelectedIcon(new ImageIcon(Images.get(imageName + "_n.png")));
tmp.setDisabledIcon(new ImageIcon(Images.get(imageName + "_n.png")));
} catch (NullPointerException e) {
logger.warning("Failed to load toobar toggle button images: " + imageName + ".png");
}
tmp.setBorderPainted(false);
tmp.setBorder(BorderFactory.createEmptyBorder());
tmp.setContentAreaFilled(false);
tmp.setFocusPainted(false);
return tmp;
}
代码示例来源:origin: atarw/material-ui-swing
@Override
public void installUI (JComponent c) {
super.installUI (c);
JToggleButton toggleButton = (JToggleButton) c;
toggleButton.setBorder (UIManager.getBorder ("ToggleButton.border"));
toggleButton.setFont (UIManager.getFont ("ToggleButton.font"));
toggleButton.setBackground (UIManager.getColor ("ToggleButton.background"));
toggleButton.setForeground (UIManager.getColor ("ToggleButton.foreground"));
if (toggleButton.getIcon () == null && toggleButton.getSelectedIcon () == null) {
toggleButton.setIcon (UIManager.getIcon ("ToggleButton.icon"));
toggleButton.setSelectedIcon (UIManager.getIcon ("ToggleButton.selectedIcon"));
}
}
代码示例来源:origin: net.java.abeille/abeille
public javax.swing.AbstractButton i18n_createToolBarToggleButton(String cmd, String unselImage, String selImage, String toolTip) {
JToggleButton button = new JToggleButton(FormDesignerUtils.loadImage(unselImage)) {
public boolean isFocusTraversable() {
return false;
}
};
button.setSelectedIcon(FormDesignerUtils.loadImage(selImage));
button.setName(cmd);
button.setActionCommand(cmd);
button.setMargin(new java.awt.Insets(1, 1, 1, 1));
if (toolTip != null)
button.setToolTipText(I18N.getLocalizedMessage(toolTip));
return button;
}
代码示例来源:origin: RPTools/maptool
chatNotifyButton = new JToggleButton();
chatNotifyButton.setIcon(new ImageIcon(AppStyle.showTypingNotification));
chatNotifyButton.setSelectedIcon(new ImageIcon(AppStyle.hideTypingNotification));
chatNotifyButton.setToolTipText("Show/hide typing notification");
chatNotifyButton.setUI(new BasicToggleButtonUI());
代码示例来源:origin: jsettlers/settlers-remake
/**
* Constructor
*/
public ShapeSelectionPanel() {
super(BoxLayout.Y_AXIS);
JToolBar tb = new JToolBar();
tb.setFloatable(false);
ButtonGroup group = new ButtonGroup();
for (EShapeType type : EShapeType.values()) {
JToggleButton bt = new JToggleButton(type.getIcon());
bt.setDisabledIcon(type.getIcon().createDisabledIcon());
bt.setSelectedIcon(type.getIcon().createSelectedIcon());
bt.setToolTipText(type.getShape().getName());
bt.addActionListener(new ShapeActionListener(type.getShape()));
bt.setEnabled(false);
tb.add(bt);
group.add(bt);
buttons.put(type, bt);
}
add(tb);
for (EShapeProperty p : EShapeProperty.values()) {
StrokenSlider slider = new StrokenSlider(p);
properties.put(p, slider);
add(slider);
}
updateStrokeProperties();
}
代码示例来源:origin: vasl-developers/vasl
l_btn.setSelectedIcon(new ImageIcon(Op.load(strImageOn).getImage(null)));
代码示例来源:origin: org.activecomponents.jadex/jadex-editor-bpmn
tool.setRolloverIcon(highicon);
tool.setPressedIcon(onicon);
tool.setSelectedIcon(onicon);
代码示例来源:origin: net.java.dev.designgridlayout/designgridlayout
ClassLoader loader = Thread.currentThread().getContextClassLoader();
groupBox.setIcon(new ImageIcon(loader.getResource("expand-group.png")));
groupBox.setSelectedIcon(new ImageIcon(loader.getResource("collapse-group.png")));
代码示例来源:origin: net.java.dev.designgridlayout/designgridlayout
private void addGroup(DesignGridLayout layout, String name, RowGroup group)
{
JLabel groupName = new JLabel(name);
groupName.setForeground(Color.BLUE);
JToggleButton groupBox = new JToggleButton();
groupBox.setName(name);
// The following line is mandatory to get the right baseline for the icon!
groupBox.setText(" ");
// Since we already add pixels due to the text, we want to reduce any extra space
groupBox.setIconTextGap(0);
// Setting an empty border is necessary to reduce the size to just the icon
// The down side is that it also removes the focus border
// Could use 1 pixel instead but:
// - focus border would not render right on HiDPI monitor anyway
// - focus border clearly shows there is a space after the icon (the " " text)
groupBox.setBorder(BorderFactory.createEmptyBorder());
groupBox.setContentAreaFilled(false);
groupBox.setFocusPainted(false);
groupBox.setRolloverEnabled(true);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
groupBox.setIcon(new ImageIcon(loader.getResource("expand-group.png")));
groupBox.setSelectedIcon(new ImageIcon(loader.getResource("collapse-group.png")));
groupBox.setSelected(true);
groupBox.addItemListener(new ShowHideAction(group));
layout.emptyRow();
JComponent groupCompOnent=
Componentizer.create().fixedPref(groupName, groupBox).component();
layout.row().left().add(groupComponent, new JSeparator()).fill();
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu
/**
* Sets the selected icons for a toggle button.
*/
public static void setSelectedIcons(JToggleButton _button, ImageIcon _icon, boolean _effect) {
ImageIcon icon = _icon;
if (_effect) icon = addDefaultEffect(_button, icon);
if (BuPreferences.BU.getBooleanProperty("icons.grey", false)) {
_button.setSelectedIcon(filter(_button, filter(_button, icon, BuFilters.GREY), BuFilters.getSelected()));
_button.setRolloverSelectedIcon(filter(_button, icon, BuFilters.getSelected()));
_button.setDisabledSelectedIcon(filter(_button, filter(_button, icon, BuFilters.getSelected()), BuFilters
.getDisabled()));
} else {
_button.setSelectedIcon(filter(_button, icon, BuFilters.getSelected()));
_button.setRolloverSelectedIcon(filter(_button, icon, BuFilters.getRollover()));
_button.setDisabledSelectedIcon(filter(_button, icon, BuFilters.getDisabled()));
}
}
代码示例来源:origin: org.zaproxy/zap
public static void scaleIcon(JToggleButton button) {
if (isScaleImages() && button != null) {
if (button.getIcon() != null && button.getIcon() instanceof ImageIcon) {
button.setIcon(getScaledIcon((ImageIcon)button.getIcon()));
}
if (button.getSelectedIcon() != null && button.getSelectedIcon() instanceof ImageIcon) {
button.setSelectedIcon(getScaledIcon((ImageIcon)button.getSelectedIcon()));
}
if (button.getRolloverIcon() != null && button.getRolloverIcon() instanceof ImageIcon) {
button.setRolloverIcon(getScaledIcon((ImageIcon)button.getRolloverIcon()));
}
if (button.getRolloverSelectedIcon() != null && button.getRolloverSelectedIcon() instanceof ImageIcon) {
button.setRolloverSelectedIcon(getScaledIcon((ImageIcon)button.getRolloverSelectedIcon()));
}
if (button.getDisabledIcon() != null && button.getDisabledIcon() instanceof ImageIcon) {
button.setDisabledIcon(getScaledIcon((ImageIcon)button.getDisabledIcon()));
}
if (button.getDisabledSelectedIcon() != null && button.getDisabledSelectedIcon() instanceof ImageIcon) {
button.setDisabledSelectedIcon(getScaledIcon((ImageIcon)button.getDisabledSelectedIcon()));
}
if (button.getPressedIcon() != null && button.getPressedIcon() instanceof ImageIcon) {
button.setPressedIcon(getScaledIcon((ImageIcon)button.getPressedIcon()));
}
}
}