List of utility methods to do JToolBar
boolean | isToolBarButton(JComponent c) Returns true if the specified widget is in a toolbar. return c.getParent() instanceof JToolBar; |
JButton | makeToolButton(URL iconURL, String cmd, String tooltip, String alt, ActionListener listener) make Tool Button JButton button = new JButton(); button.setActionCommand(cmd); button.setToolTipText(tooltip); button.addActionListener(listener); if (iconURL != null) { button.setIcon(new ImageIcon(iconURL, alt)); } else { button.setText(alt); ... |
void | resizeToolBarButtons(JComponent toolbar) Make the size of all toolbar buttons uniform. Component[] components = toolbar.getComponents(); int len = components.length; Dimension max_dim = new Dimension(0, 0); for (int i = 0; i < len; i++) { if (!(components[i] instanceof JButton)) continue; Dimension size = components[i].getPreferredSize(); if (size.width > max_dim.width) ... |
JToolBar | searchFakeToolBarRecursive(Container c) search Fake Tool Bar Recursive if (c instanceof JToolBar) { return (JToolBar) c; if (c.getComponents().length > 0) { Component[] comps = c.getComponents(); for (int i = 0; i < comps.length; i++) { JToolBar f = searchFakeToolBarRecursive((Container) comps[i]); if (f != null) { ... |
void | setToolIcons(AbstractButton b, Icon[] icons) Change the Icon s of an AbstractButton (JButton or JToggleButton ).
b.setIcon(icons[0]); b.setSelectedIcon(icons[1]); b.setPressedIcon(icons[3]); b.setDisabledIcon(icons[2]); |
void | setToolIcons(AbstractButton b, Icon[] icons) Change the Icon s of an AbstractButton (JButton or JToggleButton ).
b.setIcon(icons[0]); b.setSelectedIcon(icons[1]); b.setPressedIcon(icons[3]); b.setDisabledIcon(icons[2]); Insets defInsets = b.getInsets(); |
void | showTextOnToolbar(javax.swing.JToolBar t, boolean show) This method shows/hides the text of the buttons on 't' according to the value of 'show'. for (int i = t.getComponentCount() - 1; i >= 0; --i) { if (t.getComponent(i) instanceof javax.swing.AbstractButton) { javax.swing.AbstractButton button = (javax.swing.AbstractButton) t.getComponent(i); Object hide = button.getClientProperty("hideActionText"); javax.swing.Action a = button.getAction(); try { Method m = AbstractButton.class.getMethod("setHideActionText", Boolean.TYPE); m.invoke(button, !show); ... |
void | styleToolBarButton(final AbstractButton btn, final Font font, final boolean addPadding) style Tool Bar Button btn.setFont(font); btn.setBorder(null); btn.setContentAreaFilled(false); btn.setBorderPainted(false); btn.setFocusPainted(false); btn.setFocusable(false); if (addPadding) { final Dimension d = btn.getPreferredSize(); ... |