List of usage examples for java.awt.event KeyAdapter KeyAdapter
KeyAdapter
From source file:edu.ku.brc.af.ui.forms.validation.ValTextArea.java
public void init() { bgColor = getBackground();/* w ww . j a v a 2 s .co m*/ if (valTextColor == null || requiredFieldColor == null) { valTextColor = AppPrefsCache.getColorWrapper("ui", "formatting", "valtextcolor"); requiredFieldColor = AppPrefsCache.getColorWrapper("ui", "formatting", "requiredfieldcolor"); } AppPrefsCache.addChangeListener("ui.formatting.requiredfieldcolor", this); initDocument(); addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { isNew = false; repaint(); } }); // Enable being able to TAB out of TextArea getInputMap().put(KeyStroke.getKeyStroke("TAB"), "none"); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_TAB) { if (event.isShiftDown()) { transferFocusBackward(); } else { transferFocus(); } } } }); }
From source file:experiments.SimpleExample.java
public void runga(int ng, int chromeSize, int popsize, double left, double right, FitnessFunction fitnessfun, BufferedWriter output) {/* w w w . j a v a 2 s. c o m*/ long startTime = System.currentTimeMillis(); int numEvolutions = ng; Configuration gaConf = new DefaultConfiguration(); gaConf.reset(); gaConf.setPreservFittestIndividual(true); gaConf.setKeepPopulationSizeConstant(false); gaConf.getGeneticOperators().clear(); try { gaConf.addGeneticOperator(new MutationOperator(gaConf, new KeyboardMutationRateCalc(gaConf, 0.01, 0.1, 0.05, chromeSize))); gaConf.addGeneticOperator(new CrossoverOperator(gaConf, new KeyboardCrossoverRateCalc(gaConf, 0.7, 0.99, 0.8, chromeSize))); } catch (InvalidConfigurationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Genotype genotype = null; try { //(Gene) Gene[] sampleGenes = new Gene[chromeSize];//2 for (int i = 0; i < sampleGenes.length; i++) { sampleGenes[i] = new DoubleGene(gaConf, left, right); } // (Chromosome) IChromosome sampleChromosome = new Chromosome(gaConf, sampleGenes); gaConf.setSampleChromosome(sampleChromosome); gaConf.setPopulationSize(popsize); gaConf.setFitnessFunction(fitnessfun); genotype = Genotype.randomInitialGenotype(gaConf); } catch (InvalidConfigurationException e) { e.printStackTrace(); System.exit(-2); } // JOptionPane.showMessageDialog(frame.getContentPane(), // "?ing!", "?", JOptionPane.INFORMATION_MESSAGE); JFreeChart jfc = createChart(); frame = new JFrame("Test Chart"); frame.getContentPane().add(new ChartPanel(jfc), new BorderLayout().CENTER); frame.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int ch = e.getKeyCode(); switch (ch) { case KeyEvent.VK_ENTER: flag = false; break; case KeyEvent.VK_SPACE: flag2 = !flag2; break; case 37: Older.downc(); break; case 38: Older.downm(); break; case 39: Older.upc(); break; case 40: Older.upm(); break; default: break; } } }); frame.pack(); frame.setVisible(true); int progress = 0; int percentEvolution = numEvolutions / 10; int i = 0; while (flag) { // for (int i = 0; i < numEvolutions; i++) { if (flag2) { genotype.evolve(); IChromosome fittest = genotype.getFittestChromosome(); double fitness = fittest.getFitnessValue(); fitlist.add(fitness); jfc = createChart(); frame.getContentPane().removeAll(); frame.getContentPane().add(new ChartPanel(jfc), new BorderLayout().CENTER); frame.pack(); frame.setVisible(true); System.out.println("mutation: " + Older.old_mutation); System.out.println("crossover: " + Older.old_crossover); // Print progress. // --------------- if (percentEvolution > 0 && i % percentEvolution == 0) { progress++; System.out.println("Currently fittest Chromosome has fitness " + fitness); } } i++; // if(i>15000)break; } // Print summary. // -------------- IChromosome fittest = genotype.getFittestChromosome(); System.out.println("Fittest Chromosome has fitness " + (fittest.getFitnessValue())); try { output.write(fittest.getFitnessValue() + "\t"); DecimalFormat myformat = new DecimalFormat("#0.00"); for (int ii = 0; ii < chromeSize; ii++) { // System.out.println(myformat.format(((DoubleGene)fittest.getGene(i)).doubleValue())); System.out.print(myformat.format(fittest.getGene(ii).getAllele()) + " "); // output.write(myformat // .format(fittest.getGene(i).getAllele()) + " "); } System.out.println(); output.flush(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } long endTime = System.currentTimeMillis(); System.out.println("? " + (endTime - startTime) + "ms"); System.out.println("sum counts: " + MaxFunction.counts); }
From source file:org.ngrinder.recorder.ui.AboutDialog.java
private void initKeyStroke() { addKeyListener(new KeyAdapter() { @Override//from w w w. jav a2 s .c o m public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { dispose(); } } }); JRootPane rootPane = getRootPane(); rootPane.getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = 421791976774749694L; public void actionPerformed(ActionEvent e) { dispose(); } }); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, "ESCAPE"); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopFilterHelper.java
@Override public void addShortcutListener(TextField textField, final ShortcutListener listener) { final JTextField dTextField = (JTextField) DesktopComponentsHelper.unwrap(textField); final KeyStroke keyStroke = DesktopComponentsHelper.convertKeyCombination(listener.getKeyCombination()); dTextField.addKeyListener(new KeyAdapter() { @Override//from w w w . java 2 s .c o m public void keyReleased(KeyEvent e) { if (ObjectUtils.equals(e.getKeyCode(), keyStroke.getKeyCode()) && ObjectUtils.equals(e.getModifiers(), keyStroke.getModifiers())) { listener.handleShortcutPressed(); } } }); }
From source file:gtu._work.ui.RegexTestUI.java
private void initGUI() { try {//ww w .j a va2 s . co m DocumentListener docListener = JCommonUtil.getDocumentListener(new HandleDocumentEvent() { public void process(DocumentEvent event) { jText1OrJArea1Change(event); } }); BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { jText1OrJArea1Change(null); } }); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("src text", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { srcArea = new JTextArea(); jScrollPane1.setViewportView(srcArea); srcArea.setBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); JCommonUtil.setFont(srcArea); srcArea.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { jText1OrJArea1Change(null); } }); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("group", null, jPanel2, null); { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(398, 234)); { ListModel groupListModel = new DefaultComboBoxModel(); groupList = new JList(); jScrollPane2.setViewportView(groupList); groupList.setBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); groupList.setModel(groupListModel); JCommonUtil.setFont(groupList); } } { regexText0 = new JTextField(); jPanel2.add(regexText0, BorderLayout.NORTH); regexText0.setBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); JCommonUtil.setFont(regexText0); regexText0.getDocument().addDocumentListener(docListener); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("scanner", null, jPanel3, null); { jScrollPane3 = new JScrollPane(); jPanel3.add(jScrollPane3, BorderLayout.CENTER); { ListModel scannerListModel = new DefaultComboBoxModel(); scannerList = new JList(); jScrollPane3.setViewportView(scannerList); scannerList.setBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); scannerList.setModel(scannerListModel); JCommonUtil.setFont(scannerList); } } { regexText = new JTextField(); jPanel3.add(regexText, BorderLayout.NORTH); regexText.setBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); JCommonUtil.setFont(regexText); regexText.getDocument().addDocumentListener(docListener); } } } this.setTitle("\u6b63\u5247\u8868\u793a\u5f0f"); this.setSize(419, 320); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.declarativa.interprolog.gui.Ini.java
public Ini(AbstractPrologEngine e, boolean autoDisplay) { /// super("PrologEngine listener (Swing)"); System.out.println("ENTRA"); if (e != null) { engine = e;/* w w w . j a v a 2 s.c o m*/ } else { throw new IPException("missing Prolog engine"); } String VF = e.getImplementationPeer().visualizationFilename(); if (engine.getLoadFromJar()) { engine.consultFromPackage(VF, Ini.class); } else { engine.consultRelative(VF, Ini.class); } engine.teachMoreObjects(guiExamples()); if (engine == null) { dispose(); // no interface object permitted! } else { topLevelCount++; } debug = engine.isDebug(); loadedFiles = new Vector(); initComponents(); //constructWindowContents(); /// constructMenu(); addWindowListener(this); prologInput.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { // sendToProlog(); e.consume(); } } }); //prologOutput.append("Welcome to an InterProlog top level\n" + e.getPrologVersion() + "\n\n"); prologOutput.append("\n ARG ENGINE v18 ALPHA "); prologOutput.append("\t Argument Engine based on WFS \n\n"); prologOutput.append("\t UIKM Group - Umea University \n\n"); prologOutput.append("\t {esteban, jcnieves, helena}@cs.umu.se \n\n"); if (autoDisplay) { setVisible(true); // focusInput(); } }
From source file:gtu._work.etc.EnglishAdd.java
private void initGUI() { try {/*www . ja va 2 s .co m*/ BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); this.setPreferredSize(new java.awt.Dimension(400, 211)); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { if (jTabbedPane1.getSelectedIndex() == 2) { // XXX } } }); { jPanel1 = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("add", null, jPanel1, null); jPanel1.setPreferredSize(new java.awt.Dimension(387, 233)); { showwordText = new JTextField(); jPanel1.add(showwordText); showwordText.setPreferredSize(new java.awt.Dimension(271, 23)); showwordText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { scanWord(); } } }); showwordText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { scanWord(); } }); } { netChkBox = new JCheckBox(); jPanel1.add(netChkBox); netChkBox.setSelected(true); } { jScrollPane2 = new JScrollPane(); jPanel1.add(jScrollPane2); jScrollPane2.setPreferredSize(new java.awt.Dimension(364, 80)); { showChineseArea = new JTextArea(); jScrollPane2.setViewportView(showChineseArea); showChineseArea.setPreferredSize(new java.awt.Dimension(364, 80)); } } { setFileBtn = new JButton(); jPanel1.add(setFileBtn); setFileBtn.setText("set file"); setFileBtn.setPreferredSize(new java.awt.Dimension(261, 30)); setFileBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error("?!"); return; } currentFile = file; StringBuffer sb = new StringBuffer(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(currentFile), "BIG5")); for (String line = null; (line = reader.readLine()) != null;) { sb.append(line + "\r\n"); } reader.close(); } catch (IOException e) { e.printStackTrace(); } wordTextArea.setText(sb.toString()); } }); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("word", null, jPanel3, null); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(387, 224)); { wordTextArea = new JTextArea(); jScrollPane1.setViewportView(wordTextArea); } } } } setDefaultSave(); pack(); this.setSize(400, 211); } catch (Exception e) { // add your error handling code here e.printStackTrace(); } }
From source file:com.microsoftopentechnologies.intellij.forms.TableForm.java
public TableForm() { final TableForm form = this; this.setResizable(false); this.setModal(true); this.setTitle("Create new table"); this.setContentPane(mainPanel); createButton.setEnabled(false);//from www . j a va2s . co m tableNameTextField.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent keyEvent) { super.keyTyped(keyEvent); createButton.setEnabled(!tableNameTextField.getText().isEmpty()); } }); final PermissionItem[] tablePermissions = PermissionItem.getTablePermissions(); insertPermisssionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); deletePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); updatePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); readPermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { form.setVisible(false); form.dispose(); } }); createButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { try { TablePermissions tablePermissions = new TablePermissions(); tablePermissions.setDelete( ((PermissionItem) deletePermissionComboBox.getSelectedItem()).getType()); tablePermissions.setUpdate( ((PermissionItem) updatePermissionComboBox.getSelectedItem()).getType()); tablePermissions .setRead(((PermissionItem) readPermissionComboBox.getSelectedItem()).getType()); tablePermissions.setInsert( ((PermissionItem) insertPermisssionComboBox.getSelectedItem()).getType()); final String tableName = tableNameTextField.getText().trim(); if (!tableName.matches("^[A-Za-z][A-Za-z0-9_]+")) { JOptionPane.showMessageDialog(form, "Invalid table name. Table name must start with a letter, \n" + "contain only letters, numbers, and underscores.", "Error creating the table", JOptionPane.ERROR_MESSAGE); return; } int tableNameIndex = -1; if (existingTableNames != null) { tableNameIndex = Iterables.indexOf(existingTableNames, new Predicate<String>() { @Override public boolean apply(String name) { return tableName.equalsIgnoreCase(name); } }); } if (tableNameIndex != -1) { JOptionPane.showMessageDialog(form, "Invalid table name. A table with that name already exists in this service.", "Error creating the table", JOptionPane.ERROR_MESSAGE); return; } form.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (editingTable == null) { AzureRestAPIManager.getManager().createTable(subscriptionId, serviceName, tableName, tablePermissions); } else { AzureRestAPIManager.getManager().updateTable(subscriptionId, serviceName, tableName, tablePermissions); } if (afterSave != null) afterSave.run(); form.setVisible(false); form.dispose(); form.setCursor(Cursor.getDefaultCursor()); } catch (Throwable e) { form.setCursor(Cursor.getDefaultCursor()); UIHelper.showException("Error creating table", e); } } }); } }); }
From source file:com.iisigroup.ris.WebFileScanUtilBrowserUI.java
private void initGUI() { final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this); try {/* ww w.ja v a2 s . co m*/ BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setTitle("browser source code"); { informationMenu = new JPopupMenu(); setComponentPopupMenu(this, informationMenu); } { ListModel openFileListModel = new DefaultListModel(); openFileList = new JList(); openFileList.setModel(openFileListModel); getContentPane().add(openFileList, BorderLayout.NORTH); openFileList.setPreferredSize(new java.awt.Dimension(663, 281)); openFileList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { swingUtil.invokeAction("openFileList.valueChanged", evt); } }); openFileList.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent evt) { swingUtil.invokeAction("openFileList.mouseMoved", evt); } }); openFileList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { swingUtil.invokeAction("openFileList.keyPressed", evt); } }); } { jPanel1 = new JPanel(); GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1); jPanel1.setLayout(jPanel1Layout); getContentPane().add(jPanel1, BorderLayout.SOUTH); jPanel1.setPreferredSize(new java.awt.Dimension(478, 35)); { openSelected = new JButton(); openSelected.setText("open all"); openSelected.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("openSelected.actionPerformed", evt); } }); } jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(178, 178) .addComponent(openSelected, GroupLayout.PREFERRED_SIZE, 126, GroupLayout.PREFERRED_SIZE) .addContainerGap(174, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addGap(7) .addComponent(openSelected, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addGap(0, 6, Short.MAX_VALUE)); } { informationMenu = new JPopupMenu(); } this.setSize(486, 350); this.setLocationRelativeTo(null); //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // ?tooltip //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx int initialDelay = ToolTipManager.sharedInstance().getInitialDelay(); ToolTipManager.sharedInstance().setInitialDelay(0); //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // ?tooltip //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx swingUtil.addAction("openFileList.mouseClicked", new Action() { public void action(EventObject evt) throws Exception { DefaultListModel model = (DefaultListModel) openFileList.getModel(); int pos = openFileList.getLeadSelectionIndex(); if (pos == -1) { return; } setOpenFileListToolTip(); MouseEvent eeev = (MouseEvent) evt; if (eeev.getClickCount() != 2) { return; } MFile file = (MFile) model.elementAt(pos); openSource(file.file); } }); final JListUtil jlistUtil = JListUtil.newInstance(openFileList); swingUtil.addAction("openFileList.keyPressed", new Action() { public void action(EventObject evt) throws Exception { jlistUtil.defaultJListKeyPressed((KeyEvent) evt); setOpenFileListToolTip(); } }); swingUtil.addAction("openSelected.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { DefaultListModel model = (DefaultListModel) openFileList.getModel(); for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) { MFile file = (MFile) enu.nextElement(); openSource(file.file); } } }); swingUtil.addAction("openFileList.mouseMoved", new Action() { public void action(EventObject evt) throws Exception { setOpenFileListToolTip(); } }); swingUtil.addAction("openFileList.valueChanged", new Action() { public void action(EventObject evt) throws Exception { System.out.println(evt); setOpenFileListToolTip(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.objectpocket.viewer.Viewer.java
/** * Initialize the contents of the frame. *///from w ww . j av a 2s . c o m private void initialize() { viewerFrame = new JFrame(); viewerFrame.setTitle("ObjectPocketViewer"); viewerFrame.setBounds(100, 100, 1427, 524); viewerFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); splitPane = new JSplitPane(); splitPane.setResizeWeight(0.2); viewerFrame.getContentPane().add(splitPane, BorderLayout.CENTER); classTree = new JTree(); classTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); classTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { updateTable(); } }); splitPane.setLeftComponent(classTree); panel = new JPanel(); splitPane.setRightComponent(panel); panel.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); panel.add(scrollPane); objectTable = new JTable(); objectTable.setAutoCreateRowSorter(true); objectTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.setViewportView(objectTable); panel.add(scrollPane, BorderLayout.CENTER); filterPanel = new JPanel(); panel.add(filterPanel, BorderLayout.NORTH); filterPanel.setLayout(new BorderLayout(0, 0)); filterTextField = new JTextField(); filterTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { updateTable(); } } }); filterPanel.add(filterTextField, BorderLayout.CENTER); filterTextField.setColumns(10); filterButton = new JButton("apply filter"); filterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTable(); } }); filterPanel.add(filterButton, BorderLayout.EAST); statusLabel = new JLabel(""); panel.add(statusLabel, BorderLayout.SOUTH); }