List of usage examples for java.awt.event FocusEvent getComponent
public Component getComponent()
From source file:com.dbschools.quickquiz.client.giver.MainWindow.java
private void customizeDefaultButtonHandling() { final FocusListener focusListener = new FocusListener() { public final void focusGained(final FocusEvent e) { final Component comp = e.getComponent(); final JRootPane pane = getRootPane(); if (comp == txtChatLine) { pane.setDefaultButton(btnSendChatLine); } else if (comp == cbxQuestions || comp == txtTimeLimit) { pane.setDefaultButton(btnSendQuestion); } else if (comp == sprPoints) { pane.setDefaultButton(btnAwardPoints); }//from w ww. ja v a 2 s.c om } public void focusLost(FocusEvent e) { // Ignore } }; txtChatLine.addFocusListener(focusListener); cbxQuestions.addFocusListener(focusListener); txtTimeLimit.addFocusListener(focusListener); sprPoints.addFocusListener(focusListener); }
From source file:BeanContainer.java
public void focusGained(FocusEvent e) { m_activeBean = e.getComponent(); repaint(); }
From source file:org.rdv.viz.spectrum.SpectrumViz.java
/** * Initializes the properties panel./*from ww w . ja v a 2 s. c o m*/ */ private void initPropertiesPanel() { propertiesPanel = new JPanel(); propertiesPanel.setLayout(new SpringLayout()); propertiesPanel.setBorder(BorderFactory.createTitledBorder("Properties")); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { handlePropertiesUpdate((Component) ae.getSource()); } }; FocusAdapter focusListener = new FocusAdapter() { public void focusLost(FocusEvent fe) { handlePropertiesUpdate(fe.getComponent()); } }; propertiesPanel.add(new JLabel("Sample rate: ")); sampleRateTextField = new JTextField(Double.toString(spectrumAnalyzerPanel.getSampleRate())); sampleRateTextField.addActionListener(actionListener); sampleRateTextField.addFocusListener(focusListener); propertiesPanel.add(sampleRateTextField); propertiesPanel.add(new JLabel("Number of points: ")); numberOfSamplesTextField = new JTextField(Integer.toString(spectrumAnalyzerPanel.getNumberOfSamples())); numberOfSamplesTextField.addActionListener(actionListener); numberOfSamplesTextField.addFocusListener(focusListener); propertiesPanel.add(numberOfSamplesTextField); propertiesPanel.add(new JLabel("Window: ")); Object[] windowTypes = EnumSet.allOf(WindowFunction.class).toArray(); windowFunctionComboBox = new JComboBox(windowTypes); windowFunctionComboBox.setSelectedItem(spectrumAnalyzerPanel.getWindowFunction()); windowFunctionComboBox.addActionListener(actionListener); propertiesPanel.add(windowFunctionComboBox); propertiesPanel.add(new JLabel("Size: ")); segmentSizeTextField = new JTextField(Integer.toString(spectrumAnalyzerPanel.getSegmentSize())); segmentSizeTextField.addActionListener(actionListener); segmentSizeTextField.addFocusListener(focusListener); propertiesPanel.add(segmentSizeTextField); propertiesPanel.add(new JLabel("Overlap: ")); overlapTextField = new JTextField(Integer.toString(spectrumAnalyzerPanel.getOverlap())); overlapTextField.addActionListener(actionListener); overlapTextField.addFocusListener(focusListener); propertiesPanel.add(overlapTextField); SpringUtilities.makeCompactGrid(propertiesPanel, 5, 2, 5, 5, 5, 5); panel.add(propertiesPanel, BorderLayout.EAST); }
From source file:org.trianacode.gui.hci.ApplicationFrame.java
/** * Invoked when a component loses the keyboard focus. * ANDREW: IS THIS NEEDED NOW?//from w ww.ja v a 2 s . co m */ public void focusLost(FocusEvent event) { // required to fix internal frame focus/selection bug if (event.getComponent() instanceof TaskGraphPanel) { DesktopView frame = getDesktopViewManager().getDesktopViewFor((TaskGraphPanel) event.getComponent()); if (frame != null) { getDesktopViewManager().setSelected(frame, false); } } }
From source file:org.xulux.swing.listeners.PrePostFieldListener.java
/** * now call post..// www .j a va 2 s .co m * @see java.awt.event.FocusListener#focusLost(FocusEvent) */ public void focusLost(FocusEvent e) { if (isProcessing()) { return; } if (e.getID() != FocusEvent.FOCUS_LOST || e.isTemporary()) { return; } NyxEventQueue q = NyxEventQueue.getInstance(); // @todo make test.. // A checkbox would consume an event, so it wouldn't process // any further.. Need to make a test of this! if (!(e.getComponent() instanceof JCheckBox)) { q.holdEvents(true); q.holdAccepted(this); } }
From source file:scannerapplication.scannerapps.java
public void focusGained(FocusEvent e) { System.out.println(e.getComponent().getName()); String source = e.getComponent().getName(); //source.replaceAll("/\d+/", username); switch (source) { case "jList1": fileUpload = jList1.getSelectedValuesList(); break;//from w w w .jav a2s. co m case "jTextField": break; case "jButton": break; } }
From source file:uk.chromis.pos.imports.JPanelCSVImport.java
private void jComboBoxFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBoxFocusGained JComboBox myJComboBox = ((javax.swing.JComboBox) (evt.getComponent())); myJComboBox.removeAllItems();//ww w . j av a2s.c o m int i = 1; myJComboBox.addItem(""); while (i < Headers.size()) { if (!isEntryInUse(Headers.get(i))) { myJComboBox.addItem(Headers.get(i)); } ++i; } jComboCategory.addItem(category_disable_text); }