List of utility methods to do JButton
void | setImageIcon(JButton b, String fileName, String tip) set Image Icon ImageIcon i = null; URL u = ClassLoader.getSystemResource("img/" + fileName); i = new ImageIcon(u); b.setIcon(i); b.setPreferredSize(new Dimension(61, 81)); b.setToolTipText(tip); b.setVerticalTextPosition(JButton.BOTTOM); b.setHorizontalTextPosition(JButton.CENTER); ... |
void | setMacBevelButton(JButton button) Set property to render button in bevel style on the Mac. button.putClientProperty("Quaqua.Button.style", "bevel"); |
void | setTransparent(JButton btn) set Transparent btn.setOpaque(false); btn.setContentAreaFilled(false); btn.setBorderPainted(false); btn.setBorder(null); |
void | setupAutoRepeat(final JButton button, final int intervalMs) Sets up repetitive action invocation on the given button until mouse is released. class MouseListenerImpl extends MouseAdapter implements ActionListener { private Timer myTimer; private MouseEvent myEvent; @Override public void mousePressed(MouseEvent e) { if (myTimer == null) { myEvent = e; myTimer = new Timer(intervalMs, this); ... |
void | setWFActionMap(Vector set WF Action Map for (int i = 0; i < actionButtons.size(); i++) { JButton button = actionButtons.elementAt(i); String[] cmnd = button.getActionCommand().split("="); String stepAction = cmnd[1]; wfActionMap.put(stepAction, action); |
void | showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText) Muestra u oculta un tooltip relacionado con un botón. tipText.setText(boton.getToolTipText()); tip.setBackground((Color) UIManager.get("ToolTip.background")); tipText.setBackground((Color) UIManager.get("ToolTip.background")); tipText.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(0, 3, 0, 3))); tipText.setFont((Font) UIManager.get("ToolTip.font")); tipText.setOpaque(true); tip.add(tipText); ... |
void | showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText) Muestra u oculta un tooltip relacionado con un botón. tipText.setText(boton.getToolTipText()); tip.setBackground((Color) UIManager.get("ToolTip.background")); tipText.setBackground((Color) UIManager.get("ToolTip.background")); tipText.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(0, 3, 0, 3))); tipText.setFont((Font) UIManager.get("ToolTip.font")); tipText.setOpaque(true); tip.add(tipText); ... |
JSeparator | toolBarSeparator(JButton button, Icon icon) Create a separator to add to a toolbar. JSeparator separator = new JSeparator(SwingConstants.VERTICAL); if (button == null) return separator; Insets i = button.getInsets(); int h = 0; if (icon != null) h = icon.getIconHeight(); Dimension d = new Dimension(SEPARATOR_WIDTH, i.top + h + i.bottom); ... |
void | wireComponentWithButton(JComponent component, final JButton button) wire Component With Button component.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) { if (button.isEnabled()) { button.doClick(); }); component.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { if (e.getKeyChar() == '\n') { if (button.isEnabled()) { button.doClick(); @Override public void keyReleased(KeyEvent arg0) { @Override public void keyPressed(KeyEvent arg0) { }); |