当前位置: 首页>>代码示例>>Java>>正文


Java TextField.setText方法代码示例

本文整理汇总了Java中java.awt.TextField.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setText方法的具体用法?Java TextField.setText怎么用?Java TextField.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.TextField的用法示例。


在下文中一共展示了TextField.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import java.awt.TextField; //导入方法依赖的package包/类
@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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:SelectionVisible.java

示例2: OverScrollTest

import java.awt.TextField; //导入方法依赖的package包/类
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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:OverScrollTest.java

示例3: fixtext

import java.awt.TextField; //导入方法依赖的package包/类
private void fixtext(final TextField textfield) {
    String string = textfield.getText();
    string = string.replace('\"', '#');
    final String string330 = "\\";
    String string331 = "";
    int i = 0;
    int i332 = -1;
    rd.setFont(new Font("Arial", 1, 12));
    ftm = rd.getFontMetrics();
    for (/**/; i < string.length(); i++) {
        final String string333 = "" + string.charAt(i);
        if (string333.equals("|") || string333.equals(",") || string333.equals("(") || string333.equals(")") || string333.equals("#") || string333.equals(string330) || string333.equals("!") || string333.equals("?") || string333.equals("~") || string333.equals(".") || string333.equals("@") || string333.equals("$") || string333.equals("%") || string333.equals("^") || string333.equals("&") || string333.equals("*") || string333.equals("+") || string333.equals("=") || string333.equals(">") || string333.equals("<") || string333.equals("/") || string333.equals(";") || string333.equals(":") || ftm.stringWidth(string331) > 274) {
            i332 = i;
        } else {
            string331 = "" + string331 + string333;
        }
    }
    if (i332 != -1) {
        textfield.setText(string331);
        textfield.select(i332, i332);
    }
}
 
开发者ID:uwx,项目名称:OpenNFMM,代码行数:23,代码来源:StageMaker.java

示例4: fixtext

import java.awt.TextField; //导入方法依赖的package包/类
private void fixtext(final TextField textfield) {
    String string = textfield.getText();
    string = string.replace('\"', '#');
    final String string64 = "\\";
    String string65 = "";
    int i = 0;
    int i66 = -1;
    for (/**/ ; i < string.length(); i++) {
        final String string67 = "" + string.charAt(i);
        if (string67.equals("|") || string67.equals(",") || string67.equals("(") || string67.equals(")") || string67.equals("#") || string67.equals(string64) || string67.equals("!") || string67.equals("?") || string67.equals(" ") || string67.equals("~") || string67.equals("$") || string67.equals("%") || string67.equals("^") || string67.equals("&") || string67.equals("*") || string67.equals("+") || string67.equals("=") || string67.equals(">") || string67.equals("<") || string67.equals("/") || string67.equals("'") || string67.equals(";") || string67.equals(":") || string67.equals("\u00a0")) {
            i66 = i;
        } else {
            string65 = "" + string65 + string67;
        }
    }
    if (i66 != -1) {
        textfield.setText(string65);
        textfield.select(i66, i66);
    }
}
 
开发者ID:uwx,项目名称:OpenNFMM,代码行数:21,代码来源:Login.java

示例5: fixtext

import java.awt.TextField; //导入方法依赖的package包/类
private void fixtext(final TextField textfield) {
    String string = textfield.getText();
    string = string.replace('\"', '#');
    final String string360 = "\\";
    String string361 = "";
    int i = 0;
    int i362 = -1;
    for (/**/; i < string.length(); i++) {
        final String string363 = "" + string.charAt(i);
        if (string363.equals("|") || string363.equals(",") || string363.equals("(") || string363.equals(")") || string363.equals("#") || string363.equals(string360) || string363.equals("!") || string363.equals("?") || string363.equals("~") || string363.equals(".") || string363.equals("@") || string363.equals("$") || string363.equals("%") || string363.equals("^") || string363.equals("&") || string363.equals("*") || string363.equals("+") || string363.equals("=") || string363.equals(">") || string363.equals("<") || string363.equals("/") || string363.equals("'") || string363.equals(";") || string363.equals(":") || i > 15) {
            i362 = i;
        } else {
            string361 = "" + string361 + string363;
        }
    }
    if (i362 != -1) {
        textfield.setText(string361);
        textfield.select(i362, i362);
    }
}
 
开发者ID:uwx,项目名称:OpenNFMM,代码行数:21,代码来源:CarMaker.java

示例6: mouseClicked

