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

The following examples show how to use javax.swing.JTextField#setFocusable() . 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: GuiUtil.java    From FancyBing with GNU General Public License v3.0 4 votes vote down vote up
/** Set text field non-editable.
    Also sets it non-focusable. */
public static void setEditableFalse(JTextField field)
{
    field.setEditable(false);
    field.setFocusable(false);
}
 
Example 3
Source File: UnitInfoPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void init(String unitName, String unitType, String unitDescription) {

		setOpaque(false);
		setLayout(new BorderLayout(10, 20));
		// this.setSize(350, 400); // undecorated 301, 348 ; decorated : 303, 373

		JPanel mainPanel = new JPanel(new FlowLayout());// new BorderLayout());
		mainPanel.setOpaque(false);
		mainPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(mainPanel, BorderLayout.NORTH);

		JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
		westPanel.setOpaque(false);
		westPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(westPanel, BorderLayout.WEST);

		JPanel eastPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
		eastPanel.setOpaque(false);
		eastPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(eastPanel, BorderLayout.EAST);

		// Creating the text Input
		JTextField tf1 = new JTextField("", 15);

		tf1.setHorizontalAlignment(JTextField.CENTER);
		tf1.setOpaque(false);
		tf1.setFocusable(false);
		tf1.setBackground(new Color(92, 83, 55, 128));
		tf1.setColumns(20);
		Border border = BorderFactory.createLineBorder(Color.gray, 2);
		tf1.setBorder(border);
		tf1.setText(unitName);
		tf1.setForeground(Color.BLACK);
		tf1.setFont(new Font("Arial", Font.BOLD, 14));

		mainPanel.add(tf1);

		JTextArea ta = new JTextArea();
		String type = "TYPE: ";
		String description = "DESCRIPTION: ";

		ta.setLineWrap(true);
		ta.setFocusable(false);
		ta.setWrapStyleWord(true);
		ta.setText(type + "\n");
		ta.append(unitType + "\n\n");
		ta.append(description + "\n");
		ta.append(unitDescription);
		ta.setCaretPosition(0);
		ta.setEditable(false);
		ta.setForeground(Color.black); 
		ta.setFont(new Font("Dialog", Font.PLAIN, 14));
		ta.setOpaque(false);
		ta.setBackground(new Color(92, 83, 55, 128));

		CustomScroll scr = new CustomScroll(ta);
		scr.setSize(PopUpUnitMenu.D_WIDTH - 50 , PopUpUnitMenu.D_HEIGHT);
		add(scr, BorderLayout.CENTER);

		JPanel southPanel = new JPanel();
		add(southPanel, BorderLayout.SOUTH);
		southPanel.setOpaque(false);
		southPanel.setBackground(new Color(0, 0, 0, 128));
		
		setVisible(true);

	}