List of usage examples for javax.swing AbstractButton setVerticalTextPosition
@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.TOP", "SwingConstants.CENTER", "SwingConstants.BOTTOM" }, description = "The vertical position of the text relative to the icon.") public void setVerticalTextPosition(int textPosition)
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//from www.ja v a 2s. co m }); jb.setVerticalTextPosition(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
/** * //www.j a va 2 s.com * TODO * @param action * @return */ public static AbstractButton createToolbarItem(Action action) { final AbstractButton button; if (action == null) { throw new NullPointerException("Action cannot be null!"); } else if (action.getValue(Action.SELECTED_KEY) != null) { button = new JToggleButton(action); } else { button = new JButton(action); } button.setOpaque(false); // hide text if icon is available if (action != null && (action.getValue(Action.SMALL_ICON) != null || action.getValue(Action.LARGE_ICON_KEY) != null)) { button.setHideActionText(true); } button.setHorizontalTextPosition(JButton.CENTER); button.setVerticalTextPosition(JButton.BOTTOM); return button; }
From source file:com.mightypocket.ashot.Mediator.java
private JToolBar createToolBar() { ApplicationActionMap actionMap = getActionMap(); JToolBar bar = new JToolBar(); bar.setRollover(true);//from w ww . j a v a2s. co m toolBarMap.clear(); final boolean hideText = !p.getBoolean(PREF_GUI_SHOW_TEXT_IN_TOOLBAR, true); for (String actionName : TOOLBAR) { if (TOOLBAR_SEPARATOR.equals(actionName)) { bar.addSeparator(); } else { AbstractButton bt; if (actionName.startsWith(TOOLBAR_TOGGLE_BUTTON)) { actionName = StringUtils.substring(actionName, TOOLBAR_TOGGLE_BUTTON.length()); bt = new JToggleButton(actionMap.get(actionName)); } else { bt = new JButton(actionMap.get(actionName)); } bt.setFocusable(false); bt.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); bt.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); bt.setHideActionText(hideText); bar.add(bt); toolBarMap.put(actionName, bt); } } return bar; }
From source file:org.pentaho.ui.xul.swing.tags.SwingButton.java
@Override public void layout() { // check type to see if it's a toggleButton if (type == Type.CHECKBOX || type == Type.RADIO) { final AbstractButton oldButton = getButton(); final AbstractButton button = new JToggleButton(); button.setText(oldButton.getText()); button.setIcon(oldButton.getIcon()); button.setEnabled(oldButton.isEnabled()); button.setSelected(this.selected); setButton(button);//from ww w .j a v a2s . com if (this.getOnclick() != null) { this.setOnclick(this.getOnclick()); } } final AbstractButton button = getButton(); // adjust orientation of label and icon if (this.orientation == Orient.VERTICAL) { button.setHorizontalTextPosition(JButton.CENTER); if (this.dir == Direction.FORWARD) { button.setVerticalTextPosition(JButton.BOTTOM); } else { button.setVerticalTextPosition(JButton.TOP); } } else { button.setVerticalTextPosition(JButton.CENTER); if (this.dir == Direction.FORWARD) { button.setHorizontalTextPosition(JButton.RIGHT); } else { button.setHorizontalTextPosition(JButton.LEFT); } } // Square button patch. if no label and icon is square, set min/max to square up button final Icon icon = button.getIcon(); if ("".equals(button.getText()) && icon != null && icon.getIconHeight() == icon.getIconWidth()) { Dimension dim = button.getPreferredSize(); button.setMinimumSize(new Dimension(dim.height, dim.height)); button.setPreferredSize(new Dimension(dim.height, dim.height)); } button.setToolTipText(this.getTooltiptext()); super.layout(); }