Action action = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.out.println("some action"); } }; JTextField textField = new JTextField(10); textField.addActionListener( action );
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();
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);
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);
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);
public IdentifierPanel() { setLayout(new LinearLayout(0)); _id = new JTextField(25); _id.addActionListener(this); add(_id); _type = new JComboBox(NAMES); _type.addActionListener(this); add(_type); }
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);
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());
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; }
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);
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);
setTitle("Quiz"); textField = new JTextField(10); textField.addActionListener(this); typedText = textField.getText(); String ucText = typedText.toUpperCase(); if (magicWord.equals(ucText)) {
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); } }
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);
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);
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) {
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));
public RequestIdPanel() { setLayout(new LinearLayout(0)); _id = new JTextField(25); _id.addActionListener(this); add(_id); _async = new LabeledCheckbox("Asynchronous"); _async.addActionListener(this); add(_async); }
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);
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);