List of usage examples for javax.swing JTextField JTextField
public JTextField(int columns)
TextField
with the specified number of columns. From source file:FlowLayoutBehaviour.java
public FlowLayoutBehaviour() { super();//from w w w .j av a 2 s.com Container pane = getContentPane(); pane.setLayout(new FlowLayout(FlowLayout.LEFT)); pane.add(new JLabel("This is a test")); pane.add(new JButton("of a FlowLayout")); pane.add(new JTextField(30)); pane.add(new JTextArea("This is a JTextArea", 3, 10)); pane.add(new JLabel("This is a FlowLayout test with a long string")); }
From source file:Main.java
private Main() { textfield = new JTextField(10); add(textfield);//w w w . j a v a 2s . c om ((AbstractButton) add(printButton = new JButton("Print"))).addActionListener(new printListener()); ((AbstractButton) add(dialogButton = new JButton("Dialog"))).addActionListener(new dialogListener()); }
From source file:NonNumericDocument.java
public void prepareAndShowGUI() { tf = new JTextField(30); tf.setDocument(new NonNumericDocument()); getContentPane().add(tf, BorderLayout.NORTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack();/* w ww . jav a 2 s . c o m*/ setVisible(true); }
From source file:FramewithComponents.java
public FramewithComponents() { super("JLayeredPane Demo"); setSize(256, 256);//from ww w .ja v a 2s. c o m JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.setOpaque(false); JLabel label1 = new JLabel("Username:"); label1.setForeground(Color.white); content.add(label1); JTextField field = new JTextField(15); content.add(field); JLabel label2 = new JLabel("Password:"); label2.setForeground(Color.white); content.add(label2); JPasswordField fieldPass = new JPasswordField(15); content.add(fieldPass); getContentPane().setLayout(new FlowLayout()); getContentPane().add(content); ((JPanel) getContentPane()).setOpaque(false); ImageIcon earth = new ImageIcon("largeJava2sLogo.png"); JLabel backlabel = new JLabel(earth); getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE)); backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight()); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); setVisible(true); }
From source file:Main.java
private void addComponentsToPane() { JButton button = new JButton("Clear"); button.addActionListener(this); typingArea = new JTextField(20); typingArea.addKeyListener(this); getContentPane().add(typingArea, BorderLayout.PAGE_START); getContentPane().add(button, BorderLayout.PAGE_END); }
From source file:Main.java
public Main() { JFormattedTextField formattedField = null; try {/*from w w w . ja v a 2 s .c o m*/ MaskFormatter dateMask = new MaskFormatter("##/##/####"); formattedField = new JFormattedTextField(dateMask); } catch (ParseException ex) { System.out.println(ex); } formattedField.setColumns(10); formattedField.setInputVerifier(getInputVerifier()); JTextField field = new JTextField(10); format.setLenient(false); Box box = Box.createVerticalBox(); box.add(formattedField); box.add(Box.createVerticalStrut(10)); box.add(field); box.setBorder(new EmptyBorder(10, 10, 10, 10)); JFrame frame = new JFrame(); frame.add(box); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:GridBagConstraintsSimplePanel.java
public GridBagConstraintsSimplePanel() { super();//from w ww . j a v a2 s .co m GridBagConstraints constraints = new GridBagConstraints(); GridBagLayout layout = new GridBagLayout(); setLayout(layout); constraints.anchor = GridBagConstraints.WEST; constraints.gridy = 0; JLabel label = new JLabel("First name:"); add(label, constraints); JTextField tf = new JTextField(8); add(tf, constraints); label = new JLabel("Last name:"); add(label, constraints); tf = new JTextField(8); add(tf, constraints); constraints.gridy = 1; label = new JLabel("Address:"); add(label, constraints); tf = new JTextField(10); add(tf, constraints); }
From source file:Main.java
private void addComponentsToPane() { JButton button = new JButton("Clear"); button.addActionListener(this); typingArea = new JTextField(20); typingArea.addKeyListener(this); displayArea = new JTextArea(); displayArea.setEditable(false);//from ww w . ja va2 s. c o m JScrollPane scrollPane = new JScrollPane(displayArea); scrollPane.setPreferredSize(new Dimension(375, 125)); getContentPane().add(typingArea, BorderLayout.PAGE_START); getContentPane().add(scrollPane, BorderLayout.CENTER); getContentPane().add(button, BorderLayout.PAGE_END); }
From source file:JTextFieldLimit.java
public void init() { setLayout(new FlowLayout()); label1 = new JLabel("max 10 chars"); textfield1 = new JTextField(15); add(label1);/*w ww . j a v a2s .co m*/ add(textfield1); textfield1.setDocument(new JTextFieldLimit(10)); setSize(300, 300); setVisible(true); }
From source file:mysynopsis.FTPUploader.java
public static void display() throws IOException { JTextField address = new JTextField(server); JTextField username = new JTextField(user); JPasswordField password = new JPasswordField(pass); JTextField directory = new JTextField(dir); JPanel panel = new JPanel(new GridLayout(10, 1)); panel.add(new JLabel("Server Address:")); panel.add(address);//from w w w . j a v a 2s.c o m panel.add(new JLabel("Username:")); panel.add(username); panel.add(new JLabel("Password:")); panel.add(password); panel.add(new JLabel("Upload Directory:")); panel.add(directory); int result; /*JOptionPane pane = new JOptionPane(panel,JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION); JDialog dialog = pane.createDialog(MotherFrame.mframe, "FTP Upload Wizard - My Synopsis"); dialog.setSize(new Dimension(300,300)); dialog.setVisible(true);*/ result = JOptionPane.showConfirmDialog(MotherFrame.mframe, panel, "FTP Upload Wizard", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { server = address.getText(); user = username.getText(); pass = new String(password.getPassword()); // System.out.println(pass); dir = directory.getText(); JOptionPane.showMessageDialog(MotherFrame.mframe, "Press OK to start FTP Upload"); HTMLWriter.writeHTML(); JOptionPane.showMessageDialog(MotherFrame.mframe, uploadWizard()); } else { // System.out.println("Cancelled"); } }