Java Code Examples for javax.swing.JToggleButton#setMaximumSize()
The following examples show how to use
javax.swing.JToggleButton#setMaximumSize() .
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: FiltersManagerImpl.java From netbeans with Apache License 2.0 | 6 votes |
private JToggleButton createToggle(Map<String, Boolean> fStates, int index) { boolean isSelected = filtersDesc.isSelected(index); boolean enabled = filtersDesc.isEnabled(index); Icon icon = filtersDesc.getIcon(index); // ensure small size, just for the icon JToggleButton result = new JToggleButton(icon, enabled && isSelected); Dimension size = new Dimension(21, 21); // 3 less than other buttons result.setMaximumSize(size); result.setMinimumSize(size); result.setPreferredSize(size); if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N result.setBorderPainted(true); } else { result.setBorderPainted(false); } // result.setMargin(new Insets(2, 3, 2, 3)); result.setToolTipText(filtersDesc.getTooltip(index)); result.setEnabled(enabled); fStates.put(filtersDesc.getKey(index), Boolean.valueOf(isSelected)); return result; }
Example 2
Source File: JTSTestBuilderToolBar.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
private JToggleButton createToggleButton(String toolTipText, ImageIcon icon, java.awt.event.ActionListener actionListener) { JToggleButton btn = new JToggleButton(); btn.setMargin(new Insets(0, 0, 0, 0)); btn.setPreferredSize(new Dimension(30, 30)); btn.setIcon(icon); btn.setMinimumSize(new Dimension(30, 30)); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setSelected(false); btn.setToolTipText(toolTipText); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setFont(new java.awt.Font("SansSerif", 0, 10)); btn.setMaximumSize(new Dimension(30, 30)); btn.addActionListener(actionListener); return btn; }
Example 3
Source File: FiltersManagerImpl.java From netbeans with Apache License 2.0 | 5 votes |
private void addAdditionalButtons(JToggleButton[] sortButtons) { Dimension space = new Dimension(3, 0); for (JToggleButton button : sortButtons) { Dimension size = new Dimension(21, 21); // 3 less than other buttons button.setMaximumSize(size); button.setMinimumSize(size); button.setPreferredSize(size); // button.setMargin(new Insets(2, 3, 2, 3)); toolbar.addSeparator(space); toolbar.add(button); } }
Example 4
Source File: MainMenuJPanel.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
/** * Called when a waypoint is added. This implementation adds a waypoint button. * @param graphic the waypoint graphic, whose ID may or may not be populated. * @param graphicUid the waypoint graphic's ID. * @see RouteListener#waypointAdded(com.esri.core.map.Graphic, int) */ public void waypointAdded(Graphic graphic, int graphicUid) { final JToggleButton button = new JToggleButton((String) graphic.getAttributeValue("name")); waypointButtonToGraphicId.put(button, graphicUid); graphicIdToWaypointButton.put(graphicUid, button); Font font = new Font("Arial", Font.PLAIN, 18); button.setFont(font); button.setFocusable(false); button.setSelected(false); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (button == selectedWaypointButton) { //Unselect buttonGroup_waypoints.remove(button); button.setSelected(false); buttonGroup_waypoints.add(button); selectedWaypointButton = null; routeController.setSelectedWaypoint(null); } else { selectedWaypointButton = button; routeController.setSelectedWaypoint(waypointButtonToGraphicId.get(button)); } } }); button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60)); button.setMinimumSize(new Dimension(0, 60)); jPanel_waypointsList.add(button); buttonGroup_waypoints.add(button); }