List of usage examples for javax.swing JTextField getText
public String getText()
TextComponent
. From source file:misc.TextAreaPrintingDemo.java
private MessageFormat createFormat(JTextField source) { String text = source.getText(); if (text != null && text.length() > 0) { try {/*w w w.j a va 2 s .c o m*/ return new MessageFormat(text); } catch (IllegalArgumentException e) { error("Sorry, this format is invalid."); } } return null; }
From source file:br.usp.poli.lta.cereda.wsn2spa.Editor.java
private boolean filled(JTextField... fields) { for (JTextField field : fields) { if (field.getText().trim().isEmpty()) { return false; }// w w w . j a v a2 s .c om } return true; }
From source file:br.usp.poli.lta.cereda.wsn2spa.Editor.java
private boolean valid(JTextField... fields) { for (JTextField field : fields) { if (!field.getText().contains("%s")) { return false; }//from w w w. java2s .c o m } return true; }
From source file:Main.java
public Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel pnl = new JPanel(); pnl.add(new JLabel("Enter text")); final JTextField txtText; txtText = new JTextField("to be removed"); pnl.add(txtText);/*from w ww . j av a 2 s . c om*/ JButton btnRemove = new JButton("Remove"); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) { String text = txtText.getText(); text = Normalizer.normalize(text, Normalizer.Form.NFD); txtText.setText(text.replaceAll("[^\\p{ASCII}]", "")); } }; btnRemove.addActionListener(al); pnl.add(btnRemove); add(pnl); pack(); 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);// w w w. j a v a 2 s . c om 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"); } }
From source file:RemoveAccents.java
public RemoveAccents() { setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel pnl = new JPanel(); pnl.add(new JLabel("Enter text")); final JTextField txtText; txtText = new JTextField("to be removed"); pnl.add(txtText);/*from w w w . ja va 2s . co m*/ JButton btnRemove = new JButton("Remove"); ActionListener al; al = new ActionListener() { public void actionPerformed(ActionEvent e) { String text = txtText.getText(); text = Normalizer.normalize(text, Normalizer.Form.NFD); txtText.setText(text.replaceAll("[^\\p{ASCII}]", "")); } }; btnRemove.addActionListener(al); pnl.add(btnRemove); getContentPane().add(pnl); pack(); setVisible(true); }
From source file:NewFilterTable.java
public NewFilterTable() { setDefaultCloseOperation(EXIT_ON_CLOSE); String[] columns = { "ID", "Des", "Date", "Fixed" }; Object[][] rows = { { 1, "C", new Date(), new Date() }, { 2, "G", new Date(), new Date() }, { 5, "F", new Date(), new Date() } }; TableModel model = new DefaultTableModel(rows, columns); JTable table = new JTable(model); final TableRowSorter<TableModel> sorter; sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter);/*w ww. ja va 2 s . co m*/ getContentPane().add(new JScrollPane(table)); JPanel pnl = new JPanel(); pnl.add(new JLabel("Filter expression:")); final JTextField txtFE = new JTextField(25); pnl.add(txtFE); JButton btnSetFE = new JButton("Set Filter Expression"); ActionListener al; al = new ActionListener() { public void actionPerformed(ActionEvent e) { String expr = txtFE.getText(); sorter.setRowFilter(RowFilter.regexFilter(expr)); sorter.setSortKeys(null); } }; btnSetFE.addActionListener(al); pnl.add(btnSetFE); getContentPane().add(pnl, BorderLayout.SOUTH); setSize(750, 150); setVisible(true); }
From source file:com.willwinder.ugs.nbp.core.windows.StateTopComponent.java
private void executeNumber(char word, JTextField value) { if (!StringUtils.isNumeric(value.getText())) { value.setText("0"); GUIHelpers.displayErrorDialog("Provide numeric input."); return;/* w w w .j ava2 s . c o m*/ } if (backend.isIdle()) { try { backend.sendGcodeCommand(word + value.getText()); } catch (Exception ex) { GUIHelpers.displayErrorDialog(ex.getLocalizedMessage()); } } }
From source file:eu.europa.ec.markt.tlmanager.view.pages.TreeDataPublisher.java
/** * This method handles the state of the <code>JLabel</code>'s that are associated to mandatory fields, as well as * any 'special' component. It is called via two tracks: Once by the implementation of the * <code>BindingListener</code> in <code>BindingManager</code> and once by individual action listeners for each * component. These action listeners are installed at the same time of the installation of the binding (cf. * BindingManager.setupComponent())./*from w w w . java 2s . co m*/ * * @param component the component * @param failure if the label should express a failure */ protected void changeMandatoryComponents(Component component, boolean failure) { if (mandatoryLabels == null) { return; } for (JLabel label : mandatoryLabels) { if (label == null || component == null || label.getLabelFor() == null) { continue; } if (label.getLabelFor().equals(component)) { boolean empty = false; if (component instanceof JTextField) { JTextField tf = (JTextField) component; if (tf.getText().isEmpty()) { empty = true; } } else if (component instanceof JComboBox) { JComboBox box = (JComboBox) component; if (box.isEditable()) { final String text = ((JTextComponent) box.getEditor().getEditorComponent()).getText(); if (StringUtils.isEmpty(text) || StringUtils.equals(text, Util.DEFAULT_NO_SELECTION_ENTRY)) { empty = true; } } else { if (box.getSelectedItem().equals(Util.DEFAULT_NO_SELECTION_ENTRY)) { empty = true; } } } else if (component instanceof JXDatePicker) { JXDatePicker picker = (JXDatePicker) component; Date date = picker.getDate(); if (date == null) { empty = true; } } else if (component instanceof DateTimePicker) { DateTimePicker picker = (DateTimePicker) component; Date date = picker.getDateTime(); if (date == null) { empty = true; } } else if (component instanceof MultivalueButton) { MultivalueButton button = (MultivalueButton) component; if (button.getMultivaluePanel().getMultivalueModel().isEmpty()) { empty = true; } } else if (component instanceof CertificateProperty) { CertificateProperty certificateProperty = (CertificateProperty) component; empty = certificateProperty.isEmpty(); } if (failure || empty) { label.setForeground(Configuration.MANDATORY_COLOR); } else { label.setForeground(Configuration.NORMAL_COLOR); } break; } } }
From source file:cz.alej.michalik.totp.client.AddDialog.java
/** * Ov zda je sdlen heslo platn/*from ww w.j av a2 s . co m*/ * * @param text * @return platnost */ private boolean verify(JTextField text) { System.out.println("Testuji retezec " + text.getText()); // Pokud tda Base32 vrt kl? s nulovou dlkou, nen to platn kl? if (new Base32().decode(text.getText().getBytes()).length == 0) { System.out.println("Kl? nen platn"); // Zvyraznim okraje text.setBorder(new EtchedBorder(new Color(255, 0, 0), new Color(250, 50, 50))); return false; } System.out.println("Kl? je platn"); return true; }