List of usage examples for javax.swing JTextField getText
public String getText()
TextComponent
. From source file:MainProgram.MainProgram.java
public boolean mailTest(JTextField emailTextField, JPasswordField emailPasswordField, boolean mailCorrect) throws IOException, InterruptedException { String passwordString = String.copyValueOf(emailPasswordField.getPassword()); mailCorrect = JavaMailReceiving.testMail("pop.mail.com", "pop3", emailTextField.getText() + "@mail.com", passwordString);/*from w w w . j av a 2 s.com*/ return mailCorrect; }
From source file:at.beris.jarcommander.helper.ModelViewController.java
public void setViewPropertyValue(Component viewProperty, Object newValue) { if (viewProperty instanceof JTextField) { JTextField textfield = (JTextField) viewProperty; String oldValue = null;/*from www . j ava 2 s . c om*/ if (viewProperty instanceof JPasswordField) { if (newValue == null) newValue = new char[0]; oldValue = String.valueOf(((JPasswordField) textfield).getPassword()); if (!StringUtils.equals(oldValue, String.valueOf((char[]) newValue))) { ((JTextField) viewProperty).setText(String.valueOf((char[]) newValue)); } } else { oldValue = textfield.getText(); if (newValue == null) newValue = ""; if (!StringUtils.equals(oldValue, String.valueOf(newValue))) { ((JTextField) viewProperty).setText(String.valueOf(newValue)); } } } }
From source file:LicenseGenerator.java
private void checkAdapter(JCheckBox chk, JTextField txt, int[] adapterFlag, String[] adapterDate) { if (chk.isSelected()) { String name = chk.getText(); int i;//from w w w . j av a 2 s . c o m i = (name.substring(0, name.lastIndexOf('.')).hashCode() & 0x7fffffff) % 64; if (name.endsWith(".s")) i += 64; System.out.println("adapter = " + name + " id = " + i + " limit = " + txt.getText()); adapterFlag[i] = 1; adapterDate[i] = txt.getText(); } }
From source file:edu.ku.brc.af.ui.weblink.WebLinkButton.java
/** * @return// w ww. j av a2s. c o m */ private CustomDialog createPromptDlg(final Hashtable<String, String> backupHash) { if (webLinkDef != null) { // Start by getting the data needed to build the URL // so first see if we need to prompt for data. int promptCnt = webLinkDef.getPromptCount(); if (promptCnt > 0 || backupHash.size() > 0) { textFieldHash.clear(); promptCnt += backupHash != null ? backupHash.size() : 0; String rowDef = createDuplicateJGoodiesDef("p", "4px", promptCnt); //$NON-NLS-1$ //$NON-NLS-2$ PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,f:p:g", rowDef)); //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); DocumentAdaptor dla = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { super.changed(e); boolean enableOK = true; for (JTextField tf : textFieldHash.values()) { if (tf.getText().length() == 0) { enableOK = false; break; } } promptDialog.getOkBtn().setEnabled(enableOK); } }; int y = 1; for (WebLinkDefArg arg : webLinkDef.getArgs()) { if (arg.isPrompt() && valueHash.get(arg.getName()) == null) { JTextField txtField = createTextField(15); txtField.getDocument().addDocumentListener(dla); textFieldHash.put(arg.getName(), txtField); String label = arg.getTitle(); if (StringUtils.isEmpty(label)) { label = arg.getName(); } pb.add(createFormLabel(label), cc.xy(1, y)); pb.add(txtField, cc.xy(3, y)); y += 2; } } if (backupHash != null) { for (String name : backupHash.keySet()) { JTextField txtField = createTextField(15); txtField.getDocument().addDocumentListener(dla); textFieldHash.put(name, txtField); pb.add(createLabel(backupHash.get(name), SwingConstants.RIGHT), cc.xy(1, y)); pb.add(txtField, cc.xy(3, y)); y += 2; } } pb.setDefaultDialogBorder(); return new CustomDialog((Frame) getTopWindow(), getResourceString("WBLK_PROMPT_DATA"), true, CustomDialog.OKCANCELHELP, pb.getPanel()); } } return null; }
From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java
/** * {@inheritDoc}//from w w w . j a v a 2 s .c o m */ @Override public void actionPerformed(final ActionEvent aE) { JPanel newPanel = new JPanel(new GridLayout(2, 2)); newPanel.add(new JLabel("GUID:")); final JTextField disabledIDInput = new JTextField(myAccount.getId()); final JPopupMenu accountIDPopupMenu = createAccountIDPopupMenu(); disabledIDInput.setEditable(false); disabledIDInput.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(final MouseEvent arg0) { if (arg0.isPopupTrigger()) { accountIDPopupMenu.show(disabledIDInput, arg0.getX(), arg0.getY()); } } @Override public void mousePressed(final MouseEvent arg0) { if (arg0.isPopupTrigger()) { accountIDPopupMenu.show(disabledIDInput, arg0.getX(), arg0.getY()); } } }); newPanel.add(disabledIDInput); newPanel.add(new JLabel("name:")); final JTextField nameInput = new JTextField(myAccount.getName()); nameInput.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent aE) { myAccount.setName(nameInput.getText()); } }); newPanel.add(nameInput); myFrame = new JFrame(myAccount.getName()); myFrame.getContentPane().setLayout(new BorderLayout()); myFrame.getContentPane().add(newPanel, BorderLayout.NORTH); myFrame.getContentPane().add(getButtonsPanel(), BorderLayout.SOUTH); myFrame.getContentPane().add(getMySettingsPanel(), BorderLayout.CENTER); myFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); myFrame.pack(); myFrame.setVisible(true); }
From source file:com.sec.ose.osi.ui.frm.main.identification.common.JComboComponentName.java
private void init() { final JTextField tfComponentName = (JTextField) this.getEditor().getEditorComponent(); tfComponentName.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && ch != KeyEvent.VK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) return; if (ch == KeyEvent.VK_ENTER) { JComboComponentName.this.hidePopup(); return; }/*from w ww . ja v a 2 s .co m*/ // 1. save string String keyword = tfComponentName.getText();//.trim(); updateComboBoxList(keyword); } }); tfComponentName.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (tfComponentName.getText().length() > 0) showPopup(); } public void focusLost(FocusEvent e) { hidePopup(); } }); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopPickerField.java
@Override public void addFieldListener(final FieldListener listener) { final JTextField field = (JTextField) impl.getEditor(); field.addFocusListener(new FocusAdapter() { @Override/*from w w w .j av a 2 s . c o m*/ public void focusLost(FocusEvent e) { fireFieldListener(listener, field.getText()); } }); field.addKeyListener(new KeyAdapter() { protected static final int ENTER_CODE = 10; @Override public void keyPressed(KeyEvent e) { if (ENTER_CODE == e.getKeyCode()) { fireFieldListener(listener, field.getText()); } } }); }
From source file:main.UIController.java
/******** FROM GREGORIAN **********/ public void updateDayComboGregorian() { UI window = this.getUi(); JTextField year = window.getYear(); JComboBox month = window.getMonth(); JComboBox day = window.getDay(); JButton convert = window.getToImladris(); JTextPane result = window.getResImladris(); String value = year.getText(); if (!value.isEmpty()) { try {//from w ww . ja v a2 s. co m int yearNum = Integer.parseInt(value); if (yearNum > 0 && yearNum <= GregorianInfo.MAX_SUPPORTED_YEAR) { int monthNum = month.getSelectedIndex() + 1; int daySel = 0; if (day.isEnabled()) { daySel = day.getSelectedIndex() + 1; } ArrayList<Integer> days = GregorianInfo.getInstance().getDaysArray(yearNum, monthNum); day.setModel(new DefaultComboBoxModel(days.toArray())); if (daySel > 0 && daySel <= days.size()) { day.setSelectedIndex(daySel - 1); } day.setEnabled(true); convert.setEnabled(true); result.setText(""); } else { day.setEnabled(false); convert.setEnabled(false); day.setModel(new DefaultComboBoxModel()); result.setText(""); } } catch (NumberFormatException e) { day.setEnabled(false); convert.setEnabled(false); day.setModel(new DefaultComboBoxModel()); result.setText(""); } } else { day.setEnabled(false); convert.setEnabled(false); day.setModel(new DefaultComboBoxModel()); result.setText(""); } }
From source file:main.UIController.java
@SuppressWarnings("deprecation") public void convertToImladris() { UI window = this.getUi(); String errorEmptyYear = "Please insert a year."; String errorYearNotNumeric = "Please insert the year as a numeric value."; String errorYearNotValid = "Please insert a valid year (from 1 to " + Integer.toString(GregorianInfo.MAX_SUPPORTED_YEAR) + ")."; String errorDayNotRead = "Sorry, the day could not be read."; JTextField year = window.getYear(); JComboBox month = window.getMonth(); JComboBox day = window.getDay(); JCheckBox afterSunset = window.getAfterSunset(); JTextPane result = window.getResImladris(); String value = year.getText(); if (!value.isEmpty()) { try {//from ww w . ja v a 2 s . c o m int yearNum = Integer.parseInt(value); if (yearNum > 0 && yearNum <= GregorianInfo.MAX_SUPPORTED_YEAR) { int monthNum = month.getSelectedIndex() + 1; int dayNum = 0; if (day.isEnabled()) { dayNum = day.getSelectedIndex() + 1; ImladrisCalendar cal; if (afterSunset.isSelected()) { GregorianCalendar gcal = new GregorianCalendar(yearNum, monthNum, dayNum); Time time = this.calculateSunsetForActualLocation(gcal, true); cal = new ImladrisCalendar(time, yearNum, monthNum, dayNum, time.getHours(), time.getMinutes(), time.getSeconds()); } else { cal = new ImladrisCalendar(yearNum, monthNum, dayNum); } result.setText(cal.toString()); } else { result.setText(errorDayNotRead); } } else { result.setText(errorYearNotValid); } } catch (NumberFormatException e) { result.setText(errorYearNotNumeric); } } else { result.setText(errorEmptyYear); } }
From source file:org.cds06.speleograph.graph.ValueAxisEditor.java
/** * {@inheritDoc}/*w ww .j a va 2 s .c om*/ */ @Override protected void setup() { PanelBuilder builder = new PanelBuilder(getFormLayout(), getPanel()); CellConstraints cc = new CellConstraints(); Dimension d = maxModifier.getPreferredSize(); maxModifier.setPreferredSize(new Dimension(d.width + 50, d.height)); d = minModifier.getPreferredSize(); minModifier.setPreferredSize(new Dimension(d.width + 50, d.height)); { builder.add(new JLabel("Titre de l'axe :")); final JTextField axisTitleField = new JTextField(); axisTitleField.setText(axis.getLabel()); builder.nextColumn(2); builder.add(axisTitleField, cc.xyw(3, 1, 5)); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = axisTitleField.getText(); if (text != null && !text.equals("")) axis.setLabel(axisTitleField.getText()); } }); } { builder.nextLine(2); builder.add(new JLabel("Valeur min. :")); builder.nextColumn(2); builder.add(lowField); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Double value = Double.valueOf(lowField.getText()); if (isApply) { axis.setLowerBound(value); } else if (isCancel && oldLowValue != null) axis.setLowerBound(oldLowValue); } catch (NumberFormatException e1) { canClose = false; JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(), "'" + lowField.getText() + "' n'est pas un nombre", "Erreur", JOptionPane.ERROR_MESSAGE); } } }); builder.nextColumn(2); builder.add(new JLabel("+")); builder.nextColumn(2); builder.add(minModifier); } { builder.nextLine(2); builder.add(new JLabel("Valeur max. :")); builder.nextColumn(2); builder.add(maxField); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Double value = Double.valueOf(maxField.getText()); if (isApply) { axis.setUpperBound(value); } else if (isCancel && oldHighValue != null) axis.setUpperBound(oldHighValue); } catch (NumberFormatException e1) { canClose = false; JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(), "'" + maxField.getText() + "' n'est pas un nombre", "Erreur", JOptionPane.ERROR_MESSAGE); } } }); builder.nextColumn(2); builder.add(new JLabel("+")); builder.nextColumn(2); builder.add(maxModifier); } { builder.nextLine(2); builder.add(new JLabel("<HTML><strong>Sries associes l'axe</strong></HTML>"), cc.xyw(1, 7, 3)); String linkedSeries = "<html><ul>"; for (Series series : Series.getInstances()) { if (series.getAxis().equals(axis)) linkedSeries += "<li>" + series.toString(true) + "</li>"; } linkedSeries += "</ul></html>"; builder.add(new JLabel(linkedSeries), cc.xyw(1, 8, 3)); } JPanel buttonPanel = new JPanel(); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(buttonPanel); buttonBuilder.addGlue(); { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { isCancel = true; isApply = false; canClose = true; validateForm(); } }); } { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("apply")); } @Override public void actionPerformed(ActionEvent e) { isCancel = false; isApply = true; canClose = false; validateForm(); } }); } { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { isCancel = false; isApply = true; canClose = true; validateForm(); } }); } buttonBuilder.build(); buttonPanel.setVisible(true); builder.add(buttonBuilder.getPanel(), cc.xyw(1, 10, 10)); { translateSlider.setToolTipText("Translation des axes"); translateSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int maxValue = -translateSlider.getValue(); maxModifier.setText(String.valueOf(maxValue)); int lowValue = -translateSlider.getValue(); minModifier.setText(String.valueOf(lowValue)); } }); builder.add(translateSlider, cc.xywh(9, 1, 1, 8)); } { homotSlider.setToolTipText("Homothtie sur les axes"); homotSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int maxValue = -homotSlider.getValue(); maxModifier.setText(String.valueOf(maxValue)); int lowValue = homotSlider.getValue(); minModifier.setText(String.valueOf(lowValue)); } }); builder.add(homotSlider, cc.xywh(10, 1, 1, 8)); } builder.build(); getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (canClose) setVisible(false); } }); }