List of usage examples for java.awt.event FocusListener FocusListener
FocusListener
From source file:org.springframework.amqp.rabbit.stocks.ui.StockPanel.java
public StockPanel(StockController controller) { this.stockController = controller; controller.setStockPanel(this); this.setBorder(BorderFactory.createTitledBorder("Stock Form")); FormLayout formLayout = new FormLayout("pref, 150dlu", // columns "pref, fill:100dlu:grow"); // rows setLayout(formLayout);//from w w w . ja v a 2 s .co m CellConstraints c = new CellConstraints(); tradeRequestButton = new JButton("Send Trade Request"); add(tradeRequestButton, c.xy(1, 1)); tradeRequestTextField = new JTextField(""); add(tradeRequestTextField, c.xy(2, 1)); add(new JLabel("Market Data"), c.xy(1, 2)); marketDataTextArea = new JTextArea(); JScrollPane sp = new JScrollPane(marketDataTextArea); sp.setSize(200, 300); add(sp, c.xy(2, 2)); tradeRequestTextField.addFocusListener(new FocusListener() { public void focusLost(FocusEvent e) { } public void focusGained(FocusEvent e) { tradeRequestTextField.setText(""); tradeRequestTextField.setForeground(Color.BLACK); } }); tradeRequestButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sendTradeRequest(); } }); }
From source file:com.microsoft.intellij.forms.ExternalStorageAccountForm.java
public ExternalStorageAccountForm(Project project) { super(project, true); setModal(true);/* w w w.j av a 2 s. c o m*/ privacyLink.addMouseListener(new LinkListener(PRIVACY_LINK)); ActionListener connectionClick = new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { updateConnectionString(); customEndpointsPanel.setVisible(specifyCustomEndpointsRadioButton.isSelected()); } }; useHTTPRadioButton.addActionListener(connectionClick); useHTTPSRecommendedRadioButton.addActionListener(connectionClick); specifyCustomEndpointsRadioButton.addActionListener(connectionClick); FocusListener focusListener = new FocusListener() { @Override public void focusGained(FocusEvent focusEvent) { } @Override public void focusLost(FocusEvent focusEvent) { updateConnectionString(); } }; accountNameTextField.addFocusListener(focusListener); accountKeyTextField.addFocusListener(focusListener); rememberAccountKeyCheckBox.addFocusListener(focusListener); blobURLTextField.addFocusListener(focusListener); tableURLTextField.addFocusListener(focusListener); queueURLTextField.addFocusListener(focusListener); init(); }
From source file:facebookchat.ui.common.JNABalloon.java
public JNABalloon(String BALLOON_TEXT, JComponent owner, int X, int Y) { //System.setProperty("sun.java2d.noddraw", "true"); content = new JLabel(BALLOON_TEXT); content.setIconTextGap(10);/* w ww . ja va2 s . c o m*/ content.setBorder(new EmptyBorder(0, 8, 0, 8)); content.setSize(content.getPreferredSize()); content.setIcon(new InfoIcon()); popup = BalloonManager.getBalloon(owner, content, X, Y); content.addMouseListener(listener); content.addFocusListener(new FocusListener() { public void focusGained(FocusEvent arg0) { log.debug("content get focusssssssssss"); } public void focusLost(FocusEvent fe) { log.debug("content lost focusssssssssss"); fe.getComponent().removeMouseListener(listener); if (popup != null) popup.hide(); } }); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.TextualAnnotationsUI.java
/** Initializes the components. */ private void initComponents() { set = false;/*from w w w. j a v a2 s . c om*/ commentArea = new OMEWikiComponent(false); commentArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); commentArea.addPropertyChangeListener(controller); //commentArea.setBackground(UIUtilities.BACKGROUND_COLOR); commentArea.setForeground(UIUtilities.DEFAULT_FONT_COLOR); commentArea.setComponentBorder(EDIT_BORDER); commentArea.addFocusListener(new FocusListener() { public void focusLost(FocusEvent arg0) { if (CommonsLangUtils.isBlank(commentArea.getText())) { pane.getViewport().setPreferredSize(null); revalidate(); pane.revalidate(); } } public void focusGained(FocusEvent arg0) { Dimension d = commentArea.getSize(); pane.getViewport().setPreferredSize(new Dimension(d.width, 60)); revalidate(); pane.revalidate(); } }); setBorder(new SeparatorOneLineBorder()); setBackground(UIUtilities.BACKGROUND_COLOR); addButton = new JButton("Add comment"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveComment(); } }); addButton.setEnabled(false); }
From source file:com.floreantpos.ui.dialog.DiscountSelectionDialog.java
private void createCouponSearchPanel() { itemSearchPanel = new JPanel(new BorderLayout(5, 5)); PosButton btnSearch = new PosButton("..."); btnSearch.setPreferredSize(new Dimension(60, 40)); JLabel lblCoupon = new JLabel("Enter Coupon Number"); txtSearchItem = new JTextField(); txtSearchItem.addFocusListener(new FocusListener() { @Override//from www . j a v a2 s .c om public void focusLost(FocusEvent e) { txtSearchItem.setText("Scan barcode"); txtSearchItem.setForeground(Color.gray); } @Override public void focusGained(FocusEvent e) { txtSearchItem.setForeground(Color.black); txtSearchItem.setText(""); } }); txtSearchItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (txtSearchItem.getText().equals("")) { POSMessageDialog.showMessage("Please enter coupon number or barcode "); return; } if (!addCouponByBarcode(txtSearchItem.getText())) { addCouponById(txtSearchItem.getText()); } txtSearchItem.setText(""); } }); btnSearch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ItemSearchDialog dialog = new ItemSearchDialog(Application.getPosWindow()); dialog.setTitle("Search Coupon"); dialog.pack(); dialog.open(); if (dialog.isCanceled()) { return; } txtSearchItem.requestFocus(); if (!addCouponByBarcode(dialog.getValue())) { if (!addCouponById(dialog.getValue())) { POSMessageDialog.showError(Application.getPosWindow(), "Coupon not found"); } } } }); itemSearchPanel.add(lblCoupon, BorderLayout.WEST); itemSearchPanel.add(txtSearchItem); itemSearchPanel.add(btnSearch, BorderLayout.EAST); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.CommentsTaskPaneUI.java
/** Initializes the components. */ private void initComponents() { commentArea = new OMEWikiComponent(false); commentArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); commentArea.addPropertyChangeListener(controller); commentArea.setForeground(UIUtilities.DEFAULT_FONT_COLOR); commentArea.setComponentBorder(EDIT_BORDER); commentArea.addFocusListener(new FocusListener() { public void focusLost(FocusEvent arg0) { if (CommonsLangUtils.isBlank(commentArea.getText())) { pane.getViewport().setPreferredSize(null); revalidate();/*w w w.j a va 2s .co m*/ pane.revalidate(); } } public void focusGained(FocusEvent arg0) { Dimension d = commentArea.getSize(); pane.getViewport().setPreferredSize(new Dimension(d.width, 60)); revalidate(); pane.revalidate(); } }); setBorder(new SeparatorOneLineBorder()); setBackground(UIUtilities.BACKGROUND_COLOR); addButton = new JButton("Add comment"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveComment(); } }); addButton.setEnabled(false); pane = new JScrollPane(commentArea); pane.setBorder(null); setLayout(new GridBagLayout()); buildGUI(); }
From source file:org.rdv.ui.RBNBConnectionDialog.java
public RBNBConnectionDialog(JFrame owner, RBNBController rbnbController, DataPanelManager dataPanelManager) { super(owner, true); this.rbnb = rbnbController; this.dataPanelManager = dataPanelManager; setDefaultCloseOperation(DISPOSE_ON_CLOSE); setTitle("Connect to RBNB Server"); JPanel container = new JPanel(); setContentPane(container);/*from w ww. ja v a 2 s . co m*/ InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; headerLabel = new JLabel("Please specify the RBNB server connection information."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new Insets(0, 0, 0, 0); container.add(headerLabel, c); c.gridwidth = 1; rbnbHostNameLabel = new JLabel("Host:"); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new Insets(10, 10, 10, 5); container.add(rbnbHostNameLabel, c); rbnbHostNameTextField = new JTextField(25); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(10, 0, 10, 10); container.add(rbnbHostNameTextField, c); rbnbPortLabel = new JLabel("Port:"); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new Insets(0, 10, 10, 5); container.add(rbnbPortLabel, c); rbnbPortTextField = new JTextField(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(0, 0, 10, 10); rbnbPortTextField.addFocusListener(new FocusListener() { public void focusGained(FocusEvent focusEvent) { rbnbPortTextField.setSelectionStart(0); rbnbPortTextField.setSelectionEnd(rbnbPortTextField.getText().length()); } public void focusLost(FocusEvent focusEvent) { } }); container.add(rbnbPortTextField, c); JPanel buttonPanel = new JPanel(); Action connectAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = 5814028508027064335L; public void actionPerformed(ActionEvent e) { connect(); } }; connectAction.putValue(Action.NAME, "Connect"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "connect"); actionMap.put("connect", connectAction); connectButton = new JButton(connectAction); buttonPanel.add(connectButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -679192362775669088L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); buttonPanel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = 2; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(0, 10, 10, 5); container.add(buttonPanel, c); pack(); setLocationByPlatform(true); setVisible(true); }
From source file:Applet.EmbeddedChart.java
public synchronized void updateInfo(String[] legends, List<double[][]> yVals, boolean gofr) { removeAll();/* www .j a va 2 s . c om*/ GridBagLayout gbl = new GridBagLayout(); gbl.columnWidths = new int[] { 10, 0, 0 }; gbl.rowHeights = new int[] { 0, 0, 0 }; gbl.columnWeights = new double[] { 0.0, 1.0, 1.0 }; gbl.rowWeights = new double[] { 1.0, 1.0, 0.0 }; setLayout(gbl); this.legends = legends; this.yvals = yVals; this.gofr = gofr; XYDataset dataset = createDataset(gofr, legends, yVals); JFreeChart chart = createChart(dataset, title, gofr); chartPanel = new ChartPanel(chart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawWidth(2000); chartPanel.setMaximumDrawHeight(2000); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); chartPanel.getChart().setBackgroundPaint(null); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.gridheight = 2; gbc.fill = GridBagConstraints.BOTH; add(chartPanel, gbc); GridBagConstraints gbcX1 = new GridBagConstraints(); GridBagConstraints gbcX2 = new GridBagConstraints(); GridBagConstraints gbcY1 = new GridBagConstraints(); GridBagConstraints gbcY2 = new GridBagConstraints(); GridBagConstraints gbcButton = new GridBagConstraints(); final NumberAxis domain = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getDomainAxis(); final NumberAxis range = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getRangeAxis(); if (gofr) { domain.setLowerBound(over.gr_xMin); domain.setUpperBound(over.gr_xMax); range.setLowerBound(over.gr_yMin); range.setUpperBound(over.gr_yMax); } else { domain.setLowerBound(over.pot_xMin); domain.setUpperBound(over.pot_xMax); range.setLowerBound(over.pot_yMin); range.setUpperBound(over.pot_yMax); } gbcX2.gridx = 2; gbcX2.gridy = 2; gbcX2.anchor = GridBagConstraints.EAST; gbcX2.insets = new Insets(0, 0, 0, 12); final JTextField xMax = new JTextField(5); xMax.setMinimumSize(new Dimension(50, 20)); xMax.setText("" + domain.getUpperBound()); // gbcX2.fill = GridBagConstraints.VERTICAL; add(xMax, gbcX2); final boolean gr = gofr; xMax.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_xMax = Double.parseDouble(xMax.getText()); domain.setRange(over.gr_xMin, over.gr_xMax); } else { over.pot_xMax = Double.parseDouble(xMax.getText()); domain.setRange(over.pot_xMin, over.pot_xMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcX1.gridx = 1; gbcX1.gridy = 2; gbcX1.anchor = GridBagConstraints.WEST; gbcX1.insets = new Insets(0, 70, 0, 0); final JTextField xMin = new JTextField(5); xMin.setMinimumSize(new Dimension(50, 20)); xMin.setText("" + domain.getLowerBound()); // gbcX1.fill = GridBagConstraints.VERTICAL; add(xMin, gbcX1); xMin.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { x1 = Double.parseDouble(xMin.getText()); domain.setRange(x1, x2); if (gr) { over.gr_xMin = Double.parseDouble(xMin.getText()); domain.setRange(over.gr_xMin, over.gr_xMax); } else { over.pot_xMin = Double.parseDouble(xMin.getText()); domain.setRange(over.pot_xMin, over.pot_xMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcY1.gridx = 0; gbcY1.gridy = 1; gbcY1.anchor = GridBagConstraints.SOUTH; gbcY1.insets = new Insets(0, 0, 45, 0); final JTextField yMin = new JTextField(5); yMin.setMinimumSize(new Dimension(50, 20)); yMin.setText("" + range.getLowerBound()); // gbcY1.fill = GridBagConstraints.BOTH; add(yMin, gbcY1); yMin.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_yMin = Double.parseDouble(yMin.getText()); range.setRange(over.gr_yMin, over.gr_yMax); } else { over.pot_yMin = Double.parseDouble(yMin.getText()); range.setRange(over.pot_yMin, over.pot_yMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcY2.gridx = 0; gbcY2.gridy = 0; gbcY2.anchor = GridBagConstraints.NORTH; gbcY2.insets = new Insets(10, 0, 0, 0); final JTextField yMax = new JTextField(5); yMax.setMinimumSize(new Dimension(50, 20)); yMax.setText("" + range.getUpperBound()); // gbcY2.fill = GridBagConstraints.BOTH; add(yMax, gbcY2); yMax.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_yMax = Double.parseDouble(yMax.getText()); range.setRange(over.gr_yMin, over.gr_yMax); } else { over.pot_yMax = Double.parseDouble(yMax.getText()); range.setRange(over.pot_yMin, over.pot_yMax); } } @Override public void focusGained(FocusEvent e) { } }); }
From source file:com.anrisoftware.prefdialog.miscswing.components.menu.PopupMenuComponent.java
private void createMenuFocusListener() { menuFocusListener = new FocusListener() { @Override/*from w ww . j av a 2s . com*/ public void focusLost(FocusEvent e) { alreadyShowingPopup = false; } @Override public void focusGained(FocusEvent e) { alreadyShowingPopup = true; } }; }
From source file:com.floreantpos.ui.forms.QuickCustomerForm.java
private void createCustomerForm() { setLayout(new BorderLayout(10, 10)); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); setOpaque(true);// w w w . j av a 2s . co m JPanel inputPanel = new JPanel(); inputPanel.setLayout(new MigLayout("insets 10 10 10 10", "[][][][]", "[][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ inputPanel.setBorder(BorderFactory.createTitledBorder("Enter Customer Information")); JLabel lblAddress = new JLabel(Messages.getString("CustomerForm.18")); //$NON-NLS-1$ tfAddress = new JTextArea(new FixedLengthDocument(220)); JScrollPane scrlDescription = new JScrollPane(tfAddress); scrlDescription.setPreferredSize(PosUIManager.getSize(338, 52)); JLabel lblZip = new JLabel(Messages.getString("CustomerForm.21")); //$NON-NLS-1$ tfZip = new FixedLengthTextField(30); JLabel lblCitytown = new JLabel(Messages.getString("CustomerForm.24")); //$NON-NLS-1$ tfCity = new FixedLengthTextField(); JLabel lblState = new JLabel(Messages.getString("QuickCustomerForm.0")); //$NON-NLS-1$ tfState = new JTextField(30); JLabel lblCellPhone = new JLabel(Messages.getString("CustomerForm.32")); //$NON-NLS-1$ inputPanel.add(lblCellPhone, "cell 0 1,alignx right"); //$NON-NLS-1$ tfCellPhone = new JTextField(30); inputPanel.add(tfCellPhone, "cell 1 1"); //$NON-NLS-1$ //setPreferredSize(PosUIManager.getSize(800, 350)); JLabel lblFirstName = new JLabel(Messages.getString("CustomerForm.3")); //$NON-NLS-1$ //inputPanel.add(lblFirstName, "cell 0 2,alignx right"); //$NON-NLS-1$ tfFirstName = new FixedLengthTextField(); //inputPanel.add(tfFirstName, "cell 1 2"); //$NON-NLS-1$ JLabel lblLastName = new JLabel(Messages.getString("CustomerForm.11")); //$NON-NLS-1$ //inputPanel.add(lblLastName, "cell 0 3,alignx right"); //$NON-NLS-1$ tfLastName = new FixedLengthTextField(); //inputPanel.add(tfLastName, "cell 1 3"); //$NON-NLS-1$ JLabel lblName = new JLabel("Name"); //$NON-NLS-1$ inputPanel.add(lblName, "cell 0 3,alignx right"); //$NON-NLS-1$ tfName = new FixedLengthTextField(); tfName.setLength(120); inputPanel.add(tfName, "cell 1 3"); //$NON-NLS-1$ inputPanel.add(lblZip, "cell 0 4,right"); //$NON-NLS-1$ inputPanel.add(tfZip, "cell 1 4"); //$NON-NLS-1$ inputPanel.add(lblCitytown, "cell 0 5,right"); //$NON-NLS-1$ inputPanel.add(tfCity, "cell 1 5"); //$NON-NLS-1$ inputPanel.add(lblState, "cell 0 6,right"); //$NON-NLS-1$ inputPanel.add(tfState, "cell 1 6"); //$NON-NLS-1$ inputPanel.add(lblAddress, "cell 2 1 1 6,right"); //$NON-NLS-1$ inputPanel.add(scrlDescription, "grow, cell 3 1 1 6"); //$NON-NLS-1$ qwertyKeyPad = new QwertyKeyPad(); add(inputPanel, BorderLayout.CENTER); if (isKeypad) { add(qwertyKeyPad, BorderLayout.SOUTH); //$NON-NLS-1$ } tfZip.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getStateAndCityByZipCode(); } }); tfZip.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { getStateAndCityByZipCode(); } @Override public void focusGained(FocusEvent e) { } }); enableCustomerFields(false); callOrderController(); }