Java Code Examples for java.awt.TextField#setText()
The following examples show how to use
java.awt.TextField#setText() .
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: SelectionVisible.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 2
Source File: SelectionVisible.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 3
Source File: SelectionVisible.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 4
Source File: SelectionVisible.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 5
Source File: SelectionVisible.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 6
Source File: SelectionVisible.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 7
Source File: OverScrollTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
OverScrollTest() { try { robot = new Robot(); } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); } mainFrame = new Frame(); mainFrame.setSize(400, 200); mainFrame.setLocation(200, 200); mainFrame.setLayout(new FlowLayout()); textField = new TextField(10); textField.setSize(300, 100); textField.setText("123456 789123"); mainFrame.add(textField); mainFrame.setVisible(true); textField.requestFocusInWindow(); }
Example 8
Source File: SelectionVisible.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 9
Source File: SelectionVisible.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 10
Source File: SelectionVisible.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 11
Source File: EOLTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void testSetText() { textField = new TextField(); textField.setSize(200, 100); textField.setText(testStrEOL); mainFrame.add(textField); checkTest(); mainFrame.remove(textField); }
Example 12
Source File: EOLTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void testConstructor2() { textField = new TextField(30); textField.setSize(200, 100); mainFrame.add(textField); textField.setText(testStrEOL); checkTest(); mainFrame.remove(textField); }
Example 13
Source File: NoteEditor.java From jmg with GNU General Public License v2.0 | 5 votes |
private static boolean validateFloatEdit( TextField theField, double minValue, double maxValue) { StringTokenizer fieldTokenizer = new StringTokenizer(theField.getText()); if (!fieldTokenizer.hasMoreElements()) { theField.setText("Error--No Data"); return false; } else { String fieldString = fieldTokenizer.nextToken(); try { double fieldValue = new Double(fieldString) .doubleValue(); if (fieldValue < minValue ) { theField.setText("Value Too Low"); return false; } else if (fieldValue < minValue ) { theField.setText("Value Too High"); return false; } } catch (Throwable e ) { theField.setText("Data Error"); return false; } } if (fieldTokenizer.hasMoreElements()) { theField.setText("Data Error"); return false; } else { return true; } }
Example 14
Source File: LoginRequester.java From pdfxtk with Apache License 2.0 | 5 votes |
public LoginRequester(Frame parent, String title, String user_label, String password_label, String posText_, String negText) { super(parent, title, true); setLayout(new GridBagLayout()); posText = posText_; add(new Label(user_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL)); u_text = new TextField(30); try{u_text.setText(System.getProperty("user.name",""));} catch(Exception e) {} add(u_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL)); add(new Label(password_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL)); p_text = new TextField(30); p_text.setEchoChar('*'); add(p_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL)); Button pos = new Button(posText); add(pos, Awt.constraints(false, 10, 4, GridBagConstraints.HORIZONTAL)); pos.addActionListener(this); Button neg = new Button(negText); add(neg, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL)); neg.addActionListener(this); pack(); }
Example 15
Source File: NoteEditor.java From jmg with GNU General Public License v2.0 | 4 votes |
private static void initializeIntEdit( TextField theEdit, int theValue ) { theEdit.setText( new Integer(theValue).toString()); }
Example 16
Source File: NoteEditor.java From jmg with GNU General Public License v2.0 | 4 votes |
private static void initializeDoubleEdit( TextField theEdit, double theValue ) { theEdit.setText(decimalFormat.format(theValue)); }
Example 17
Source File: SnippetCreator.java From Scripts with GNU General Public License v3.0 | 4 votes |
@Override public boolean dialogItemChanged(final GenericDialog gd, final AWTEvent e) { final Object source = (e == null) ? null : e.getSource(); final Vector<?> choices = gd.getChoices(); final Vector<?> fields = gd.getStringFields(); final Button[] buttons = gd.getButtons(); final Choice fChoice = (Choice) choices.elementAt(0); final TextField fField = (TextField) fields.elementAt(0); final Button okButton = buttons[0]; sFilename = gd.getNextString(); sType = gd.getNextChoiceIndex(); infoMsg = (MultiLineLabel) gd.getMessage(); // Populate text area if (source == fChoice) { String header = ""; switch (sType) { case BSH: header = bshHeader(); break; case CLJ: header = cljHeader(); break; case GRV: header = grvHeader(); break; case IJM: header = ijmHeader(); break; case JS: header = jsHeader(); break; case PY: header = pyHeader(); break; case RB: header = rbHeader(); break; } if (header != "") appendToTextArea(header); // Ensure adequate filename extension if (!sFilename.endsWith(S_EXTS[sType])) { final int index = sFilename.lastIndexOf("."); if (index > -1) sFilename = sFilename.substring(0, index); sFilename += S_EXTS[sType]; fField.setText(sFilename); } } // Adjust labels and fields final File f = new File(Utils.getMyRoutinesDir() + sFilename); final boolean invalidName = invalidFilename(sFilename); okButton.setLabel(f.exists() ? "Replace and Open" : " Create and Open "); fField.setForeground((f.exists()||invalidName) ? Color.RED : Color.BLACK); // Adjust messages final StringBuilder sb = new StringBuilder(); if (invalidName) { sb.append("\nInvalid Filename"); } else if (f.exists()) { sb.append("File already exists in BAR/My_Routines!"); } else if (sFilename.indexOf("_") == -1) { sb.append("\nFile does not contain an underscore"); sb.append("\nand will not be listed in the BAR Menu."); } else { sb.append("\nFile will be listed in the BAR Menu."); } infoMsg.setText(sb.toString()); infoMsg.setForeground(Color.DARK_GRAY); return !invalidName; }
Example 18
Source File: ResetToDefaultListener.java From ij-ridgedetection with GNU General Public License v2.0 | 4 votes |
@Override public void actionPerformed(ActionEvent arg0) { // Set settings to default TextField textLineWidth = (TextField) gd.getNumericFields().get(0); textLineWidth.setText("" + IJ.d2s(Lines_.lineWidthDefault, 2)); textLineWidth.setEditable(true); TextField textHighCon = (TextField) gd.getNumericFields().get(1); textHighCon.setText("" + IJ.d2s(Lines_.contrastHighDefault, 0)); textHighCon.setEditable(true); TextField textLowCon = (TextField) gd.getNumericFields().get(2); textLowCon.setText("" + IJ.d2s(Lines_.contrastLowDefault, 0)); textLowCon.setEditable(true); TextField textSigma = (TextField) gd.getNumericFields().get(3); textSigma.setText("" + IJ.d2s(Lines_.sigmaDefault, 2)); textSigma.setEditable(true); TextField textLowThresh = (TextField) gd.getNumericFields().get(4); textLowThresh.setText("" + IJ.d2s(Lines_.lowerThreshDefault, 2)); textLowThresh.setEditable(true); TextField textUppThresh = (TextField) gd.getNumericFields().get(5); textUppThresh.setText("" + IJ.d2s(Lines_.upperThreshDefault, 2)); textUppThresh.setEditable(true); TextField textMinLength = (TextField) gd.getNumericFields().get(6); textMinLength.setText("" + IJ.d2s(Lines_.minLengthDefault, 2)); textMinLength.setEditable(true); TextField textMaxLength = (TextField) gd.getNumericFields().get(7); textMaxLength.setText("" + IJ.d2s(Lines_.maxLengthDefault, 2)); textMaxLength.setEditable(true); ((Checkbox) gd.getCheckboxes().get(0)).setState(Lines_.isDarkLineDefault); ((Checkbox) gd.getCheckboxes().get(1)).setState(Lines_.doCorrectPositionDefault); ((Checkbox) gd.getCheckboxes().get(2)).setState(Lines_.doEstimateWidthDefault); ((Checkbox) gd.getCheckboxes().get(3)).setState(Lines_.doExtendLineDefault); ((Checkbox) gd.getCheckboxes().get(4)).setState(Lines_.showJunctionPointsDefault); ((Checkbox) gd.getCheckboxes().get(5)).setState(Lines_.showIDsDefault); ((Checkbox) gd.getCheckboxes().get(6)).setState(Lines_.verboseDefault); ((Checkbox) gd.getCheckboxes().get(7)).setState(Lines_.displayResultsDefault); ((Checkbox) gd.getCheckboxes().get(8)).setState(Lines_.addToRoiManagerDefault); ((Checkbox) gd.getCheckboxes().get(9)).setState(Lines_.makeBinaryDefault); ((Choice) gd.getChoices().get(0)).select(0); }
Example 19
Source File: Lines_.java From ij-ridgedetection with GNU General Public License v2.0 | 4 votes |
@Override public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) { imp.setOverlay(null); boolean lwChanged = false; boolean contHighChanged = false; boolean contLowChanged = false; boolean darklineChanged = false; double lwCand = gd.getNextNumber(); double diff = Math.abs(lwCand - lineWidth); if (diff > 0.0001) { lineWidth = lwCand; lwChanged = true; } double conCand = gd.getNextNumber(); diff = Math.abs(conCand - contrastHigh); if (diff > 0.0001) { contrastHigh = conCand; contHighChanged = true; } conCand = gd.getNextNumber(); diff = Math.abs(conCand - contrastLow); if (diff > 0.0001) { contrastLow = conCand; contLowChanged = true; } boolean darklineCand = gd.getNextBoolean(); if (darklineCand != isDarkLine) { isDarkLine = darklineCand; darklineChanged = true; } doCorrectPosition = gd.getNextBoolean(); doEstimateWidth = gd.getNextBoolean(); doExtendLine = gd.getNextBoolean(); showJunctionPoints = gd.getNextBoolean(); showIDs = gd.getNextBoolean(); verbose = gd.getNextBoolean(); displayResults = gd.getNextBoolean(); addToRoiManager = gd.getNextBoolean(); makeBinary = gd.getNextBoolean(); overlapOption = OverlapOption.valueOf(gd.getNextChoice()); if (lwChanged || contHighChanged || contLowChanged) { contrastOrLineWidthChangedOnce = true; } if (lwChanged || contHighChanged || contLowChanged || (darklineChanged && contrastOrLineWidthChangedOnce)) { double estimatedSigma = lineWidth / (2 * Math.sqrt(3)) + 0.5; TextField textSigma = (TextField) gd.getNumericFields().get(3); textSigma.setText("" + IJ.d2s(estimatedSigma, 2)); textSigma.setEditable(true); double clow = contrastLow; if (isDarkLine) { clow = 255 - contrastHigh; } double estimatedLowerThresh = Math.floor(Math.abs(-2 * clow * (lineWidth / 2.0) / (Math.sqrt(2 * Math.PI) * estimatedSigma * estimatedSigma * estimatedSigma) * Math.exp(-((lineWidth / 2.0) * (lineWidth / 2.0)) / (2 * estimatedSigma * estimatedSigma)))); TextField textLowThresh = (TextField) gd.getNumericFields().get(4); textLowThresh.setText("" + IJ.d2s(estimatedLowerThresh * 0.17, 2)); textLowThresh.setEditable(true); double chigh = contrastHigh; if (isDarkLine) { chigh = 255 - contrastLow; } double estimatedUpperThresh = Math.floor(Math.abs(-2 * chigh * (lineWidth / 2.0) / (Math.sqrt(2 * Math.PI) * estimatedSigma * estimatedSigma * estimatedSigma) * Math.exp(-((lineWidth / 2.0) * (lineWidth / 2.0)) / (2 * estimatedSigma * estimatedSigma)))); TextField textUppThresh = (TextField) gd.getNumericFields().get(5); textUppThresh.setText("" + IJ.d2s(estimatedUpperThresh * 0.17, 2)); textUppThresh.setEditable(true); } sigma = gd.getNextNumber(); lowerThresh = gd.getNextNumber(); upperThresh = gd.getNextNumber(); if (lowerThresh >= upperThresh || sigma < 0.4 || Double.isNaN(sigma + lowerThresh + upperThresh)) { return false; } minLength = gd.getNextNumber(); maxLength = gd.getNextNumber(); isPreview = gd.isPreviewActive(); return true; }
Example 20
Source File: SWCImportOptionsDialog.java From SNT with GNU General Public License v3.0 | 4 votes |
protected void enableTextField(final TextField tf, final boolean enabled, final String defaultValue) { tf.setEnabled(enabled); tf.setVisible(enabled); if (!enabled) tf.setText(defaultValue); }