List of usage examples for javax.swing JTextField addFocusListener
public synchronized void addFocusListener(FocusListener l)
From source file:edu.ku.brc.ui.UIHelper.java
@SuppressWarnings("unchecked") public static <T> T addAutoSelect(final JTextField tf) { if (!isMacOS()) { tf.addFocusListener(new FocusAdapter() { @Override/*from w ww . java 2 s .c o m*/ public void focusGained(FocusEvent e) { ((JTextField) e.getSource()).selectAll(); } }); } return (T) tf; }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java
/** * This method initializes jComboBoxClonedFrom * // w w w .j a v a2s . co m * @return javax.swing.JComboBox */ private JComboBox<String> getJComboBoxClonedFrom() { if (jComboBoxClonedFrom == null) { jComboBoxClonedFrom = new JComboBox<String>(); jComboBoxClonedFrom.setRenderer(new ComboToopTip()); jComboBoxClonedFrom.setEditable(true); jComboBoxClonedFrom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("jComboBoxClonedFrom.actionPerformed()"); eventHandler.handleEvent(EventHandler.COMBO_CLONED_FROM); } }); refresh(jComboBoxClonedFrom); final JTextField editor; editor = (JTextField) jComboBoxClonedFrom.getEditor().getEditorComponent(); editor.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) return; if (ch == KeyEvent.VK_ENTER) { jComboBoxClonedFrom.hidePopup(); return; } String str = editor.getText(); if (jComboBoxClonedFrom.getComponentCount() > 0) { jComboBoxClonedFrom.removeAllItems(); } jComboBoxClonedFrom.addItem(str); try { String tmpProjectName = null; if (str.length() > 0) { for (int i = 0; i < names.size(); i++) { tmpProjectName = names.get(i); if (tmpProjectName.toLowerCase().startsWith(str.toLowerCase())) jComboBoxClonedFrom.addItem(tmpProjectName); } } else { for (int i = 0; i < names.size(); i++) { jComboBoxClonedFrom.addItem(names.get(i)); } } } catch (Exception e1) { log.warn(e1.getMessage()); } jComboBoxClonedFrom.hidePopup(); if (str.length() > 0) jComboBoxClonedFrom.showPopup(); } }); editor.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (editor.getText().length() > 0) jComboBoxClonedFrom.showPopup(); } public void focusLost(FocusEvent e) { jComboBoxClonedFrom.hidePopup(); } }); } return jComboBoxClonedFrom; }
From source file:com.sec.ose.osi.ui.frm.main.identification.common.JComboLicenseName.java
public JComboLicenseName() { final JTextField editor; this.initLicenseComboBox(); this.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (isEnabled()) { if (e.getActionCommand().equals("comboBoxChanged") || e.getActionCommand().equals("comboBoxEdited")) { if (getSelectedIndex() > 0) { setSelectedIndex(getSelectedIndex()); IdentifyMediator.getInstance() .setSelectedLicenseName(String.valueOf(getSelectedItem())); log.debug("selected license name : " + IdentifyMediator.getInstance().getSelectedLicenseName()); } else { IdentifyMediator.getInstance().setSelectedLicenseName(""); }//from w w w.ja v a 2 s .c om } } } }); editor = (JTextField) this.getEditor().getEditorComponent(); editor.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))) return; if (ch == KeyEvent.VK_ENTER) { hidePopup(); return; } String str = editor.getText(); if (getComponentCount() > 0) { removeAllItems(); } addItem(str); try { String tmpLicense = null; ArrayList<String> AllLicenseList = new ArrayList<String>(); AllLicenseList = LicenseAPIWrapper.getAllLicenseList(); if (str.length() > 0) { for (int i = 0; i < AllLicenseList.size(); i++) { tmpLicense = AllLicenseList.get(i); if (tmpLicense.toLowerCase().startsWith(str.toLowerCase())) addItem(tmpLicense); } } else { for (int i = 0; i < AllLicenseList.size(); i++) { addItem(AllLicenseList.get(i)); } } } catch (Exception e1) { log.warn(e1.getMessage()); } hidePopup(); if (str.length() > 0) showPopup(); } }); editor.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (editor.getText().length() > 0) showPopup(); } public void focusLost(FocusEvent e) { hidePopup(); } }); }
From source file:edu.ku.brc.specify.plugins.ipadexporter.ManageDataSetsDlg.java
/** * /*from www . j av a2 s .c om*/ */ private void addUserToDS() { final Vector<String> wsList = new Vector<String>(); final Vector<String> instItems = new Vector<String>(); String addStr = getResourceString("ADD"); instItems.add(addStr); wsList.add(addStr); for (String fullName : cloudHelper.getInstList()) { String[] toks = StringUtils.split(fullName, '\t'); instItems.add(toks[0]); wsList.add(toks[1]); } final JTextField userNameTF = createTextField(20); final JTextField passwordTF = createTextField(20); final JLabel pwdLbl = createI18NFormLabel("Password"); final JLabel statusLbl = createLabel(""); final JCheckBox isNewUser = UIHelper.createCheckBox("Is New User"); final JLabel instLbl = createI18NFormLabel("Insitution"); final JComboBox instCmbx = UIHelper.createComboBox(instItems.toArray()); if (instItems.size() == 2) { instCmbx.setSelectedIndex(1); } CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,4px,p,4px,p,4px,p,4px,p,8px,p")); pb.add(createI18NLabel("Add New or Existing User to DataSet"), cc.xyw(1, 1, 3)); pb.add(createI18NFormLabel("Username"), cc.xy(1, 3)); pb.add(userNameTF, cc.xy(3, 3)); pb.add(pwdLbl, cc.xy(1, 5)); pb.add(passwordTF, cc.xy(3, 5)); pb.add(instLbl, cc.xy(1, 7)); pb.add(instCmbx, cc.xy(3, 7)); pb.add(isNewUser, cc.xy(3, 9)); pb.add(statusLbl, cc.xyw(1, 11, 3)); pb.setDefaultDialogBorder(); pwdLbl.setVisible(false); passwordTF.setVisible(false); instLbl.setVisible(false); instCmbx.setVisible(false); final CustomDialog dlg = new CustomDialog(this, "Add User", true, OKCANCEL, pb.getPanel()) { @Override protected void okButtonPressed() { String usrName = userNameTF.getText(); if (cloudHelper.isUserNameOK(usrName)) { String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex()); if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) { super.okButtonPressed(); } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("Unable to add usr: %s to the DataSet guid: %s", usrName, collGuid)); } } else if (isNewUser.isSelected()) { String pwdStr = passwordTF.getText(); String guid = null; if (instCmbx.getSelectedIndex() == 0) { // InstDlg instDlg = new InstDlg(cloudHelper); // if (!instDlg.isInstOK()) // { // instDlg.createUI(); // instDlg.pack(); // centerAndShow(instDlg, 600, null); // if (instDlg.isCancelled()) // { // return; // } // //guid = instDlg.getGuid()(); // } } else { //webSite = wsList.get(instCmbx.getSelectedIndex()); } if (guid != null) { String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex()); if (cloudHelper.addNewUser(usrName, pwdStr, guid)) { if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) { ManageDataSetsDlg.this.loadUsersForDataSetsIntoJList(); super.okButtonPressed(); } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("Unable to add%s to the DataSet %s", usrName, collGuid)); } } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("Unable to add%s to the DataSet %s", usrName, collGuid)); } } else { // error } } else { iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("'%s' doesn't exist.", usrName)); } } }; KeyAdapter ka = new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { statusLbl.setText(""); String usrNmStr = userNameTF.getText(); boolean hasData = StringUtils.isNotEmpty(usrNmStr) && (!isNewUser.isSelected() || StringUtils.isNotEmpty(passwordTF.getText())) && UIHelper.isValidEmailAddress(usrNmStr); dlg.getOkBtn().setEnabled(hasData); } }; userNameTF.addKeyListener(ka); passwordTF.addKeyListener(ka); final Color textColor = userNameTF.getForeground(); FocusAdapter fa = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { JTextField tf = (JTextField) e.getSource(); if (!tf.getForeground().equals(textColor)) { tf.setText(""); tf.setForeground(textColor); } } @Override public void focusLost(FocusEvent e) { JTextField tf = (JTextField) e.getSource(); if (tf.getText().length() == 0) { tf.setText("Enter email address"); tf.setForeground(Color.LIGHT_GRAY); } } }; userNameTF.addFocusListener(fa); userNameTF.setText("Enter email address"); userNameTF.setForeground(Color.LIGHT_GRAY); isNewUser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isSel = isNewUser.isSelected(); pwdLbl.setVisible(isSel); passwordTF.setVisible(isSel); instLbl.setVisible(isSel); instCmbx.setVisible(isSel); Dimension s = dlg.getSize(); int hgt = isNewUser.getSize().height + 4 + instCmbx.getSize().height; s.height += isSel ? hgt : -hgt; dlg.setSize(s); } }); dlg.createUI(); dlg.getOkBtn().setEnabled(false); centerAndShow(dlg); if (!dlg.isCancelled()) { loadUsersForDataSetsIntoJList(); } }
From source file:userinterface.properties.GUIGraphHandler.java
public void plotNewFunction() { JDialog dialog;//from w w w . ja v a2 s . co m JRadioButton radio2d, radio3d, newGraph, existingGraph; JTextField functionField, seriesName; JButton ok, cancel; JComboBox<String> chartOptions; JLabel example; //init all the fields of the dialog dialog = new JDialog(GUIPrism.getGUI()); radio2d = new JRadioButton("2D"); radio3d = new JRadioButton("3D"); newGraph = new JRadioButton("New Graph"); existingGraph = new JRadioButton("Exisiting"); chartOptions = new JComboBox<String>(); functionField = new JTextField(); ok = new JButton("Plot"); cancel = new JButton("Cancel"); seriesName = new JTextField(); example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); example.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { example.setCursor(new Cursor(Cursor.HAND_CURSOR)); example.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); example.setForeground(Color.BLACK); } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (radio2d.isSelected()) { functionField.setText("x/2 + 5"); } else { functionField.setText("x+y+5"); } functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setForeground(Color.BLACK); } } }); //set dialog properties dialog.setSize(400, 350); dialog.setTitle("Plot a new function"); dialog.setModal(true); dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); dialog.setLocationRelativeTo(GUIPrism.getGUI()); //add every component to their dedicated panels JPanel graphTypePanel = new JPanel(new FlowLayout()); graphTypePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type")); graphTypePanel.add(radio2d); graphTypePanel.add(radio3d); JPanel functionFieldPanel = new JPanel(new BorderLayout()); functionFieldPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function")); functionFieldPanel.add(functionField, BorderLayout.CENTER); functionFieldPanel.add(example, BorderLayout.SOUTH); JPanel chartSelectPanel = new JPanel(); chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS)); chartSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to")); JPanel radioPlotPanel = new JPanel(new FlowLayout()); radioPlotPanel.add(newGraph); radioPlotPanel.add(existingGraph); JPanel chartOptionsPanel = new JPanel(new FlowLayout()); chartOptionsPanel.add(chartOptions); chartSelectPanel.add(radioPlotPanel); chartSelectPanel.add(chartOptionsPanel); JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomControlPanel.add(ok); bottomControlPanel.add(cancel); JPanel seriesNamePanel = new JPanel(new BorderLayout()); seriesNamePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); seriesNamePanel.add(seriesName, BorderLayout.CENTER); // add all the panels to the dialog dialog.add(graphTypePanel); dialog.add(functionFieldPanel); dialog.add(chartSelectPanel); dialog.add(seriesNamePanel); dialog.add(bottomControlPanel); // do all the enables and set properties radio2d.setSelected(true); newGraph.setSelected(true); chartOptions.setEnabled(false); functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); seriesName.setText("New function"); ok.setMnemonic('P'); cancel.setMnemonic('C'); example.setToolTipText("click to try out"); ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); cancel.getActionMap().put("cancel", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); boolean found = false; for (int i = 0; i < theTabs.getTabCount(); i++) { if (theTabs.getComponentAt(i) instanceof Graph) { chartOptions.addItem(getGraphName(i)); found = true; } } if (!found) { existingGraph.setEnabled(false); chartOptions.setEnabled(false); } //add all the action listeners radio2d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio2d.isSelected()) { radio3d.setSelected(false); if (chartOptions.getItemCount() > 0) { existingGraph.setEnabled(true); chartOptions.setEnabled(true); } example.setText( "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); } } }); radio3d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio3d.isSelected()) { radio2d.setSelected(false); newGraph.setSelected(true); existingGraph.setEnabled(false); chartOptions.setEnabled(false); example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>"); } } }); newGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGraph.isSelected()) { existingGraph.setSelected(false); chartOptions.setEnabled(false); } } }); existingGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existingGraph.isSelected()) { newGraph.setSelected(false); chartOptions.setEnabled(true); } } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String function = functionField.getText(); Expression expr = null; try { expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function); expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.typeCheck(); expr.semanticCheck(); } catch (PrismLangException e1) { // for copying style JLabel label = new JLabel(); // html content in our case the error we want to show JEditorPane ep = new JEditorPane("text/html", "<html> There was an error parsing the function. To read about what built-in" + " functions are supported <br>and some more information on the functions, visit " + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>." + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } } }); ep.setEditable(false); ep.setBackground(label.getBackground()); // show the error dialog JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE); return; } if (radio2d.isSelected()) { ParametricGraph graph = null; if (newGraph.isSelected()) { graph = new ParametricGraph(""); } else { for (int i = 0; i < theTabs.getComponentCount(); i++) { if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) { graph = (ParametricGraph) theTabs.getComponent(i); } } } dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true); } else if (radio3d.isSelected()) { try { expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.semanticCheck(); expr.typeCheck(); } catch (PrismLangException e1) { e1.printStackTrace(); } if (expr.getAllConstants().size() < 2) { JOptionPane.showMessageDialog(dialog, "There are not enough variables in the function to plot a 3D chart!", "Error", JOptionPane.ERROR_MESSAGE); return; } // its always a new graph ParametricGraph3D graph = new ParametricGraph3D(expr); dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false); } dialog.dispose(); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // we will show info about the function when field is out of focus functionField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!functionField.getText().equals("")) { return; } functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); } @Override public void focusGained(FocusEvent e) { if (!functionField.getText().equals("Add function expression here....")) { return; } functionField.setForeground(Color.BLACK); functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setText(""); } }); // show the dialog dialog.setVisible(true); }
From source file:org.broad.igv.cbio.FilterGeneNetworkUI.java
private void add() { final AttributeFilter row = new AttributeFilter(); row.getDelRow().addActionListener(new ActionListener() { @Override/* w ww.j a va 2 s.com*/ public void actionPerformed(ActionEvent e) { remove(row); } }); row.getAddRow().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { add(); } }); contentPane.add(row.getPanel()); //We want to refresh the RefreshListener listener = new RefreshListener(); row.getAttrName().addActionListener(listener); for (JTextField text : new JTextField[] { row.minVal, row.maxVal }) { text.addActionListener(listener); text.addFocusListener(listener); } //Set the status of being last if (filterRows.size() >= 1) { filterRows.get(filterRows.size() - 1).setIsLast(false); } filterRows.add(row); int numRows = filterRows.size(); filterRows.get(numRows - 1).setIsLast(true); filterRows.get(0).setShowDel(numRows >= 2); validate(); }
From source file:org.nuclos.client.wizard.steps.NuclosEntityAttributeValueListShipStep.java
@Override protected void initComponents() { lstValues = new ArrayList<ValueList>(); this.setLayout(new BorderLayout(5, 5)); pnlName = new JPanel(); pnlName.setLayout(new BorderLayout(5, 5)); lbName = new JLabel( SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributevaluelist.7", "Name")); tfName = new JTextField(); tfName.setDocument(new LimitSpecialCharacterDocument(25)); pnlName.add(lbName, BorderLayout.WEST); pnlName.add(tfName, BorderLayout.CENTER); lbInfo = new JLabel(SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributevaluelist.1", "Entitt ist schon vorhanden. Bitte anderen Namen vergeben!")); lbInfo.setForeground(Color.RED); lbInfo.setVisible(false);/*w w w. ja v a2 s.c o m*/ this.add(pnlName, BorderLayout.NORTH); this.add(subform, BorderLayout.CENTER); this.add(lbInfo, BorderLayout.SOUTH); subform.getSubformTable().setModel(new ValuelistTableModel()); JTextField textField = new JTextField(); textField.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter()); DefaultCellEditor editor = new DefaultCellEditor(textField); editor.setClickCountToStart(1); subform.getSubformTable().setDefaultEditor(String.class, editor); subform.getSubformTable().setDefaultEditor(Date.class, new DateEditor()); ListenerUtil.registerSubFormToolListener(subform, this, new SubForm.SubFormToolListener() { @Override public void toolbarAction(String actionCommand) { if (SubForm.ToolbarFunction.fromCommandString(actionCommand) == SubForm.ToolbarFunction.NEW) { ValuelistTableModel model = (ValuelistTableModel) subform.getSubformTable().getModel(); lstValues.add(new ValueList()); model.fireTableDataChanged(); } } }); tfName.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { doSomeWork(e); } @Override public void insertUpdate(DocumentEvent e) { doSomeWork(e); } @Override public void changedUpdate(DocumentEvent e) { doSomeWork(e); } private void doSomeWork(DocumentEvent e) { try { String s = e.getDocument().getText(0, e.getDocument().getLength()); model.getAttribute().setValueListName(s); if (s.length() == 0) NuclosEntityAttributeValueListShipStep.this.setComplete(false); else NuclosEntityAttributeValueListShipStep.this.setComplete(true); if (model.getAttribute().isValueListNew()) { for (EntityMetaDataVO voEntity : MetaDataClientProvider.getInstance().getAllEntities()) { if (s.equals(voEntity.getEntity()) || ("V_EO_" + s).equalsIgnoreCase(voEntity.getDbEntity())) { NuclosEntityAttributeValueListShipStep.this.setComplete(false); lbInfo.setVisible(true); break; } NuclosEntityAttributeValueListShipStep.this.setComplete(true); lbInfo.setVisible(false); } } } catch (BadLocationException e1) { LOG.info("doSomeWork failed: " + e1, e1); } } }); }
From source file:org.openmicroscopy.shoola.agents.imviewer.util.player.MoviePlayerControl.java
/** * Adds listeners to a {@link JTextField}. * * @param field The component to attach the listeners to. *///from w w w .j a v a2 s . com private void attachFieldListeners(JTextField field) { field.addFocusListener(this); field.addPropertyChangeListener(this); }
From source file:se.llbit.chunky.renderer.ui.RenderControls.java
private JPanel buildGeneralPane() { JLabel canvasSizeLbl = new JLabel("Canvas size:"); JLabel canvasSizeAdvisory = new JLabel("Note: Actual image size may not be the same as the window size!"); canvasSizeCB.setEditable(true);/*from w w w . j a va 2 s .c o m*/ canvasSizeCB.addItem("400x400"); canvasSizeCB.addItem("1024x768"); canvasSizeCB.addItem("960x540"); canvasSizeCB.addItem("1920x1080"); canvasSizeCB.addActionListener(canvasSizeListener); final JTextField canvasSizeEditor = (JTextField) canvasSizeCB.getEditor().getEditorComponent(); canvasSizeEditor.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { } @Override public void focusGained(FocusEvent e) { canvasSizeEditor.selectAll(); } }); updateCanvasSizeField(); loadSceneBtn.setText("Load Scene"); loadSceneBtn.setIcon(Icon.load.imageIcon()); loadSceneBtn.addActionListener(loadSceneListener); JButton loadSelectedChunksBtn = new JButton("Load Selected Chunks"); loadSelectedChunksBtn.setToolTipText("Load the chunks that are currently selected in the map view"); loadSelectedChunksBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sceneMan.loadChunks(chunky.getWorld(), chunky.getSelectedChunks()); } }); JButton reloadChunksBtn = new JButton("Reload Chunks"); reloadChunksBtn.setIcon(Icon.reload.imageIcon()); reloadChunksBtn.setToolTipText("Reload all chunks in the scene"); reloadChunksBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sceneMan.reloadChunks(); } }); openSceneDirBtn.setText("Open Scene Directory"); openSceneDirBtn.setToolTipText("Open the directory where Chunky stores scene descriptions and renders"); openSceneDirBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(context.getSceneDirectory()); } } catch (IOException e) { Log.warn("Failed to open scene directory", e); } } }); openSceneDirBtn.setVisible(Desktop.isDesktopSupported()); loadSceneBtn.setToolTipText("This replaces the current scene!"); JButton setCanvasSizeBtn = new JButton("Apply"); setCanvasSizeBtn.setToolTipText("Set the canvas size to the value in the field"); setCanvasSizeBtn.addActionListener(canvasSizeListener); JButton halveCanvasSizeBtn = new JButton("Halve"); halveCanvasSizeBtn.setToolTipText("Halve the canvas width and height"); halveCanvasSizeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int width = renderMan.scene().canvasWidth() / 2; int height = renderMan.scene().canvasHeight() / 2; setCanvasSize(width, height); } }); JButton doubleCanvasSizeBtn = new JButton("Double"); doubleCanvasSizeBtn.setToolTipText("Double the canvas width and height"); doubleCanvasSizeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int width = renderMan.scene().canvasWidth() * 2; int height = renderMan.scene().canvasHeight() * 2; setCanvasSize(width, height); } }); JButton makeDefaultBtn = new JButton("Make Default"); makeDefaultBtn.setToolTipText("Make the current canvas size the default"); makeDefaultBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { PersistentSettings.set3DCanvasSize(renderMan.scene().canvasWidth(), renderMan.scene().canvasHeight()); } }); JSeparator sep1 = new JSeparator(); JSeparator sep2 = new JSeparator(); biomeColorsCB.setText("enable biome colors"); updateBiomeColorsCB(); saveDumpsCB.setText("save dump once every "); saveDumpsCB.addActionListener(saveDumpsListener); updateSaveDumpsCheckBox(); String[] frequencyStrings = new String[dumpFrequencies.length]; for (int i = 0; i < dumpFrequencies.length; ++i) { frequencyStrings[i] = Integer.toString(dumpFrequencies[i]); } dumpFrequencyCB.setModel(new DefaultComboBoxModel(frequencyStrings)); dumpFrequencyCB.setEditable(true); dumpFrequencyCB.addActionListener(dumpFrequencyListener); updateDumpFrequencyField(); saveSnapshotsCB.addActionListener(saveSnapshotListener); updateSaveSnapshotCheckBox(); yCutoff.update(); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(loadSceneBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(openSceneDirBtn)) .addGroup(layout.createSequentialGroup().addComponent(loadSelectedChunksBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(reloadChunksBtn)) .addComponent(sep1) .addGroup(layout.createSequentialGroup().addComponent(canvasSizeLbl) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(setCanvasSizeBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(makeDefaultBtn)) .addGroup(layout.createSequentialGroup().addComponent(halveCanvasSizeBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(doubleCanvasSizeBtn)) .addComponent(canvasSizeAdvisory).addComponent(sep2).addComponent(biomeColorsCB) .addGroup(layout.createSequentialGroup().addComponent(saveDumpsCB) .addComponent(dumpFrequencyCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(dumpFrequencyLbl).addGap(0, 0, Short.MAX_VALUE)) .addComponent(saveSnapshotsCB).addGroup(yCutoff.horizontalGroup(layout))) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup().addComponent(loadSceneBtn).addComponent(openSceneDirBtn)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout .createParallelGroup().addComponent(loadSelectedChunksBtn).addComponent(reloadChunksBtn)) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent( sep1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(canvasSizeLbl) .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(setCanvasSizeBtn).addComponent(makeDefaultBtn)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup().addComponent(halveCanvasSizeBtn) .addComponent(doubleCanvasSizeBtn)) .addPreferredGap(ComponentPlacement.RELATED).addComponent(canvasSizeAdvisory) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(sep2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(biomeColorsCB) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(saveDumpsCB) .addComponent(dumpFrequencyCB).addComponent(dumpFrequencyLbl)) .addComponent(saveSnapshotsCB).addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(yCutoff.verticalGroup(layout)).addContainerGap()); return panel; }
From source file:visolate.Visolate.java
private JPanel getInitialXPanel() { if (myInitialXPanel == null) { myInitialXPanel = new JPanel(); myInitialXPanel.setLayout(new BorderLayout()); myInitialXPanel.add(new JLabel("X"), BorderLayout.WEST); myInitialXPanel.setToolTipText("Left side is at this coordinate (mm or inch)"); myInitialXPanel.setEnabled(gCodeWriter.getIsAbsolute()); final JTextField field = new JTextField(NumberFormat.getInstance().format(gCodeWriter.getXOffset())); myInitialXPanel.add(field, BorderLayout.CENTER); myInitialXPanel.addPropertyChangeListener("enabled", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { field.setEnabled(myInitialXPanel.isEnabled()); }/* ww w. j av a2s . com*/ }); field.setEnabled(myInitialXPanel.isEnabled()); field.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { try { gCodeWriter.setXOffset(NumberFormat.getInstance().parse(field.getText()).doubleValue()); } catch (ParseException e) { } field.setText(NumberFormat.getInstance().format(gCodeWriter.getXOffset())); } }); } return myInitialXPanel; }