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

The following examples show how to use javax.swing.JTextField#setHorizontalAlignment() . These examples are extracted from open source projects. 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 Project: mzmine2   File: JFontSpecs.java    License: GNU General Public License v2.0 6 votes vote down vote up
public JFontSpecs() {
  super();
  fontBox = new JFontBox();
  add(fontBox);

  styleBox = new JFontStyleBox();
  add(styleBox);


  txtSize = new JTextField();
  txtSize.setHorizontalAlignment(SwingConstants.RIGHT);
  txtSize.setText("14");
  add(txtSize);
  txtSize.setColumns(3);

  color = new JColorPickerButton(this);
  add(color);
  color.setColor(Color.WHITE);

  // setPreferredSize(new Dimension(280, 30));
  this.validate();
  setMaximumSize(getPreferredSize());
}
 
Example 2
private void createBoundFields ()
{
    // Allocate bound fields (2 per check)
    final int checkNb = suite.getChecks().size();
    bounds = new JTextField[checkNb][];

    for (int ic = 0; ic < checkNb; ic++) {
        Check<C> check = suite.getChecks().get(ic);
        bounds[ic] = new JTextField[2];

        for (int i = 0; i <= 1; i++) {
            JTextField field = new JTextField(FIELD_WIDTH);
            field.setHorizontalAlignment(JTextField.CENTER);
            bounds[ic][i] = field;

            Constant.Double constant = (i == 0) ? check.getLowConstant()
                    : check.getHighConstant();

            field.setText(textOf(constant.getValue()));
            field.setToolTipText(
                    "<html>" + constant.getName() + "<br/>"
                    + constant.getDescription() + "</html>");
        }
    }
}
 
Example 3
/**
 * JSpinField constructor with given minimum and maximum vaues and initial
 * value 0.
 */
public JSpinField(int min, int max) {
	super();
	setName("JSpinField");
	this.min = min;
	if (max < min)
		max = min;
	this.max = max;
	value = 0;
	if (value < min)
		value = min;
	if (value > max)
		value = max;

	darkGreen = new Color(0, 150, 0);
	setLayout(new BorderLayout());
	textField = new JTextField();
	textField.addCaretListener(this);
	textField.addActionListener(this);
	textField.setHorizontalAlignment(SwingConstants.RIGHT);
	textField.setBorder(BorderFactory.createEmptyBorder());
	textField.setText(Integer.toString(value));
	textField.addFocusListener(this);
	spinner = new JSpinner() {
		private static final long serialVersionUID = -6287709243342021172L;
		private JTextField textField = new JTextField();

		public Dimension getPreferredSize() {
			Dimension size = super.getPreferredSize();
			return new Dimension(size.width, textField.getPreferredSize().height);
		}
	};
	spinner.setEditor(textField);
	spinner.addChangeListener(this);
	// spinner.setSize(spinner.getWidth(), textField.getHeight());
	add(spinner, BorderLayout.CENTER);
}
 
Example 4
private void createTime(TimeSettings timeSettings, JComponent labels,
                        JComponent values)
{
    Box boxLabel = Box.createHorizontalBox();
    boxLabel.add(Box.createHorizontalGlue());
    JLabel label = new JLabel(i18n("LB_GAMEINFO_TIME"));
    label.setAlignmentY(Component.CENTER_ALIGNMENT);
    boxLabel.add(label);
    labels.add(boxLabel);
    Box boxValue = Box.createVerticalBox();
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    boxValue.add(Box.createVerticalGlue());
    boxValue.add(panel);
    boxValue.add(Box.createVerticalGlue());
    m_preByoyomi = new TimeField(3, "TT_GAMEINFO_TIME_MAIN");
    if (timeSettings != null)
        m_preByoyomi.setTime(timeSettings.getPreByoyomi());
    panel.add(m_preByoyomi);
    panel.add(new JLabel(" + "));
    m_byoyomi = new TimeField(2, "TT_GAMEINFO_TIME_BYOYOMI");
    if (timeSettings != null && timeSettings.getUseByoyomi())
        m_byoyomi.setTime(timeSettings.getByoyomi());
    panel.add(m_byoyomi);
    panel.add(new JLabel(" / "));
    m_byoyomiMoves = new JTextField(2);
    m_byoyomiMoves.setToolTipText(i18n("TT_GAMEINFO_TIME_BYOYOMI_MOVES"));
    m_byoyomiMoves.setHorizontalAlignment(JTextField.RIGHT);
    if (timeSettings != null && timeSettings.getUseByoyomi())
    {
        int byoyomiMoves = timeSettings.getByoyomiMoves();
        m_byoyomiMoves.setText(Integer.toString(byoyomiMoves));
    }
    panel.add(m_byoyomiMoves);
    panel.add(new JLabel(" " + i18n("LB_GAMEINFO_TIME_MOVES")));
    values.add(boxValue);
}
 
