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

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

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

JTextField.addActionListener介绍

暂无

代码示例

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

Action action = new AbstractAction()
{
  @Override
  public void actionPerformed(ActionEvent e)
  {
    System.out.println("some action");
  }
};

JTextField textField = new JTextField(10);
textField.addActionListener( action );

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private JPanel createSearchPanel(final FilteredJList classes) {
  JPanel search = new JPanel();
  search.setLayout(new BorderLayout());
  search.add(new JLabel("Choose a Demo to start:      Find: "),
      BorderLayout.WEST);
  final javax.swing.JTextField jtf = new javax.swing.JTextField();
  jtf.getDocument().addDocumentListener(new DocumentListener() {
    public void removeUpdate(DocumentEvent e) {
  jtf.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      selectedClass = classes.getSelectedValuesList();

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

final Object benchmarkResult = mixedCheckBox.getBenchmarkResult();
JPanel mainPanel = new JPanel(new BorderLayout());
String benchmarkResultTextFieldText = null;
if (benchmarkResult instanceof SolverBenchmarkResult) {
  benchmarkResultTextFieldText = solverBenchmarkResultNameMapping.get(benchmarkResult);
final JTextField benchmarkResultNameTextField = new JTextField(benchmarkResultTextFieldText == null ? benchmarkResult.toString()
    : benchmarkResultTextFieldText, 30);
mainPanel.add(benchmarkResultNameTextField, BorderLayout.WEST);
benchmarkResultNameTextField.addActionListener(renamedAction);
JButton confirmRenameButton = new JButton(renamedAction);
mainPanel.add(confirmRenameButton, BorderLayout.EAST);

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

private JPanel panel = new JPanel(new BorderLayout());
private JLabel lblStatus = new JLabel();
private JTextField txtURL = new JTextField();
private JProgressBar progressBar = new JProgressBar();
      loadURL(txtURL.getText());
  txtURL.addActionListener(al);
  JPanel topBar = new JPanel(new BorderLayout(5, 0));
  topBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
  topBar.add(txtURL, BorderLayout.CENTER);
  topBar.add(btnGo, BorderLayout.EAST);
  JPanel statusBar = new JPanel(new BorderLayout(5, 0));
  statusBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
  statusBar.add(lblStatus, BorderLayout.CENTER);
  statusBar.add(progressBar, BorderLayout.EAST);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);

代码示例来源:origin: skylot/jadx

public SearchBar(RSyntaxTextArea textArea) {
  rTextArea = textArea;
  JLabel findLabel = new JLabel(NLS.str("search.find") + ":");
  add(findLabel);
  searchField = new JTextField(30);
  searchField.addKeyListener(new KeyAdapter() {
    @Override
  searchField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      search(1);

代码示例来源:origin: org.openspml/openspml

public IdentifierPanel() {
setLayout(new LinearLayout(0));

  _id = new JTextField(25);
  _id.addActionListener(this);
  add(_id);
  _type = new JComboBox(NAMES);
  _type.addActionListener(this);
  add(_type);
}

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

frame.getContentPane().setLayout(new FlowLayout());
JTextField field1 = new JTextField(10);
field1.addActionListener(new Events());
frame.getContentPane().add(new JLabel("Field with no action command set"));
frame.getContentPane().add(field1);
JTextField field2 = new JTextField(10);
field2.addActionListener(new Events());
field2.setActionCommand("my action command");
frame.getContentPane().add(new JLabel("Field with an action command set"));
frame.getContentPane().add(field2);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(220, 150);
frame.setResizable(false);

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

setBackground(ColorScheme.PROGRESS_COMPLETE_COLOR);
JPanel content = new JPanel(new BorderLayout());
content.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0);
content.setBorder(new EmptyBorder(15, 15, 15, 15));
JPanel colorSelection = new JPanel(new BorderLayout(15, 0));
JPanel leftPanel = new JPanel(new BorderLayout(15, 0));
leftPanel.add(huePanel, BorderLayout.WEST);
leftPanel.add(colorPanel, BorderLayout.CENTER);
JLabel old = new JLabel("Previous");
old.setHorizontalAlignment(JLabel.CENTER);
JLabel next = new JLabel(" Current ");
next.setHorizontalAlignment(JLabel.CENTER);
JPanel hexContainer = new JPanel(new GridBagLayout());
JLabel hexLabel = new JLabel("#");
hexInput.setBackground(ColorScheme.DARKER_GRAY_COLOR);
hexInput.addActionListener((ActionEvent e) -> updateHex());

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

import acm.program.*;
import java.awt.event.*;
import javax.swing.*;

public class TextFieldExample extends GraphicsProgram {

  @Override
  public void init() {
    nameField = new JTextField(15);
    add(new JLabel("Name: "), NORTH);
    add(nameField, NORTH);
    nameField.addActionListener(this);
  }

  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == nameField) {
      println("Hello, " + nameField.getText());
    }
  }
  private JTextField nameField;
}

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

this.addMouseListener(this);
this.addFocusListener(this);
this.addActionListener(this);
setToolTipText(target.toString());
JPanel p = new JPanel(new GridLayout(0,1));
File f = new File(".","LinkLabel.java");
p.add(linkLabelFile);
p.add(linkLabelWeb);
JPanel labelConstrain = new JPanel(new BorderLayout());
labelConstrain.add( linkLabelConstrain, BorderLayout.EAST );
p.add(labelConstrain);

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

final JTextField field = new JTextField("Enter some int + press enter");
frame.add(field);
field.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);

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

setTitle("Quiz");
textField = new JTextField(10);
textField.addActionListener(this);
    typedText = textField.getText();
    String ucText = typedText.toUpperCase();
    if (magicWord.equals(ucText)) {

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

import java.awt.event.*;
import javax.swing.*;

public class TestTextField {

  public static void main(String[] args) {
    final JTextField field = new JTextField(15);
    field.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e) {
        System.out.println("Enter Pressed: " + field.getText());
      }
    });
    JOptionPane.showMessageDialog(null, field);
  }
}

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

private JTextField tfield = new JTextField(10);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  tarea.setText("Hello there\n");
  tarea.append("Hello student://");
  JScrollPane scroll = new JScrollPane(tarea);
  tfield.addActionListener(new ActionListener()
      tarea.append(tfield.getText() + "\n");
      int startOffset = tarea.viewToModel(new Point(x, y));
      System.out.println("Start Offset : " + startOffset);
      String text = tarea.getText();
      int searchLocation = text.indexOf("student://", startOffset);
      System.out.println("Search Location : " + searchLocation);
  getContentPane().add(scroll, BorderLayout.CENTER);
  getContentPane().add(tfield, BorderLayout.PAGE_END);
  pack();
  setLocationByPlatform(true);
  setVisible(true);

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

jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
urlTextField = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
openButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
urlTextField.addActionListener(evt -> urlTextFieldActionPerformed(evt));
getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);

代码示例来源:origin: bobbylight/RSyntaxTextArea

public FindAndReplaceDemo() {
 JPanel cp = new JPanel(new BorderLayout());
 searchField = new JTextField(30);
 toolBar.add(searchField);
 final JButton nextButton = new JButton("Find Next");
 nextButton.addActionListener(this);
 toolBar.add(nextButton);
 searchField.addActionListener(new ActionListener() {
   @Override
  public void actionPerformed(ActionEvent e) {

代码示例来源:origin: magefree/mage

lblServer = new javax.swing.JLabel();
lblPort = new javax.swing.JLabel();
lblUserName = new javax.swing.JLabel();
lblPassword = new javax.swing.JLabel();
txtUserName = new javax.swing.JTextField();
txtPassword = new javax.swing.JPasswordField();
btnRegister = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
lblStatus = new javax.swing.JLabel();
txtServer = new javax.swing.JTextField();
txtPort = new javax.swing.JTextField();
txtEmail = new javax.swing.JTextField();
lblPasswordConfirmation = new javax.swing.JLabel();
lblPassword.setText("Password:");
txtUserName.addActionListener(evt -> txtUserNameActionPerformed(evt));

代码示例来源:origin: org.openspml/openspml

public RequestIdPanel() {
setLayout(new LinearLayout(0));

  _id = new JTextField(25);
  _id.addActionListener(this);
  add(_id);
  _async = new LabeledCheckbox("Asynchronous");
  _async.addActionListener(this);
  add(_async);
}

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

frame.setLayout(new GridLayout(2, 2));
final JTextField user = new JTextField();
final JTextField pass = new JTextField();
user.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
pass.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
frame.add(new JLabel("User:"));
frame.add(user);
frame.add(new JLabel("Password:"));
frame.add(pass);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);

代码示例来源:origin: winder/Universal-G-Code-Sender

scrollWindowCheckBox = new javax.swing.JCheckBox();
bottomTabbedPane = new javax.swing.JTabbedPane();
commandsPanel = new javax.swing.JPanel();
commandLabel = new javax.swing.JLabel();
commandTextField = new com.willwinder.universalgcodesender.uielements.components.CommandTextArea(backend);
consoleScrollPane = new javax.swing.JScrollPane();
commandTable = new com.willwinder.universalgcodesender.uielements.components.GcodeTable();
controlContextTabbedPane = new javax.swing.JTabbedPane();
machineControlPanel = new javax.swing.JPanel();
actionPanel = new javax.swing.JPanel();
resetCoordinatesButton = new javax.swing.JButton();
returnToZeroButton = new javax.swing.JButton();
opencloseButton = new javax.swing.JButton();
refreshButton = new javax.swing.JButton();
baudLabel = new javax.swing.JLabel();
portLabel = new javax.swing.JLabel();
firmwareLabel = new javax.swing.JLabel();
firmwareComboBox = new javax.swing.JComboBox();
commandsPanel.add(commandLabel, gridBagConstraints);
commandTextField.addActionListener(new java.awt.event.ActionListener() {
  public void actionPerformed(java.awt.event.ActionEvent evt) {
    commandTextFieldActionPerformed(evt);

相关文章

微信公众号

最新文章

更多

JTextField类方法