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

The following examples show how to use javax.swing.JTextField#addFocusListener() . 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: CellEditorAdapter.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public CellEditorAdapter(PropertyEditor editor) {
  this.editor = editor;
  Component component = editor.getCustomEditor();
  if (component instanceof JTextField) {
    JTextField field = (JTextField)component;
    field.addFocusListener(new SelectOnFocus());
    field.addActionListener(new CommitEditing());
    field.registerKeyboardAction(
      new CancelEditing(),
      KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
      JComponent.WHEN_FOCUSED);
  }

  // when the editor notifies a change, commit the changes
  editor.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {       
      stopCellEditing();
    }
  });
}
 
Example 2
Source File: SingleEntryDialog.java    From nanoleaf-desktop with MIT License 6 votes vote down vote up
public SingleEntryDialog(Component parent, String entryLabel,
		String buttonLabel, ActionListener buttonListener)
{
	super();
	
	entry = new JTextField(entryLabel);
	entry.setForeground(Color.WHITE);
	entry.setBackground(Color.DARK_GRAY);
	entry.setBorder(new LineBorder(Color.GRAY));
	entry.setCaretColor(Color.WHITE);
	entry.setFont(new Font("Tahoma", Font.PLAIN, 22));
	entry.addFocusListener(new TextFieldFocusListener(entry));
	contentPanel.add(entry, "cell 0 1, grow, gapx 2 2");
	
	JButton btnConfirm = new ModernButton(buttonLabel);
	btnConfirm.setFont(new Font("Tahoma", Font.PLAIN, 18));
	btnConfirm.addActionListener(buttonListener);
	contentPanel.add(btnConfirm, "cell 0 3, alignx center");
	
	JLabel spacer = new JLabel(" ");
	contentPanel.add(spacer, "cell 0 4");
	
	finalize(parent);
	
	btnConfirm.requestFocus();
}
 
Example 3
Source File: SpecialkeyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form SpecialkeyPanel */
public SpecialkeyPanel(final Popupable parent, JTextField target) {
    this.parent = parent;
    this.target = target;
    initComponents();

    target.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            parent.hidePopup();
        }
    });

    downButton.addActionListener(this);
    enterButton.addActionListener(this);
    escButton.addActionListener(this);
    leftButton.addActionListener(this);
    rightButton.addActionListener(this);
    tabButton.addActionListener(this);
    upButton.addActionListener(this);
    wheelUpButton.addActionListener(this);
    wheelDownButton.addActionListener(this);
}
 
Example 4
Source File: Search.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Creates the search panel.
 *
 * @param target The search target.
 */
public Search(SearchTarget target) {
    mTarget = target;

    mFilterField = new JTextField(10);
    mFilterField.getDocument().addDocumentListener(this);
    mFilterField.addKeyListener(this);
    mFilterField.addFocusListener(this);
    mFilterField.setToolTipText(Text.wrapPlainTextForToolTip(I18n.Text("Enter text here and press RETURN to select all matching items")));
    // This client property is specific to Mac OS X
    mFilterField.putClientProperty("JTextField.variant", "search");
    mFilterField.setMinimumSize(new Dimension(60, mFilterField.getPreferredSize().height));
    add(mFilterField);

    mHits = new JLabel();
    mHits.setToolTipText(Text.wrapPlainTextForToolTip(I18n.Text("The number of matches found")));
    adjustHits();
    add(mHits);

    FlexRow row = new FlexRow();
    row.add(mFilterField);
    row.add(mHits);
    row.apply(this);
}
 
Example 5
Source File: ConfigurationsComboModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ae) {
    JComboBox combo = (JComboBox) ae.getSource();
    combo.setEditable(true);
    JTextField editorComponent = (JTextField) combo.getEditor().getEditorComponent();
    editorComponent.addFocusListener(this);
    editorComponent.addKeyListener(this);
    combo.setSelectedItem(lastSelected);
    combo.addPopupMenuListener(this);
}
 
