java.awt.TextField#setText ( )源码实例Demo

下面列出了java.awt.TextField#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: SelectionVisible.java
@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);
}
 
源代码2 项目: TencentKona-8   文件: SelectionVisible.java
@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);
}
 
源代码3 项目: openjdk-jdk8u   文件: SelectionVisible.java
@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);
}
 
源代码4 项目: openjdk-jdk8u-backup   文件: SelectionVisible.java
@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);
}
 
源代码5 项目: openjdk-jdk9   文件: OverScrollTest.java
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();
}
 
源代码6 项目: jdk8u-jdk   文件: SelectionVisible.java
@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);
}
 
源代码7 项目: hottub   文件: SelectionVisible.java
@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);
}
 
源代码8 项目: openjdk-8-source   文件: SelectionVisible.java
@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);
}
 
源代码9 项目: jdk8u_jdk   文件: SelectionVisible.java
@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);
}
 
源代码10 项目: jdk8u-dev-jdk   文件: SelectionVisible.java
@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);
}
 
源代码11 项目: jmg   文件: NoteEditor.java
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;                
    }                             
}
 
源代码12 项目: openjdk-jdk9   文件: EOLTest.java
private void testConstructor2() {
    textField = new TextField(30);
    textField.setSize(200, 100);
    mainFrame.add(textField);
    textField.setText(testStrEOL);
    checkTest();
    mainFrame.remove(textField);
}
 
源代码13 项目: openjdk-jdk9   文件: EOLTest.java
private void testSetText() {
    textField = new TextField();
    textField.setSize(200, 100);
    textField.setText(testStrEOL);
    mainFrame.add(textField);
    checkTest();
    mainFrame.remove(textField);
}
 
源代码14 项目: pdfxtk   文件: LoginRequester.java
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();
}
 
源代码15 项目: jmg   文件: NoteEditor.java
private static void initializeDoubleEdit(
                        TextField theEdit,
                        double    theValue ) {
    theEdit.setText(decimalFormat.format(theValue));                                            
}
 
源代码16 项目: jmg   文件: NoteEditor.java
private static void initializeIntEdit(
                        TextField theEdit,
                        int       theValue ) {
    theEdit.setText(
            new Integer(theValue).toString());                                            
}
 
源代码17 项目: Scripts   文件: SnippetCreator.java
@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;
}
 
源代码18 项目: ij-ridgedetection   文件: ResetToDefaultListener.java
@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);

}
 
源代码19 项目: ij-ridgedetection   文件: Lines_.java
@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;
}
 
源代码20 项目: SNT   文件: SWCImportOptionsDialog.java
protected void enableTextField(final TextField tf, final boolean enabled, final String defaultValue) {
	tf.setEnabled(enabled);
	tf.setVisible(enabled);
	if (!enabled)
		tf.setText(defaultValue);
}