import java.awt.TextField; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e)
{
	if (e.getClickCount() > 1) // Double-click
	{
		TextField text;
		String title;
		if (e.getSource() == text1)
		{
			text = text1;
			title = "Coordinate_file_1";
		}
		else
		{
			text = text2;
			title = "Coordinate_file_2";
		}
		String[] path = decodePath(text.getText());
		OpenDialog chooser = new OpenDialog(title, path[0], path[1]);
		if (chooser.getFileName() != null)
		{
			text.setText(chooser.getDirectory() + chooser.getFileName());
		}
	}
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:25,代码来源:FileMatchCalculator.java

示例7: mouseClicked

import java.awt.TextField; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e)
{
	if (e.getClickCount() > 1 && e.getSource() instanceof TextField) // Double-click
	{
		TextField tf = (TextField) e.getSource();
		String path = tf.getText();
		boolean recording = Recorder.record;
		Recorder.record = false;
		if (tf == textParamFile)
		{
			path = Utils.getFilename("Choose_a_parameter_file", path);
		}
		else
		{
			path = Utils.getDirectory("Choose_a_directory", path);
		}
		Recorder.record = recording;
		if (path != null)
			tf.setText(path);
	}
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:22,代码来源:FindFoci.java

示例8: initTestWindow

import java.awt.TextField; //导入方法依赖的package包/类
public static void initTestWindow() {
    mainFrame = new Frame("ScrollSelectionTest frame");
    mainFrame.setBounds(500, 0, 400, 200);

    textField = new TextField(40);
    textField.setText("abcdefghijklmnopqrstuvwxyz");
    mainFrame.add(textField);
    mainFrame.setLayout(new FlowLayout());
    textField.select(0, 20);
    mainFrame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ScrollSelectionTest.java

示例9: testConstructor2

import java.awt.TextField; //导入方法依赖的package包/类
private void testConstructor2() {
    textField = new TextField(30);
    textField.setSize(200, 100);
    mainFrame.add(textField);
    textField.setText(testStrEOL);
    checkTest();
    mainFrame.remove(textField);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:EOLTest.java

示例10: testSetText

import java.awt.TextField; //导入方法依赖的package包/类
private void testSetText() {
    textField = new TextField();
    textField.setSize(200, 100);
    textField.setText(testStrEOL);
    mainFrame.add(textField);
    checkTest();
    mainFrame.remove(textField);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:EOLTest.java

示例11: dialogItemChanged

import java.awt.TextField; //导入方法依赖的package包/类
@Override
public boolean dialogItemChanged(final GenericDialog gd, final AWTEvent e) {
	if (!DialogModifier.allNumbersValid(gd.getNumericFields()))
		return false;
	final Vector<?> checkboxes = gd.getCheckboxes();
	final Vector<?> nFields = gd.getNumericFields();
	final Checkbox calibration = (Checkbox) checkboxes.get(10);
	final boolean isHUCalibrated = calibration.getState();
	final TextField minT = (TextField) nFields.get(0);
	final TextField maxT = (TextField) nFields.get(1);

	final double min = Double.parseDouble(minT.getText());
	final double max = Double.parseDouble(maxT.getText());
	if (isHUCalibrated && !fieldUpdated) {
		minT.setText("" + cal.getCValue(min));
		maxT.setText("" + cal.getCValue(max));
		fieldUpdated = true;
	}
	if (!isHUCalibrated && fieldUpdated) {
		minT.setText("" + cal.getRawValue(min));
		maxT.setText("" + cal.getRawValue(max));
		fieldUpdated = false;
	}
	if (isHUCalibrated)
		DialogModifier.replaceUnitString(gd, "grey", "HU");
	else
		DialogModifier.replaceUnitString(gd, "HU", "grey");

	final Checkbox oriented = (Checkbox) checkboxes.get(9);
	if (orienteer == null) {
		oriented.setState(false);
		oriented.setEnabled(false);
	} else
		oriented.setEnabled(true);

	DialogModifier.registerMacroValues(gd, gd.getComponents());
	return true;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:39,代码来源:SliceGeometry.java

示例12: handleName

import java.awt.TextField; //导入方法依赖的package包/类
protected synchronized void handleName(NameCallback c)
{
  Frame ownerFrame = new Frame();
  Dialog dialog = new Dialog(ownerFrame);
  dialog.setTitle(c.getPrompt());
  dialog.setLayout(new GridLayout(3, 1));
  Label label = new Label(c.getPrompt());
  TextField input = new TextField();
  if (c.getDefaultName() != null)
    {
      input.setText(c.getDefaultName());
    }
  Panel buttons = new Panel();
  Button ok = new Button(messages.getString("callback.ok"));
  ok.setActionCommand(ACTION_OK);
  ok.addActionListener(this);
  Button cancel = new Button(messages.getString("callback.cancel"));
  cancel.setActionCommand(ACTION_CANCEL);
  cancel.addActionListener(this);
  dialog.add(label);
  dialog.add(input);
  buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
  buttons.add(ok);
  buttons.add(cancel);
  dialog.add(buttons);
  dialog.pack();
  dialog.show();
  try { wait(); }
  catch (InterruptedException ie) { }
  if (actionCommand.equals(ACTION_OK))
    {
      c.setName(input.getText());
    }
  dialog.dispose();
  ownerFrame.dispose();
}
 
开发者ID:vilie,项目名称:javify,代码行数:37,代码来源:AWTCallbackHandler.java

示例13: validateFloatEdit

import java.awt.TextField; //导入方法依赖的package包/类
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;                
    }                             
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:40,代码来源:NoteEditor.java

示例14: validateIntegerEdit

import java.awt.TextField; //导入方法依赖的package包/类
private static boolean validateIntegerEdit(
            TextField   theField,
            int         minValue,
            int         maxValue) {
    StringTokenizer fieldTokenizer                    
        = new StringTokenizer(theField.getText());
    if (!fieldTokenizer.hasMoreElements()) {
        theField.setText("Error--No Data");
        return false;
    }                    
    else {
        String fieldString = 
                fieldTokenizer.nextToken();             
        try {
            int fieldValue = 
                new Integer(fieldString)
                    .intValue();  
            if (fieldValue < minValue ) {
                theField.setText("Value Too Low");
                return false;
            }                                                          
            else if (fieldValue > maxValue ) {
                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;                
    }                             
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:40,代码来源:NoteEditor.java

示例15: createTextPanel

import java.awt.TextField; //导入方法依赖的package包/类
private Panel createTextPanel(TextField textField, String label, String value)
{
	Panel panel = new Panel();
	panel.setLayout(new BorderLayout());
	Label listLabel = new Label(label, 0);
	//listLabel.setFont(monoFont);
	//textField.setSize(fontWidth * 3, fontWidth);
	textField.setText(value);
	panel.add(listLabel, BorderLayout.WEST);
	panel.add(textField, BorderLayout.CENTER);
	return panel;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:13,代码来源:SpotAnalysis.java


注:本文中的java.awt.TextField.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。