Example 6
Source File: EquipmentEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
private JTextField createIntegerNumberField(Container labelParent, Container fieldParent, String title, int value, String tooltip, int maxDigits) {
    JTextField field = new JTextField(Text.makeFiller(maxDigits, '9') + Text.makeFiller(maxDigits / 3, ','));
    UIUtilities.setToPreferredSizeOnly(field);
    field.setText(Numbers.format(value));
    field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    field.setEnabled(mIsEditable);
    new NumberFilter(field, false, false, true, maxDigits);
    field.addActionListener(this);
    field.addFocusListener(this);
    labelParent.add(new LinkedLabel(title, field));
    fieldParent.add(field);
    return field;
}
 
Example 7
Source File: EquipmentEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private JTextField createWeightField(Container labelParent, Container fieldParent, String title, WeightValue value, String tooltip, int maxDigits) {
    JTextField field = new JTextField(Text.makeFiller(maxDigits, '9') + Text.makeFiller(maxDigits / 3, ',') + ".");
    UIUtilities.setToPreferredSizeOnly(field);
    field.setText(value.toString());
    field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    field.setEnabled(mIsEditable);
    field.addActionListener(this);
    field.addFocusListener(this);
    labelParent.add(new LinkedLabel(title, field));
    fieldParent.add(field);
    return field;
}
 
Example 8
Source File: EquipmentModifierEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void createWeightAdjustmentField(Container labelParent, Container fieldParent) {
    mWeightAmountField = new JTextField("-999,999,999.00");
    UIUtilities.setToPreferredSizeOnly(mWeightAmountField);
    mWeightAmountField.setText(mRow.getWeightAdjType().format(mRow.getWeightAdjAmount(), mRow.getDataFile().defaultWeightUnits(), true));
    mWeightAmountField.setToolTipText(I18n.Text("The weight modifier"));
    mWeightAmountField.setEnabled(mIsEditable);
    mWeightAmountField.addActionListener(this);
    mWeightAmountField.addFocusListener(this);
    labelParent.add(new LinkedLabel("", mWeightAmountField));
    fieldParent.add(mWeightAmountField);
}
 
Example 9
Source File: ConfigurationsComboModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ae) {
    currentActiveItem = this;
    
    JComboBox combo = (JComboBox) ae.getSource();
    combo.setEditable(true);
    JTextField editorComponent = (JTextField) combo.getEditor().getEditorComponent();
    editorComponent.addFocusListener(this);
    editorComponent.addKeyListener(this);
    combo.setSelectedItem(lastSelected);
    combo.addPopupMenuListener(this);
}
 
Example 10
Source File: Query.java    From opt4j with MIT License 5 votes vote down vote up
public QueryColorChooser(String name, String defaultColor) {
	super(BoxLayout.X_AXIS);
	// _defaultColor = defaultColor;
	_entryBox = new JTextField(defaultColor, _width);

	JButton button = new JButton("Choose");
	button.addActionListener(this);
	add(_entryBox);
	add(button);

	// Add the listener last so that there is no notification
	// of the first value.
	_entryBox.addActionListener(new QueryActionListener(name));

	// Add a listener for loss of focus. When the entry gains
	// and then loses focus, listeners are notified of an update,
	// but only if the value has changed since the last notification.
	// FIXME: Unfortunately, Java calls this listener some random
	// time after the window has been closed. It is not even a
	// a queued event when the window is closed. Thus, we have
	// a subtle bug where if you enter a value in a line, do not
	// hit return, and then click on the X to close the window,
	// the value is restored to the original, and then sometime
	// later, the focus is lost and the entered value becomes
	// the value of the parameter. I don't know of any workaround.
	_entryBox.addFocusListener(new QueryFocusListener(name));

	_name = name;
}
 
Example 11
Source File: Query.java    From opt4j with MIT License 5 votes vote down vote up
/**
 * Create a single-line entry box with the specified name, label, default
 * value, and background color. To control the width of the box, call
 * setTextWidth() first.
 * 
 * @param name
 *            The name used to identify the entry (when accessing the
 *            entry).
 * @param label
 *            The label to attach to the entry.
 * @param defaultValue
 *            Default value to appear in the entry box.
 * @param background
 *            The background color.
 * @param foreground
 *            The foreground color.
 */
