Java Code Examples for javax.swing.JTextField#setActionCommand()

The following examples show how to use javax.swing.JTextField#setActionCommand() . 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: ChatPanel.java    From freecol with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public ChatPanel(FreeColClient freeColClient) {
    super(freeColClient, null, new BorderLayout(10, 10));

    JLabel label = Utility.localizedLabel("chatPanel.message");

    field = new JTextField("", 40);
    field.setActionCommand(String.valueOf(CHAT));
    field.addActionListener(this);

    add(label);
    add(field);

    //setFocusable(false);
    label.setFocusable(false);
    field.setFocusable(true);

    setSize(getPreferredSize());
}
 
Example 2
Source File: TreeSearch.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private void createToolBar() {
    searchBar = new JToolBar();
    searchBar.setFloatable(false);
    searchBar.setLayout(new BoxLayout(searchBar, BoxLayout.X_AXIS));
    searchBar.setBorder(BorderFactory.createEtchedBorder());

    JLabel searchLabel = new JLabel(Utils.getIconByResourceName("/ui/resources/search"));

    searchField = new JTextField();
    searchField.setActionCommand("SearchField");
    searchField.addActionListener(this);

    searchBar.add(searchLabel);
    searchBar.add(new javax.swing.Box.Filler(new java.awt.Dimension(5, 0),
            new java.awt.Dimension(5, 0),
            new java.awt.Dimension(5, 32767)));
    searchBar.add(searchField);

}
 
Example 3
Source File: CameraInspector.java    From osp with GNU General Public License v3.0 6 votes vote down vote up
static private JTextField createRow(JPanel labelParent, JPanel fieldParent, String labelText, ActionListener listener) {
  if(labelText==null) { // create an empty row
    labelParent.add(new JLabel());
    fieldParent.add(new JLabel());
    return null;
  }
  //    if(labelText.length()<14) {}
  JLabel label = new JLabel(ToolsRes.getString("CameraInspector."+labelText)); //$NON-NLS-1$
  label.setHorizontalAlignment(SwingConstants.CENTER);
  label.setBorder(new EmptyBorder(0, 3, 0, 3));
  JTextField field = new JTextField(4);
  field.setActionCommand(labelText.toLowerCase());
  field.addActionListener(listener);
  labelParent.add(label);
  fieldParent.add(field);
  return field;
}
 
Example 4
Source File: AccountSeparatorTableCell.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public AccountSeparatorTableCell(final AccountManagerDialog accountManagerDialog, final ActionListener actionListener, final JTable jTable, final SeparatorList<OwnerType> separatorList) {
	super(jTable, separatorList);
	this.accountManagerDialog = accountManagerDialog;

	defaultColor = jPanel.getBackground();

	ListenerClass listener = new ListenerClass();

	jSeparatorLabel = new JLabel();
	jSeparatorLabel.setBackground(jTable.getBackground());
	jSeparatorLabel.setOpaque(true);
	jSeparatorLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, jTable.getGridColor()));
	jAccountType = new JLabel();

	jEdit = new JButton(DialoguesAccount.get().edit());
	jEdit.setOpaque(false);
	jEdit.setActionCommand(AccountCellAction.EDIT.name());
	jEdit.addActionListener(actionListener);

	jMigrate = new JButton(DialoguesAccount.get().migrate());
	jMigrate.setOpaque(false);
	jMigrate.setActionCommand(AccountCellAction.MIGRATE.name());
	jMigrate.addActionListener(actionListener);

	jDelete = new JButton(DialoguesAccount.get().delete());
	jDelete.setOpaque(false);
	jDelete.setActionCommand(AccountCellAction.DELETE.name());
	jDelete.addActionListener(actionListener);

	jAccountName = new JTextField();
	jAccountName.addFocusListener(listener);
	jAccountName.setBorder(null);
	jAccountName.setOpaque(false);
	jAccountName.setActionCommand(AccountCellAction.ACCOUNT_NAME.name());
	jAccountName.addActionListener(listener);

	jInvalidLabel = new JLabel(DialoguesAccount.get().accountInvalid());

	jExpiredLabel = new JLabel(DialoguesAccount.get().accountExpired());

	jMigratedLabel = new JLabel(DialoguesAccount.get().accountMigrated());

	jCanMigrateLabel = new JLabel(DialoguesAccount.get().accountCanMigrate());

	jSpaceLabel = new JLabel();

	layout.setHorizontalGroup(
		layout.createParallelGroup()
			.addComponent(jSeparatorLabel, 0, 0, Integer.MAX_VALUE)
			.addGroup(layout.createSequentialGroup()
				.addComponent(jExpand)
				.addGap(1)
				.addComponent(jEdit, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addComponent(jMigrate, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addComponent(jDelete, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addGap(5)
				.addComponent(jAccountType)
				.addGap(5)
				.addComponent(jAccountName, 20, 20, Integer.MAX_VALUE)
				.addGap(10)
				.addComponent(jExpiredLabel)
				.addComponent(jInvalidLabel)
				.addComponent(jMigratedLabel)
				.addComponent(jCanMigrateLabel)
				.addComponent(jSpaceLabel, 20, 20, Integer.MAX_VALUE)
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jSeparatorLabel, jTable.getRowHeight(), jTable.getRowHeight(), jTable.getRowHeight())
			.addGap(1)
			.addGroup(layout.createParallelGroup()
				.addComponent(jExpand, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jAccountType, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jEdit, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jMigrate, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jDelete, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jAccountName, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jInvalidLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jExpiredLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jMigratedLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jCanMigrateLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jSpaceLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
			.addGap(2)
	);
}