Example 5
private JTextField createEntry(String labelText, int cols, String toolTip,
                               JComponent labels, JComponent values)
{
    labels.add(createEntryLabel(labelText));
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    JTextField field = new JTextField(cols);
    GuiUtil.setEditableFalse(field);
    field.setHorizontalAlignment(JTextField.CENTER);
    field.setToolTipText(i18n(toolTip));
    panel.add(field);
    values.add(panel);
    return field;
}
 
Example 6
private ColorFields createColorEntry(String labelText, int cols,
                                     String toolTipBlack,
                                     String toolTipWhite,
                                     JComponent labels,
                                     JComponent values)
{
    labels.add(createEntryLabel(labelText));
    ColorFields colorFields = new ColorFields();
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    panel.add(new JLabel(ICON_BLACK));
    panel.add(GuiUtil.createSmallFiller());
    JTextField black = new JTextField(cols);
    black.setHorizontalAlignment(JTextField.CENTER);
    colorFields.m_black = black;
    GuiUtil.setEditableFalse(black);
    if (toolTipBlack != null)
        black.setToolTipText(i18n(toolTipBlack));
    panel.add(black);
    panel.add(GuiUtil.createFiller());
    panel.add(new JLabel(ICON_WHITE));
    panel.add(GuiUtil.createSmallFiller());
    JTextField white = new JTextField(cols);
    white.setHorizontalAlignment(JTextField.CENTER);
    colorFields.m_white = white;
    GuiUtil.setEditableFalse(white);
    if (toolTipWhite != null)
        white.setToolTipText(i18n(toolTipWhite));
    panel.add(white);
    values.add(panel);
    return colorFields;
}
 
Example 7
private JTextField addRow(JPanel panel, String label, GridBagConstraints gbc) {
    gbc.gridy++;

    gbc.weightx = 0.2;
    gbc.gridx = 0;
    panel.add(new JLabel(label), gbc);

    gbc.weightx = 0.8;
    gbc.gridx = 1;
    final JTextField fileField = new JTextField(12);
    fileField.setHorizontalAlignment(JTextField.RIGHT);
    panel.add(fileField, gbc);
    fileField.getDocument().addDocumentListener(new MyDocumentListener());
    return fileField;
}
 
Example 8
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 9
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 10
private void createValueFields ()
{
    // Allocate value fields (3 per check)
    final int checkNb = suite.getChecks().size();
    values = new JTextField[checkNb][3];

    for (int n = 0; n < checkNb; n++) {
        for (int i = 0; i <= 2; i++) {
            JTextField field = new JTextField(FIELD_WIDTH);
            field.setEditable(false);
            field.setHorizontalAlignment(JTextField.CENTER);
            values[n][i] = field;
        }
    }
}
 
Example 11
Source Project: ios-image-util   File: SplitterFrame.java    License: MIT License 5 votes vote down vote up
/**
 * Initialize text field to size box.
 *
 * @param tooltipText tooltip text
 * @param focusListener
 * @param documentListener
 * @return
 */
private JTextField createSizeText(String tooltipText, FocusListener focusListener, DocumentListener documentListener) {
	JTextField textField = new JTextField("", 5);
	Insets insets = new Insets(2, 2, 2, 4);
	textField.setToolTipText(tooltipText);
	textField.setHorizontalAlignment(JTextField.RIGHT);
	textField.setMargin(insets);
	textField.addFocusListener(focusListener);
	textField.getDocument().addDocumentListener(documentListener);
	return textField;
}
 
Example 12
Source Project: swcv   File: MetricsPanel.java    License: MIT License 5 votes vote down vote up
private JTextField createTextField()
{
    JTextField field = new JTextField();
    field.setEnabled(false);
    field.setDisabledTextColor(Color.BLACK);
    field.setPreferredSize(new Dimension(100, 20));
    field.setHorizontalAlignment(JTextField.CENTER);
    return field;
}
 