public void addLine(String name, String label, String defaultValue, Color background, Color foreground) {
	JLabel lbl = new JLabel(label + ": ");
	lbl.setBackground(_background);

	JTextField entryBox = new JTextField(defaultValue, _width);
	entryBox.setBackground(background);
	entryBox.setForeground(foreground);
	_addPair(name, lbl, entryBox, entryBox);

	// Add the listener last so that there is no notification
	// of the first value.
	entryBox.addActionListener(new QueryActionListener(name));

	// Add a listener for loss of focus. When the entry gains
	// and then loses focus, listeners are notified of an update,
	// but only if the value has changed since the last notification.
	// FIXME: Unfortunately, Java calls this listener some random
	// time after the window has been closed. It is not even a
	// a queued event when the window is closed. Thus, we have
	// a subtle bug where if you enter a value in a line, do not
	// hit return, and then click on the X to close the window,
	// the value is restored to the original, and then sometime
	// later, the focus is lost and the entered value becomes
	// the value of the parameter. I don't know of any workaround.
	entryBox.addFocusListener(new QueryFocusListener(name));
}
 
Example 12
Source File: NameChangeSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public NameChangeSupport(JTextField control) {
    this.control = control;
    control.getDocument().addDocumentListener(this);
    control.addFocusListener(this);
}
 
Example 13
Source File: FlatSpinnerUI.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
private void addEditorFocusListener( JComponent editor ) {
	JTextField textField = getEditorTextField( editor );
	if( textField != null )
		textField.addFocusListener( getHandler() );
}
 
Example 14
Source File: NewConnectionPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FocusAdapter(String targetToken, JTextField textField) {
    this.targetToken = targetToken;
    textField.addFocusListener(this);
}
 
Example 15
Source File: DataViewUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initToolbarWest(JToolBar toolbar, ActionListener outputListener, boolean nbOutputComponent) {

        if (!nbOutputComponent) {
            JButton[] btns = getEditButtons();
            for (JButton btn : btns) {
                if (btn != null) {
                    toolbar.add(btn);
                }
            }
        }

        toolbar.addSeparator(new Dimension(10, 10));

        //add refresh button
        URL url = getClass().getResource(IMG_PREFIX + "refresh.png"); // NOI18N
        refreshButton = new JButton(new ImageIcon(url));
        refreshButton.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_refresh"));
        refreshButton.addActionListener(outputListener);
        processButton(refreshButton);

        toolbar.add(refreshButton);

        //add limit row label
        limitRow = new JLabel(NbBundle.getMessage(DataViewUI.class, "LBL_max_rows"));
        limitRow.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8));
        toolbar.add(limitRow);

        //add refresh text field
        refreshField = new JTextField(5);
        refreshField.setMinimumSize(refreshField.getPreferredSize());
        refreshField.setMaximumSize(refreshField.getPreferredSize());
        refreshField.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                refreshField.selectAll();
            }
        });
        refreshField.addActionListener(outputListener);
        toolbar.add(refreshField);
        toolbar.addSeparator(new Dimension(10, 10));

        JLabel fetchedRowsNameLabel = new JLabel(NbBundle.getMessage(DataViewUI.class, "LBL_fetched_rows"));
        fetchedRowsNameLabel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(DataViewUI.class, "LBL_fetched_rows"));
        fetchedRowsNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
        toolbar.add(fetchedRowsNameLabel);
        fetchedRowsLabel = new JLabel();
        toolbar.add(fetchedRowsLabel);

        toolbar.addSeparator(new Dimension(10, 10));
    }
 
Example 16
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)
	);
}
 
