Java Code Examples for javax.swing.JToggleButton#setSelectedIcon()
The following examples show how to use
javax.swing.JToggleButton#setSelectedIcon() .
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: TimerPanel.java From plugins with GNU General Public License v3.0 | 6 votes |
TimerPanel(ClockManager clockManager, Timer timer) { super(clockManager, timer, "timer", true); JToggleButton loopButton = new JToggleButton(ClockTabPanel.LOOP_ICON); loopButton.setRolloverIcon(ClockTabPanel.LOOP_ICON_HOVER); loopButton.setSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON); loopButton.setRolloverSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON_HOVER); SwingUtil.removeButtonDecorations(loopButton); loopButton.setPreferredSize(new Dimension(16, 14)); loopButton.setToolTipText("Loop timer"); loopButton.addActionListener(e -> timer.setLoop(!timer.isLoop())); loopButton.setSelected(timer.isLoop()); leftActions.add(loopButton); JButton deleteButton = new JButton(ClockTabPanel.DELETE_ICON); SwingUtil.removeButtonDecorations(deleteButton); deleteButton.setRolloverIcon(ClockTabPanel.DELETE_ICON_HOVER); deleteButton.setPreferredSize(new Dimension(16, 14)); deleteButton.setToolTipText("Delete timer"); deleteButton.addActionListener(e -> clockManager.removeTimer(timer)); rightActions.add(deleteButton); }
Example 2
Source File: TimerPanel.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
TimerPanel(ClockManager clockManager, Timer timer) { super(clockManager, timer, "timer", true); JToggleButton loopButton = new JToggleButton(ClockTabPanel.LOOP_ICON); loopButton.setRolloverIcon(ClockTabPanel.LOOP_ICON_HOVER); loopButton.setSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON); loopButton.setRolloverSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON_HOVER); SwingUtil.removeButtonDecorations(loopButton); loopButton.setPreferredSize(new Dimension(16, 14)); loopButton.setToolTipText("Loop timer"); loopButton.addActionListener(e -> timer.setLoop(!timer.isLoop())); loopButton.setSelected(timer.isLoop()); leftActions.add(loopButton); JButton deleteButton = new JButton(ClockTabPanel.DELETE_ICON); SwingUtil.removeButtonDecorations(deleteButton); deleteButton.setRolloverIcon(ClockTabPanel.DELETE_ICON_HOVER); deleteButton.setPreferredSize(new Dimension(16, 14)); deleteButton.setToolTipText("Delete timer"); deleteButton.addActionListener(e -> clockManager.removeTimer(timer)); rightActions.add(deleteButton); }
Example 3
Source File: BoardEditor.java From megamek with GNU General Public License v2.0 | 5 votes |
/** * Sets up JToggleButtons */ private JToggleButton addTerrainTButton(String iconName, String buttonName, ArrayList<JToggleButton> bList) { JToggleButton button = new JToggleButton(buttonName); button.addActionListener(this); // Get the normal icon File file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+".png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ Image imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) { button.setIcon(new ImageIcon(imageButton)); // When there is an icon, then the text can be removed button.setText(""); } // Get the hover icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_H.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setRolloverIcon(new ImageIcon(imageButton)); // Get the selected icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_S.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setSelectedIcon(new ImageIcon(imageButton)); button.setToolTipText(Messages.getString("BoardEditor."+iconName+"TT")); //$NON-NLS-1$ //$NON-NLS-2$ if (bList != null) bList.add(button); return button; }
Example 4
Source File: ExitsDialog.java From megamek with GNU General Public License v2.0 | 5 votes |
/** * Sets up JToggleButtons */ JToggleButton setupTButton(String iconName, String buttonName) { JToggleButton button = new JToggleButton(buttonName); // Get the normal icon File file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+".png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ Image imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) { button.setIcon(new ImageIcon(imageButton)); // When there is an icon, then the text can be removed button.setText(""); } // Get the hover icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_H.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setRolloverIcon(new ImageIcon(imageButton)); // Get the selected icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_S.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setSelectedIcon(new ImageIcon(imageButton)); button.setMargin(new Insets(0,0,0,0)); button.setBorder(BorderFactory.createEmptyBorder()); return button; }
Example 5
Source File: ShapeSelectionPanel.java From settlers-remake with MIT License | 5 votes |
/** * 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(); }