Example 13
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
                                             int column) {
    JComponent component = (JComponent) super.getTableCellEditorComponent(table, value, isSelected, row,
                                                                          column);
    final JTextField textField = (JTextField) component;
    textField.selectAll();
    textField.setBorder(defaultBorder);
    textField.setHorizontalAlignment(JTextField.RIGHT);
    return component;
}
 
Example 14
private JTextField makeTextField(JPanel features, int row) {
	final JTextField f = new JTextField(5);
	f.setHorizontalAlignment(SwingUtilities.RIGHT);
	f.setFont(FONT);
	f.setText("");
	f.setEditable(false);

	final GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = 1;
	gbc.gridy = row;
	features.add(f, gbc);

	return f;
}
 
Example 15
Source Project: jaamsim   File: GUIFrame.java    License: Apache License 2.0 4 votes vote down vote up
private void addDisplayModelSelector(JToolBar buttonBar, Insets margin) {

		dispModel = new JTextField("");
		dispModel.setEditable(false);
		dispModel.setHorizontalAlignment(JTextField.CENTER);
		dispModel.setPreferredSize(new Dimension(120, fileSave.getPreferredSize().height));
		dispModel.setToolTipText(formatToolTip("DisplayModel", "Sets the default appearance of the entity. "
				+ "A DisplayModel is analogous to a text style in a word processor."));
		buttonBar.add(dispModel);

		modelSelector = new JButton(new ImageIcon(
				GUIFrame.class.getResource("/resources/images/dropdown.png")));
		modelSelector.setMargin(margin);
		modelSelector.setFocusPainted(false);
		modelSelector.setRequestFocusEnabled(false);
		modelSelector.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed( ActionEvent event ) {
				if (!(selectedEntity instanceof DisplayEntity))
					return;
				DisplayEntity dispEnt = (DisplayEntity) selectedEntity;
				if (!dispEnt.isGraphicsNominal() || dispEnt.getDisplayModelList().size() != 1)
					return;
				final String presentModelName = dispEnt.getDisplayModelList().get(0).getName();
				Input<?> in = dispEnt.getInput("DisplayModel");
				ArrayList<String> choices = in.getValidOptions(selectedEntity);
				PreviewablePopupMenu menu = new PreviewablePopupMenu(presentModelName, choices, true) {

					@Override
					public void setValue(String str) {
						dispModel.setText(str);
						KeywordIndex kw = InputAgent.formatArgs("DisplayModel", str);
						InputAgent.storeAndExecute(new KeywordCommand(dispEnt, kw));
					}

				};
				menu.show(dispModel, 0, dispModel.getPreferredSize().height);
				controlStartResume.requestFocusInWindow();
			}
		});

		buttonBar.add(modelSelector);
	}
 
Example 16
@Override
public Component getComponent(int width, int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	classifier = new SimplePerceptron();

	circle = new Circle(VIDEO_WIDTH / 2, VIDEO_HEIGHT / 2, VIDEO_HEIGHT / 8);

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);
	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.setOpaque(false);
	videoCtrls.add(vc);
	videoCtrls.add(Box.createVerticalStrut(10));
	final JPanel colourspacesPanel = createColourSpaceButtons();
	videoCtrls.add(colourspacesPanel);
	createFeatureField();
	videoCtrls.add(Box.createVerticalStrut(10));
	videoCtrls.add(featureField);
	base.add(videoCtrls);

	// right hand box
	final Box rightPanel = Box.createVerticalBox();
	rightPanel.setOpaque(false);
	image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB);
	image.fill(RGBColour.WHITE);
	imageComp = new DisplayUtilities.ImageComponent(true, false);
	imageComp.setShowPixelColours(false);
	imageComp.setShowXYPosition(false);
	imageComp.setAllowZoom(false);
	imageComp.setAllowPanning(false);
	rightPanel.add(imageComp);
	final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2));

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	classType = new JComboBox<String>();
	for (final String c : CLASSES)
		classType.addItem(c);
	learnCtrls.add(classType);
	final JButton learnButton = new JButton("Learn");
	learnButton.setActionCommand("button.learn");
	learnButton.addActionListener(this);
	learnCtrls.add(learnButton);
	classCtrlsCnt.add(learnCtrls);

	// classification controls
	final JPanel classCtrls = new JPanel(new GridLayout(0, 1));
	classCtrls.setOpaque(false);
	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-24"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	classCtrls.add(guess);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 17