Example 17
Source File: CameraTab.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
protected void addBottomFilter() {
		JLabel displayNumber1 = new JLabel("Displaying last");
		displayNumber2 = new JTextField();
		displayNumber2.setColumns(4);
		JLabel displayNumber3 = new JLabel("images decoded");
		displayNumber1.setFont(new Font("SansSerif", Font.PLAIN, 10));
		displayNumber3.setFont(new Font("SansSerif", Font.PLAIN, 10));
		displayNumber1.setBorder(new EmptyBorder(5, 2, 5, 10) ); // top left bottom right
		displayNumber3.setBorder(new EmptyBorder(5, 2, 5, 10) ); // top left bottom right
		//displayNumber2.setMinimumSize(new Dimension(50, 14));
		//displayNumber2.setMaximumSize(new Dimension(50, 14));
		displayNumber2.setText(Integer.toString(maxThumbnails));
		displayNumber2.addActionListener(this);
		bottomPanel.add(displayNumber1);
		bottomPanel.add(displayNumber2);
		bottomPanel.add(displayNumber3);
		
		lblFromReset = new JLabel("   from Reset  ");
		lblFromReset.setFont(new Font("SansSerif", Font.PLAIN, 10));
		bottomPanel.add(lblFromReset);
		
		textFromReset = new JTextField();
		bottomPanel.add(textFromReset);
		textFromReset.setText(Integer.toString(START_RESET));

		textFromReset.setColumns(8);
		textFromReset.addActionListener(this);
		textFromReset.addFocusListener(this);
		
		lblFromUptime = new JLabel("   from Uptime  ");
		lblFromUptime.setFont(new Font("SansSerif", Font.PLAIN, 10));
		bottomPanel.add(lblFromUptime);
		
		textFromUptime = new JTextField();
		bottomPanel.add(textFromUptime);

		textFromUptime.setText(Long.toString(START_UPTIME));
		textFromUptime.setColumns(8);
//		textFromUptime.setPreferredSize(new Dimension(50,14));
		textFromUptime.addActionListener(this);
		textFromUptime.addFocusListener(this);
		
	}
 
Example 18
Source File: GeneralSettingsPanel.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public GeneralSettingsPanel(final Program program, final SettingsDialog optionsDialog) {
	super(program, optionsDialog, DialoguesSettings.get().general(),  Images.DIALOG_SETTINGS.getIcon());

	jEnterFilters = new JCheckBox(DialoguesSettings.get().enterFilter());

	jHighlightSelectedRow = new JCheckBox(DialoguesSettings.get().highlightSelectedRow());

	jFocusEveOnline = new JCheckBox(DialoguesSettings.get().focusEveOnline());

	JLabel jFocusEveOnlineLinuxHelp = new JLabel(DialoguesSettings.get().focusEveOnlineLinuxHelp());
	jFocusEveOnlineLinuxHelp.setVisible(Platform.isLinux());
	JTextField jFocusEveOnlineLinuxCmd = new JTextField(DialoguesSettings.get().focusEveOnlineLinuxCmd());
	jFocusEveOnlineLinuxCmd.addFocusListener(new FocusAdapter() {
		@Override
		public void focusGained(FocusEvent e) {
			jFocusEveOnlineLinuxCmd.selectAll();
		}
	});
	jFocusEveOnlineLinuxCmd.setEditable(false);
	jFocusEveOnlineLinuxCmd.setVisible(Platform.isLinux());

	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addComponent(jEnterFilters)
			.addComponent(jHighlightSelectedRow)
			.addComponent(jFocusEveOnline)
			.addGroup(layout.createSequentialGroup()
				.addGap(30)
				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
					.addComponent(jFocusEveOnlineLinuxHelp)
					.addComponent(jFocusEveOnlineLinuxCmd)
				)
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jEnterFilters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jHighlightSelectedRow, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jFocusEveOnline, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jFocusEveOnlineLinuxHelp, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jFocusEveOnlineLinuxCmd, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
	);
}
 
