javax.swing.JTextField.setText()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(240)

本文整理了Java中javax.swing.JTextField.setText()方法的一些代码示例,展示了JTextField.setText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.setText()方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:setText

JTextField.setText介绍

暂无

代码示例

代码示例来源:origin: kiegroup/jbpm

private void addResult() {
  results.put(resultNameTextField.getText(), resultValueTextField.getText());
  resultNameTextField.setText("");
  resultValueTextField.setText("");
}

代码示例来源:origin: iluwatar/java-design-patterns

private void setup() {
 setLayout(new BorderLayout());
 JPanel panel = new JPanel();
 add(jl, BorderLayout.SOUTH);
 add(panel, BorderLayout.CENTER);
 panel.setLayout(new GridLayout(6, 2));
 panel.add(new JLabel("Name"));
 panel.add(jtFields[0]);
 panel.add(new JLabel("Contact Number"));
 panel.add(jtFields[1]);
 panel.add(new JLabel("Address"));
 panel.add(jtAreas[0]);
 panel.add(new JLabel("Deposit Number"));
 panel.add(processButton);
 clearButton.addActionListener(e -> {
  for (JTextArea i : jtAreas) {
   i.setText("");
   i.setText("");
 processButton.addActionListener(e -> {
  Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(),
    jtAreas[1].getText());
  jl.setText(sendRequest(order));

代码示例来源:origin: stanfordnlp/CoreNLP

private void doEncodingPrompt(final String encoding, final String oldEncoding) {
 final JPanel encodingPanel = new JPanel();
 encodingPanel.setLayout(new BoxLayout(encodingPanel, BoxLayout.PAGE_AXIS));
 JLabel text = new JLabel("<html>A head finder or tree reader was selected that has the default encoding " + encoding
   + "; this differs from " + oldEncoding + ", which was being used. If the encoding is changed, all newly loaded" +
   "treebanks will be read using the new encoding. Choosing an encoding that is not the true encoding of your tree " +
 JPanel textPanel = new JPanel(new BorderLayout());
 textPanel.setPreferredSize(new Dimension(100,100));
 textPanel.add(text);
 encodingPanel.add(textPanel);
 encodingPanel.add(Box.createVerticalStrut(5));
 final JOptionPane fileFilterDialog = new JOptionPane();
 fileFilterDialog.setMessage(encodingPanel);
 JButton[] options = new JButton[3];
 JButton useNewEncoding = new JButton("Use " + encoding);
 JButton useOldEncoding = new JButton("Use " + oldEncoding);
 JButton useAnotherEncoding = new JButton("Use encoding...");
 useNewEncoding.addActionListener(arg0 -> {
  FileTreeModel.setCurEncoding(encoding);
  if(setEncoding == null)
   System.out.println("encoding null!!");
  setEncoding.setText(encoding);
  dialog.setVisible(false);
 });
 useOldEncoding.addActionListener(e -> dialog.setVisible(false));
 useAnotherEncoding.addActionListener(e -> {

代码示例来源:origin: deathmarine/Luyten

this.setHideOnEscapeButton();
JLabel label = new JLabel("Find What:");
textField = new JTextField();
  textField.setText(pane.getSelectedText());
wrap = new JCheckBox("Wrap");
findButton = new JButton("Find");
findButton.addActionListener(new FindButton());
this.getRootPane().setDefaultButton(findButton);

代码示例来源:origin: ballerina-platform/ballerina-lang

private JPanel createArtifactRow(final String ext, final String serv, final String mainClass, final String args) {
  final JLabel extLabel = new JLabel(EXT_LABEL);
  final JTextField extField = new JTextField();
  extField.setToolTipText(EXT_TOOLTIP);
  extField.setText(ext);
  final JLabel packgeLabel = new JLabel("Artifact");
  final JTextField packgeField = new JTextField();
  packgeField.setToolTipText("e.g. ch.epfl.lamp:dotty-language-server_0.3:0.3.0-RC2");
  packgeField.setText(serv);
  final JLabel mainClassLabel = new JLabel("Main class");
  final JTextField mainClassField = new JTextField();
  mainClassField.setToolTipText("e.g. dotty.tools.languageserver.Main");
  mainClassField.setText(mainClass);
  final JLabel argsLabel = new JLabel("Args");
  final JTextField argsField = new JTextField();
  argsField.setToolTipText("e.g. -stdio");
  argsField.setText(args);
  final List<JComponent> components = Arrays.asList(extLabel, extField, packgeLabel, packgeField, mainClassLabel, mainClassField, argsLabel, argsField);
  final JPanel panel = createRow(components, ArtifactLanguageServerDefinition$.MODULE$.getPresentableTyp());
  final scala.collection.mutable.LinkedHashMap<String, JComponent> map = new scala.collection.mutable.LinkedHashMap<>();
  map.put(EXT, extField);
  map.put(PACKGE, packgeField);
  map.put(MAINCLASS, mainClassField);
  map.put(ARGS, argsField);
  rows.add(new ServersGUIRow(panel, ArtifactLanguageServerDefinition$.MODULE$.typ(), map));
  return panel;
}

代码示例来源:origin: kousen/java_8_recipes

public MyUI() {
  super(new BorderLayout());
  JPanel north = new JPanel();
  north.add(source);
  north.add(destination);
  JPanel south = new JPanel();
  JButton go = new JButton("Go!");
  south.add(go);
  String greeting = "Hello, %s!";
  go.addActionListener(e -> destination.setText(
      String.format(greeting, source.getText())));
  this.add(north, BorderLayout.NORTH);
  this.add(south, BorderLayout.SOUTH);
}

代码示例来源:origin: stackoverflow.com

final JTextField textField = new JTextField("cat");
JButton button = new JButton("Click");
// Code
button.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        if(textField.getText().equals("cat")) {
          textField.setText("Changes");
        } else {
          textField.setText("Already Changed");
        }
      }
    });

代码示例来源:origin: stackoverflow.com

JTabbedPane tabbePane = new JTabbedPane();
JPanel  panel1 = new JPanel();
JPanel panel2 = new JPanel();
JTextField  field = new JTextField();
JButton  button = new JButton();

tabbedPane.addTab("tab1", panel1);

field.setText("Your text here");
panel2.add(field);

button.setText("Save");
panel2.add(button);

tabbePane.addTab("tab2", panel2);

代码示例来源:origin: stackoverflow.com

final JTextField textField = new JTextField("Enabled");
final JCheckBox checkBox = new JCheckBox("Enable", true);
checkBox.addItemListener(new ItemListener(){
    if(e.getStateChange() == ItemEvent.SELECTED){
      textField.setEnabled(true);
      textField.setText("Enabled");
      textField.setText("Disabled");

代码示例来源:origin: dboissier/mongo4idea

@NotNull
private JPanel createRowLimitPanel() {
  rowLimitField.setText(Integer.toString(configuration.getDefaultRowLimit()));
  rowLimitField.setColumns(5);
  rowLimitField.setDocument(new NumberDocument());
  rowLimitField.setText(Integer.toString(configuration.getDefaultRowLimit()));
  JPanel rowLimitPanel = new NonOpaquePanel();
  rowLimitPanel.add(new JLabel("Row limit:"), BorderLayout.WEST);
  rowLimitPanel.add(rowLimitField, BorderLayout.CENTER);
  rowLimitPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST);
  return rowLimitPanel;
}

代码示例来源:origin: stackoverflow.com

public class Console extends JFrame {
  private static JTextField consoleTextField;

  public Console() {
    consoleTextField = new JTextField();
    // ...
  }

  public static feedChar(char c) {
    consoleTextField.setText(consoleTextField.getText() + c.toString());
  }
}

代码示例来源:origin: stackoverflow.com

JTextField text=new JTextField();
text.setText("this is textfield");
text.setBounds(20,0,100,20);
JPanel panel=new JPanel();
panel.addLayout(new FlowLayout());
panel.setBackground(Color.blue);
panel.add(text);

代码示例来源:origin: libgdx/libgdx

sdkLocationText.setText(System.getenv("ANDROID_HOME"));
sdkLocationText.setText(prefs.getString("ANDROID_HOME"));
  checkBox.setSelected(true);
subProjectsPanel.add(checkBox);
checkBox.addItemListener(new ItemListener() {
  @Override
JPanel extensionPanel = new JPanel(new GridLayout(1, 5));
while (depCounter < ProjectDependency.values().length) {
  if (ProjectDependency.values()[depCounter] != null) {
      depCheckBox.setSelected(true);
    extensionPanel.add(depCheckBox);
    depCheckBox.addItemListener(new ItemListener() {
      @Override
  extensionPanel.add(Box.createHorizontalBox());

代码示例来源:origin: stackoverflow.com

final JTextField input1;
 ...
 final ActionListener l = new ActionListener() {
   @Override
   public void actionPerformed(ActionEvent e) {
     input1.setText(input1.getText() + ((JButton) e.getSource()).getText());
   }
 };
 for (char c = 'A'; c <= 'Z'; c++) {
   final JButton jButton = new JButton(String.valueOf(c));
   panel.add(jButton);
   jButton.addActionListener(l);
 }

代码示例来源:origin: libgdx/libgdx

gamePanel.add(rendererCanvas.getCanvas());
  backgroundColor.getBlue() / 255f, 1);
fontList.setSelectedValue(prefs.get("system.font", "Arial"), true);
fontFileText.setText(prefs.get("font.file", ""));

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

textTranslationKey.setText(defaultKey);
getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(e -> onOK());
buttonCancel.addActionListener(e -> onCancel());
tableView.setModelAndUpdateColumns(listTableModel);
panelTableView.add(ToolbarDecorator.createDecorator(tableView)
  .disableAddAction()
  .disableDownAction()

代码示例来源:origin: stackoverflow.com

String fieldContents = "";

JTextField field = new JTextField;

ActionListener acLi = new ActionListener() {
 public void actionPerformed(ActionEvent ae) {
  JButton btn = (JButton) ae.getSource();
  fieldContents += btn.getText();
  field.setText(fieldContents);
 }
};

JButton button0 = new JButton("0");
button0.addActionListener(acLi);
...
JButton button9 = new JButton("9");
button9.addActionListener(acLi);

代码示例来源:origin: stackoverflow.com

final JTextField textField = new JTextField(20);
final JFrame frame = new JFrame("Test JFrame");
JButton button = new JButton(
   new AbstractAction("Press Me to Show Dialog") {
     @Override
     public void actionPerformed(ActionEvent arg0) {                  
      String result = JDialogTest.getInput("Get Input", frame);
      textField.setText(result);
     }
   });

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(e -> onSave());
buttonCancel.addActionListener(e -> onCancel());
buttonTest.addActionListener(e -> {
  try {
    Object eval = JavascriptServiceNameStrategy.run(project, textClass.getText(), textJavascript.getText());
    if(!(eval instanceof String)) {
      textResult.setText("Error: invalid string response");
      return;
    textResult.setText((String) eval);
  } catch (ScriptException e1) {
    textResult.setText("Error: " + e1.getMessage());

代码示例来源:origin: opentripplanner/OpenTripPlanner

private void initRoutingSubpanel() {
  JPanel routingPanel = new JPanel();
  routingPanel.setLayout(new GridLayout(0, 2));
  leftPanel.add(routingPanel, BorderLayout.NORTH);
  JButton setSourceVertexButton = new JButton("set source");
  setSourceVertexButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      Object selected = nearbyVertices.getSelectedValue();
  routingPanel.add(setSourceVertexButton);
  sourceVertex = new JTextField();
  routingPanel.add(sourceVertex);
  routingPanel.add(setSinkVertexButton);
  sinkVertex = new JTextField();
  routingPanel.add(sinkVertex);
  routingPanel.add(resetSearchDateButton);
  searchDate = new JTextField();
  searchDate.setText(dateFormat.format(new Date()));
  routingPanel.add(searchDate);
  searchTimeElapsedLabel = new JLabel("search time elapsed:");
  routingPanel.add(searchTimeElapsedLabel);

相关文章

JTextField类方法