@Override
public Component getComponent(final int width, final int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	k = 1;

	circle = new Circle(VIDEO_WIDTH / 2, VIDEO_HEIGHT / 2, VIDEO_HEIGHT / 8);

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);

	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void paintComponent(Graphics g) {
			((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

			super.paintComponent(g);

			if (bgImage != null)
				g.drawImage(bgImage, 0, 0, width, height, null);
		}
	};
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.add(vc);
	videoCtrls.add(Box.createVerticalStrut(10));
	final JPanel colourspacesPanel = createColourSpaceButtons();
	videoCtrls.add(colourspacesPanel);
	createFeatureField();
	videoCtrls.add(Box.createVerticalStrut(10));
	videoCtrls.add(featureField);
	base.add(videoCtrls);

	// right hand box
	final Box rightPanel = Box.createVerticalBox();
	rightPanel.setOpaque(false);

	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-48"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	rightPanel.add(guess);

	image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB);
	image.fill(RGBColour.WHITE);
	imageComp = new DisplayUtilities.ImageComponent(true, false);
	imageComp.setShowPixelColours(false);
	imageComp.setShowXYPosition(false);
	imageComp.setAllowZoom(false);
	imageComp.setAllowPanning(false);
	rightPanel.add(imageComp);
	final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2));
	classCtrlsCnt.setOpaque(false);

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	learnCtrls.setOpaque(false);
	classType = new JComboBox<String>();
	for (final String c : CLASSES)
		classType.addItem(c);
	learnCtrls.add(classType);
	final JButton learnButton = new JButton("Learn");
	learnButton.setActionCommand("button.learn");
	learnButton.addActionListener(this);
	learnCtrls.add(learnButton);
	classCtrlsCnt.add(learnCtrls);

	// classification controls
	final JPanel classCtrls = new JPanel(new GridLayout(0, 1));
	classCtrls.setOpaque(false);
	final JPanel cnt = new JPanel();
	cnt.setOpaque(false);
	cnt.add(new JLabel("K:"));
	final JSpinner kField = new JSpinner(new SpinnerNumberModel(k, 1, 10, 1));
	kField.addChangeListener(this);
	cnt.add(kField);
	classCtrls.add(cnt);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 18
public Main_CustomersFrame() {

        this.setAutoscrolls(true);
        this.setMinimumSize(new Dimension(800, 600));
        /*make it default size of frame maximized */
        this.setMaximumSize(new Dimension(1000, 900));
        this.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
        setLayout(new BorderLayout(0, 0));

        bean = LocaleBean.getInstance();
        loggingEngine = LoggingEngine.getInstance();
        componentOrientation = new ChangeComponentOrientation();
        componentOrientation.setThePanel(this);

        searchPanel.setDoubleBuffered(false);
        searchPanel.setAutoscrolls(true);
        add(searchPanel, BorderLayout.NORTH);
        searchPanel.setPreferredSize(new Dimension(10, 30));

        lblTableFilter = new JLabel("Type to search : ");
        lblTableFilter.setForeground(new Color(178, 34, 34));
        lblTableFilter.setSize(new Dimension(130, 25));
        lblTableFilter.setPreferredSize(new Dimension(130, 22));
        lblTableFilter.setHorizontalTextPosition(SwingConstants.CENTER);
        lblTableFilter.setAutoscrolls(true);
        lblTableFilter.setHorizontalAlignment(SwingConstants.LEFT);
        lblTableFilter.setFont(new Font("Dialog", Font.BOLD, 15));

        searchFilterField = new JTextField();
        searchFilterField.setDragEnabled(true);
        searchFilterField.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, new Color(0, 191, 255), null, null, null));
        searchFilterField.setPreferredSize(new Dimension(200, 22));
        searchFilterField.setIgnoreRepaint(true);
        searchFilterField.setColumns(10);
        searchFilterField.setFont(new Font("Dialog", Font.BOLD, 13));
        searchFilterField.setHorizontalAlignment(SwingConstants.LEFT);
        GroupLayout gl_searchPanel = new GroupLayout(searchPanel);
        gl_searchPanel.setHorizontalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(ComponentPlacement.RELATED)
                                .addComponent(searchFilterField, GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                                .addGap(118))
        );
        gl_searchPanel.setVerticalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addGap(5)
                                .addGroup(gl_searchPanel.createParallelGroup(Alignment.BASELINE)
                                        .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(searchFilterField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                .addContainerGap())
        );
        searchPanel.setLayout(gl_searchPanel);

        searchFilterField.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {

                final String searchedWord = searchFilterField.getText();
                filter(searchedWord);

            }
        });

        scrollPane = new JScrollPane();
        add(scrollPane);

        //populate main table model with custom method
        populateMainTable(model);

        customerTable = new JTable(model);
        customerTable.setFillsViewportHeight(true);
        customerTable.setRowSelectionAllowed(true);

        THR.setHorizontalAlignment(SwingConstants.CENTER);

        customerTable.setDefaultRenderer(Object.class, renderer);
        customerTable.getTableHeader().setDefaultRenderer(THR);
        customerTable.setFont(new Font("Dialog", Font.PLAIN, 14));
        customerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        customerTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        customerTable.setBackground(new Color(245, 245, 245));
        customerTable.addMouseListener(openCustomerListener());
        scrollPane.setViewportView(customerTable);

        //change component orientation with locale.
        if (bean.getLocale().toString().equals("ar_IQ")) {
            componentOrientation.changeOrientationOfJPanelToRight();
        } else {
            componentOrientation.changeOrientationOfJPanelToLeft();
        }
        //inject action event to Customers detail window to save all changes
        custWindow.setActionListener(saveChanges());
        this.setVisible(true);
    }
 