Example 19
Source File: FilterDialog.java    From WhiteRabbit with Apache License 2.0 4 votes vote down vote up
public FilterDialog(Window parentWindow){
	
	super(parentWindow,"Filter",ModalityType.MODELESS);		
	this.setResizable(false);
	this.setLocation(parentWindow.getX()+parentWindow.getWidth()/2, parentWindow.getY()+100);

	contentPane.setLayout(layout);
	sourceSearchField = new JTextField(30);
	sourceSearchField.setName("Source");
	
	targetSearchField = new JTextField(30);
	targetSearchField.setName("Target");

	
	// Add key listener to send search string as it's being typed
	sourceSearchField.addKeyListener(new SearchListener() );
	sourceSearchField.addFocusListener(new SearchFocusListener());		
	JLabel sourceLabel = new JLabel("Filter Source:",JLabel.TRAILING);
	JButton sourceClearBtn = new JButton("Clear");
	contentPane.add(sourceLabel);
	contentPane.add(sourceSearchField);
	sourceClearBtn.addActionListener(this);
	sourceClearBtn.setActionCommand("Clear Source");
	sourceClearBtn.setFocusable(false);
	contentPane.add(sourceClearBtn);
	
	targetSearchField.addKeyListener(new SearchListener() );
	targetSearchField.addFocusListener(new SearchFocusListener());
	JLabel targetLabel = new JLabel("Filter Target:",JLabel.TRAILING);
	JButton targetClearBtn = new JButton("Clear");
	contentPane.add(targetLabel);
	contentPane.add(targetSearchField);		
	targetClearBtn.addActionListener(this);
	targetClearBtn.setActionCommand("Clear Target");
	targetClearBtn.setFocusable(false);
	contentPane.add(targetClearBtn);
	
	layout.putConstraint(SpringLayout.WEST, sourceLabel, 5, SpringLayout.WEST, contentPane);
	layout.putConstraint(SpringLayout.NORTH, sourceLabel, 5, SpringLayout.NORTH, contentPane);
	
	layout.putConstraint(SpringLayout.WEST, sourceSearchField, 5, SpringLayout.EAST, sourceLabel);
	layout.putConstraint(SpringLayout.NORTH, sourceSearchField, 5, SpringLayout.NORTH, contentPane);
	
	layout.putConstraint(SpringLayout.WEST, sourceClearBtn, 5, SpringLayout.EAST, sourceSearchField);
	layout.putConstraint(SpringLayout.NORTH, sourceClearBtn, 5, SpringLayout.NORTH, contentPane);
	
	layout.putConstraint(SpringLayout.WEST, targetLabel, 5, SpringLayout.WEST, contentPane);
	layout.putConstraint(SpringLayout.NORTH, targetLabel, 10, SpringLayout.SOUTH, sourceLabel);
		
	layout.putConstraint(SpringLayout.WEST, targetSearchField, 0, SpringLayout.WEST, sourceSearchField);
	layout.putConstraint(SpringLayout.NORTH, targetSearchField, 0, SpringLayout.NORTH, targetLabel);
	
	layout.putConstraint(SpringLayout.WEST, targetClearBtn, 5, SpringLayout.EAST, targetSearchField);
	layout.putConstraint(SpringLayout.NORTH, targetClearBtn, 0, SpringLayout.NORTH, targetSearchField);		

	
	layout.putConstraint(SpringLayout.SOUTH, contentPane, 5, SpringLayout.SOUTH, targetLabel);
	layout.putConstraint(SpringLayout.NORTH, contentPane, 5, SpringLayout.NORTH, sourceLabel);
	layout.putConstraint(SpringLayout.WEST, contentPane, 5, SpringLayout.WEST, sourceLabel);
	layout.putConstraint(SpringLayout.EAST, contentPane, 5, SpringLayout.EAST, targetClearBtn);
	
	this.pack();
}
 
Example 20
Source File: JTagsDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public JTagsDialog(Program program) {
	super(program, "", Images.TAG_GRAY.getImage());

	ListenerClass listener = new ListenerClass();

	JLabel jLabel = new JLabel(GuiShared.get().tagsNewMsg());

	jTextField = new JTextField();
	jTextField.addFocusListener(listener);
	jTextField.addCaretListener(listener);

	jColor = new JButton();

	colorPicker = new ColorPicker(getDialog(), jColor);
	jColor.addFocusListener(listener);
	jColor.setActionCommand(TagsDialogAction.SHOW_COLOR.name());
	jColor.addActionListener(listener);

	jOK = new JButton(GuiShared.get().ok());
	jOK.setActionCommand(TagsDialogAction.OK.name());
	jOK.addActionListener(listener);
	jOK.addFocusListener(listener);

	JButton jCancel = new JButton(GuiShared.get().cancel());
	jCancel.setActionCommand(TagsDialogAction.CANCEL.name());
	jCancel.addActionListener(listener);
	jCancel.addFocusListener(listener);

	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.CENTER)
			.addComponent(jLabel, 250, 250, Integer.MAX_VALUE)
			.addGroup(layout.createSequentialGroup()
				.addComponent(jTextField, 200, 200, 200)
				.addComponent(jColor, 30, 30, 30)
			)
			.addGroup(layout.createSequentialGroup()
				.addComponent(jOK, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addComponent(jCancel, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addGroup(layout.createParallelGroup()
				.addComponent(jTextField, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jColor, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
			.addGroup(layout.createParallelGroup()
				.addComponent(jOK, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jCancel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
	);
}