List of usage examples for javax.swing JTextField JTextField
public JTextField(int columns)
TextField
with the specified number of columns. From source file:Main.java
public Main() { JTextField f = new JTextField(20); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.SOUTHEAST; c.weighty = 1;//w w w. java 2 s . c om add(f, c); }
From source file:Main.java
public Main() { super(null);/*www . j a va2s . c o m*/ JTextField tf = new JTextField(10); add(tf); Dimension d = tf.getPreferredSize(); tf.setBounds(10, 20, d.width, d.height); }
From source file:MyFrame.java
public MyFrame() { field1 = new JTextField(10); getContentPane().add("Center", field1); addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { field1.requestFocus();// w w w . j a v a 2s . co m } }); pack(); setVisible(true); }
From source file:Main.java
public void init() { tf1 = new JTextField(5); tf1.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { };//w ww . j a v a 2 s . c om public void focusLost(FocusEvent e) { if (!e.isTemporary()) { String content = tf1.getText(); if (!content.equals("a")) { System.out.println("illegal value! " + content); SwingUtilities.invokeLater(new FocusGrabber(tf1)); } } } }); }
From source file:Main.java
public Main() { JButton button = new JButton("foo"); JTextField textField = new JTextField(10); Document document = textField.getDocument(); document.addDocumentListener(new JButtonStateController(button)); JOptionPane.showMessageDialog(null, textField); }
From source file:Main.java
public Main() { JButton button = new JButton("foo"); JTextField textField = new JTextField(10); Document document = textField.getDocument(); document.addDocumentListener(new JButtonStateController(button)); JFrame frame = new JFrame(); frame.add(button, BorderLayout.WEST); frame.add(textField, BorderLayout.CENTER); frame.setSize(300, 300);//from ww w . ja v a 2 s. co m frame.setVisible(true); }
From source file:Main.java
public Main() { tabbedPane = new JTabbedPane(); tabbedPane.setPreferredSize(new Dimension(300, 200)); getContentPane().add(tabbedPane);//from w ww .j av a 2 s .c om JTextField one = new JTextField("one"); tabbedPane.add(one, "one"); JTextField two = new JTextField("two"); tabbedPane.add(two, "<html>T<br>i<br>t<br>t<br>l<br>e <br> 1 </html>"); tabbedPane.setEnabledAt(2, false); tabbedPane.setTabPlacement(JTabbedPane.LEFT); }
From source file:Main.java
public Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel p = new JPanel(new BorderLayout()); JTextField tf = new JTextField(5); JLabel label = new JLabel(new ImageIcon("Test.gif")); label.setOpaque(true);//ww w . java2s . c o m label.setBackground(tf.getBackground()); label.setPreferredSize(new Dimension(label.getPreferredSize().width, tf.getPreferredSize().height)); p.setBorder(tf.getBorder()); tf.setBorder(null); p.add(label, BorderLayout.WEST); p.add(tf, BorderLayout.CENTER); JPanel p1 = new JPanel(); p1.add(p); getContentPane().add(p1); pack(); setLocationRelativeTo(null); }
From source file:Main.java
Main() { JPanel p = new JPanel(new BorderLayout(2, 2)); JTextField find = new JTextField("food:pizza"); find.addActionListener(e -> {// ww w. j a v a 2 s. c o m boolean found = findText(find.getText()); System.out.println(find.getText() + " found " + found); }); p.add(find, BorderLayout.PAGE_START); tree.setVisibleRowCount(8); for (int row = tree.getRowCount(); row >= 0; row--) { tree.expandRow(row); } p.add(new JScrollPane(tree), BorderLayout.CENTER); JOptionPane.showMessageDialog(null, p); }
From source file:TableDemoApplet.java
private static void createGUI(Container contentPane) { Object[][] rowData = new String[][] { { "98-43", "AraAra! SL" }, { "81-31", "Aragones Transports SA" }, { "12-72", "Rocca SL" }, { "99-10", "Rodriguez e Hijos SA" }, { "00-65", "Rimbau Motors SL" } }; JTable table = new JTable(rowData, new String[] { "Part No", "Provider" }); JComboBox companyComboBox = new JComboBox(new Object[] { "AraAra! SL", "Aragones Transports SA", "Rocca SL", "Rodriguez e Hijos SA", "Rimbau Motors SL" }); companyComboBox.setEditable(true);/*w ww .j av a 2 s.co m*/ new S15WorkingBackspace(companyComboBox); // setup the ComboBoxCellEditor, DefaultCellEditor won't work! table.getColumnModel().getColumn(1).setCellEditor(new ComboBoxCellEditor(companyComboBox)); table.setPreferredScrollableViewportSize(new Dimension(400, 100)); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new java.awt.FlowLayout()); contentPane.add(scrollPane); contentPane.add(new JTextField("HALLO!")); }