Java Code Examples for javax.swing.JButton#setAlignmentY()

The following examples show how to use javax.swing.JButton#setAlignmentY() . 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: Utility.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a button suitable for linking to another panel
 * (e.g. ColopediaPanel).
 *
 * @param text a {@code String} value
 * @param icon an {@code Icon} value
 * @param action a {@code String} value
 * @return a {@code JButton} value
 */
public static JButton getLinkButton(String text, Icon icon, String action) {
    JButton button = new JButton(text, icon);
    button.setMargin(EMPTY_MARGIN);
    button.setOpaque(false);
    button.setForeground(LINK_COLOR);
    button.setAlignmentY(0.8f);
    button.setBorder(blankBorder(0, 0, 0, 0));
    button.setActionCommand(action);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    return button;
}
 
Example 2
Source File: ObjectivePanel.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
protected void initLayout() {
  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  objectiveModel = new ObjectiveTableModel();
  final JTable table = new JTable(objectiveModel);
  table.getTableHeader().setReorderingAllowed(false);
  final TableColumn column0 = table.getColumnModel().getColumn(0);
  column0.setPreferredWidth(34);
  column0.setWidth(34);
  column0.setMaxWidth(34);
  column0.setCellRenderer(new ColorTableCellRenderer());
  final TableColumn column1 = table.getColumnModel().getColumn(1);
  column1.setCellEditor(new EditorPaneCellEditor());
  column1.setCellRenderer(new EditorPaneTableCellRenderer());
  final JScrollPane scroll = new JScrollPane(table);
  final JButton refresh = new JButton("Refresh Objectives");
  refresh.setAlignmentY(Component.CENTER_ALIGNMENT);
  refresh.addActionListener(
      SwingAction.of(
          "Refresh Objectives",
          e -> {
            objectiveModel.loadData();
            SwingUtilities.invokeLater(table::repaint);
          }));
  add(Box.createVerticalStrut(6));
  add(refresh);
  add(Box.createVerticalStrut(6));
  add(scroll);
}
 
Example 3
Source File: FormUtils.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Get Default OK Button from LookAndFeel (like JOptionPane)
 */
public static JButton newOKButton() {
	String text = StaticMessageSource.getMessage("Accept");
	int mnemonic = getMnemonic("OptionPane.okButtonMnemonic");
	JButton b = new JButton(text, OK_ICON);
	b.setMnemonic(mnemonic);
	b.setAlignmentX(Container.CENTER_ALIGNMENT);
	b.setAlignmentY(Container.CENTER_ALIGNMENT);
	return b;
}
 
Example 4
Source File: FormUtils.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Get Default Cancel Button from LookAndFeel (like JOptionPane)
 */
public static JButton newCancelButton() {
	String text = StaticMessageSource.getMessage("Cancel");
	int mnemonic = getMnemonic("OptionPane.cancelButtonMnemonic");
	JButton b = new JButton(text, CANCEL_ICON);
	b.setMnemonic(mnemonic);
	b.setAlignmentX(Container.CENTER_ALIGNMENT);
	b.setAlignmentY(Container.CENTER_ALIGNMENT);
	
	return b;
}