Example 19
/**
 * Creates a new Options object.
 */
public Options ()
{
    // Preload constant units
    UnitManager.getInstance().preLoadUnits();

    frame = new JFrame();
    frame.setName("optionsFrame");
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JComponent framePane = (JComponent) frame.getContentPane();
    framePane.setLayout(new BorderLayout());

    InputMap inputMap = framePane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    ActionMap actionMap = framePane.getActionMap();

    JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);
    framePane.add(toolBar, BorderLayout.NORTH);

    // Dump button
    JButton dumpButton = new JButton(dumping);
    dumpButton.setName("optionsDumpButton");
    toolBar.add(dumpButton);

    // Check button
    JButton checkButton = new JButton(checking);
    checkButton.setName("optionsCheckButton");
    toolBar.add(checkButton);

    // Reset button
    JButton resetButton = new JButton(resetting);
    resetButton.setName("optionsResetButton");
    toolBar.add(resetButton);

    // Some space
    toolBar.add(Box.createHorizontalStrut(100));

    toolBar.add(new JLabel("Search:"));

    // Back button
    JButton backButton = new JButton(backSearch);
    backButton.setName("optionsBackButton");
    toolBar.add(backButton);
    inputMap.put(KeyStroke.getKeyStroke("shift F3"), "backSearch");
    actionMap.put("backSearch", backSearch);

    // Search entry
    searchField = new JTextField();
    searchField.setMaximumSize(new Dimension(200, 28));
    searchField.setName("optionsSearchField");
    searchField.setHorizontalAlignment(JTextField.LEFT);
    toolBar.add(searchField);
    inputMap.put(KeyStroke.getKeyStroke("ctrl F"), "find");
    actionMap.put("find", find);
    searchField.getDocument().addDocumentListener(docListener);

    // Forward button
    JButton forwardButton = new JButton(forwardSearch);
    forwardButton.setName("optionsForwardButton");
    toolBar.add(forwardButton);

    // Some space, message field
    toolBar.add(Box.createHorizontalStrut(10));
    toolBar.add(msgLabel);

    // TreeTable
    UnitModel unitModel = new UnitModel();
    unitTreeTable = new UnitTreeTable(unitModel);
    framePane.add(new JScrollPane(unitTreeTable), BorderLayout.CENTER);

    // Needed to process user input when RETURN/ENTER is pressed
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "forwardSearch");
    inputMap.put(KeyStroke.getKeyStroke("F3"), "forwardSearch");
    actionMap.put("forwardSearch", forwardSearch);

    // Resources injection
    ResourceMap resource = Application.getInstance().getContext().getResourceMap(getClass());
    resource.injectComponents(frame);

    // Make sure the search entry field gets the focus at creation time
    frame.addWindowListener(new WindowAdapter()
    {
        @Override
        public void windowOpened (WindowEvent e)
        {
            searchField.requestFocus();
        }
    });
}
 
Example 20
/**
 * Konfiguriert das Aussehen des Textfeldes.
 *
 * @param textField
 */
protected final void setStyle(JTextField textField) {
  setClickCountToStart(1);
  textField.setHorizontalAlignment(JTextField.LEFT);
}