List of usage examples for javax.swing JTextField setText
@BeanProperty(bound = false, description = "the text of this component") public void setText(String t)
TextComponent
to the specified text. From source file:org.gofleet.module.routing.RoutingMap.java
private Map<String, String> getValues(LatLon from) { final Map<String, String> mapa = new HashMap<String, String>(); final JDialog frame = new JDialog(basicWindow.getFrame(), "Configuration"); JPanel panel = new JPanel(new GridLayout(0, 2)); int width = 10; final JTextField maxDistance = new JTextField(width); maxDistance.setText("10"); final JTextField maxTime = new JTextField(width); maxTime.setText("8"); final JTextField origin_x = new JTextField(width / 2); origin_x.setText((new Double(from.getX())).toString()); final JTextField origin_y = new JTextField(width / 2); origin_y.setText((new Double(from.getY())).toString()); final JTextField startTime = new JTextField(width); startTime.setText("7"); final JTextField timeSpentOnStop = new JTextField(width); timeSpentOnStop.setText("1"); JLabel lmaxDistance = new JLabel("Maximum Distance (km)"); lmaxDistance.setLabelFor(maxDistance); JLabel lmaxTime = new JLabel("Maximum Time (hours)"); lmaxTime.setLabelFor(maxTime);// ww w.j a va 2 s . co m JLabel lorigin = new JLabel("Point of Origin"); lorigin.setLabelFor(origin_x); JLabel lstartTime = new JLabel("Start Time of Plan (0-24)"); lstartTime.setLabelFor(startTime); JLabel ltimeSpentOnStop = new JLabel("Time Spent on Stop (hours)"); ltimeSpentOnStop.setLabelFor(timeSpentOnStop); JButton close = new JButton("OK"); close.addActionListener(new AbstractAction() { private static final long serialVersionUID = -8912729211256933464L; @Override public void actionPerformed(ActionEvent arg0) { try { mapa.put("maxDistance", maxDistance.getText()); mapa.put("maxTime", maxTime.getText()); mapa.put("origin_x", origin_x.getText()); mapa.put("origin_y", origin_y.getText()); mapa.put("startTime", startTime.getText()); mapa.put("timeSpentOnStop", timeSpentOnStop.getText()); frame.dispose(); } catch (Throwable t) { log.error("Error configuring New Route Plan" + t); JOptionPane.showMessageDialog(RoutingMap.this, "Some values are wrong. Check them again."); } } }); panel.add(lmaxDistance); panel.add(maxDistance); panel.add(lmaxTime); panel.add(maxTime); panel.add(lorigin); JPanel panel_origin = new JPanel(); panel_origin.add(origin_x); panel_origin.add(origin_y); panel.add(panel_origin); panel.add(lstartTime); panel.add(startTime); panel.add(ltimeSpentOnStop); panel.add(timeSpentOnStop); panel.add(close); frame.add(panel, BorderLayout.CENTER); frame.pack(); frame.setModalityType(ModalityType.APPLICATION_MODAL); frame.setVisible(true); return mapa; }
From source file:org.gtdfree.ApplicationHelper.java
public static int getDefaultFieldHeigth() { if (defaultFieldHeigth <= 0) { JTextField jtf = new JTextField(); jtf.setText("1234567890"); //$NON-NLS-1$ defaultFieldHeigth = jtf.getPreferredSize().height; if (UIManager.getLookAndFeel() != null && UIManager.getLookAndFeel().getClass().getName() .equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")) { //$NON-NLS-1$ defaultFieldHeigth -= 4;/*from w w w. ja va 2 s.com*/ } if (defaultFieldHeigth < 21) { defaultFieldHeigth = 21; } } return defaultFieldHeigth; }
From source file:org.interreg.docexplore.DocExploreTool.java
@SuppressWarnings("serial") protected static File askForHome(String text) { final File[] file = { null }; final JDialog dialog = new JDialog((Frame) null, XMLResourceBundle.getBundledString("homeLabel"), true); JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, true, false, SwingConstants.CENTER, SwingConstants.TOP, true, false)); content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); JLabel message = new JLabel(text, ImageUtils.getIcon("free-64x64.png"), SwingConstants.LEFT); message.setIconTextGap(20);//from w w w . java 2 s . c om //message.setFont(Font.decode(Font.SANS_SERIF)); content.add(message); final JPanel pathPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); pathPanel.add(new JLabel("<html><b>" + XMLResourceBundle.getBundledString("homeLabel") + ":</b></html>")); final JTextField pathField = new JTextField(System.getProperty("user.home") + File.separator + "DocExplore", 40); pathPanel.add(pathField); pathPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("browseLabel")) { JNativeFileDialog nfd = null; public void actionPerformed(ActionEvent arg0) { if (nfd == null) { nfd = new JNativeFileDialog(); nfd.acceptFiles = false; nfd.acceptFolders = true; nfd.multipleSelection = false; nfd.title = XMLResourceBundle.getBundledString("homeLabel"); } nfd.setCurrentFile(new File(pathField.getText())); if (nfd.showOpenDialog()) pathField.setText(nfd.getSelectedFile().getAbsolutePath()); } })); content.add(pathPanel); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgOkLabel")) { public void actionPerformed(ActionEvent e) { File res = new File(pathField.getText()); if (res.exists() && !res.isDirectory() || !res.exists() && !res.mkdirs()) JOptionPane.showMessageDialog(dialog, XMLResourceBundle.getBundledString("homeErrorMessage"), XMLResourceBundle.getBundledString("errorLabel"), JOptionPane.ERROR_MESSAGE); else { file[0] = res; dialog.setVisible(false); } } })); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgCancelLabel")) { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } })); content.add(buttonPanel); dialog.getContentPane().add(content); dialog.pack(); dialog.setResizable(false); GuiUtils.centerOnScreen(dialog); dialog.setVisible(true); return file[0]; }
From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java
/** * Create an DropDownComponent field.//w ww . j a va 2 s .com * * @param field - JTextField to be associated with the OntologySelectionTool. * @param allowsMultiple - Should the OntologySelectionTool allow multiple terms to be selected. * @param recommendedOntologySource - A recommended ontology source. * @return DropDownComponent object. */ protected DropDownComponent createOntologyDropDown(final JTextField field, boolean allowsMultiple, Map<String, RecommendedOntology> recommendedOntologySource) { final OntologySelectionTool ost = new OntologySelectionTool(allowsMultiple, false, recommendedOntologySource); ost.createGUI(); final DropDownComponent dropdown = new DropDownComponent(field, ost, DropDownComponent.ONTOLOGY); ost.addPropertyChangeListener("selectedOntology", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { dropdown.hidePopup(ost); String value = evt.getNewValue().toString(); // for this section, we are only storing the term at the minute, not the entire unique id // returned from the ontology lookup tool! value = value.contains(":") ? value.substring(value.indexOf(":") + 1) : value; field.setText(value); } }); ost.addPropertyChangeListener("noSelectedOntology", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { dropdown.hidePopup(ost); } }); return dropdown; }
From source file:org.jets3t.gui.UserInputFields.java
/** * Builds a user input panel matching the fields specified in the uploader.properties file. * * @param fieldsPanel/*from w w w . j av a 2s. com*/ * the panel component to add prompt and user input components to. * @param uploaderProperties * properties specific to the Uploader application that includes the field.* settings * necessary to build the User Inputs screen. * * @return * true if there is at least one valid user input field, false otherwise. */ public boolean buildFieldsPanel(JPanel fieldsPanel, Jets3tProperties uploaderProperties) { int fieldIndex = 0; for (int fieldNo = 0; fieldNo < 100; fieldNo++) { String fieldName = uploaderProperties.getStringProperty("field." + fieldNo + ".name", null); String fieldType = uploaderProperties.getStringProperty("field." + fieldNo + ".type", null); String fieldPrompt = uploaderProperties.getStringProperty("field." + fieldNo + ".prompt", null); String fieldOptions = uploaderProperties.getStringProperty("field." + fieldNo + ".options", null); String fieldDefault = uploaderProperties.getStringProperty("field." + fieldNo + ".default", null); if (fieldName == null) { log.debug("No field with index number " + fieldNo); continue; } else { if (fieldType == null || fieldPrompt == null) { log.warn("Field '" + fieldName + "' missing .type or .prompt properties"); continue; } if ("message".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } else if ("radio".equals(fieldType)) { if (fieldOptions == null) { log.warn( "Radio button field '" + fieldName + "' is missing the required .options property"); continue; } JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JPanel optionsPanel = skinsFactory.createSkinnedJPanel("OptionsPanel"); optionsPanel.setLayout(new GridBagLayout()); int columnOffset = 0; ButtonGroup buttonGroup = new ButtonGroup(); StringTokenizer st = new StringTokenizer(fieldOptions, ","); while (st.hasMoreTokens()) { String option = st.nextToken(); JRadioButton radioButton = skinsFactory.createSkinnedJRadioButton(fieldName); radioButton.setText(option); buttonGroup.add(radioButton); if (fieldDefault != null && fieldDefault.equals(option)) { // This option is the default one. radioButton.setSelected(true); } else if (buttonGroup.getButtonCount() == 1) { // Make first button the default. radioButton.setSelected(true); } optionsPanel.add(radioButton, new GridBagConstraints(columnOffset++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); } fieldsPanel.add(optionsPanel, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsNone, 0, 0)); userInputComponentsMap.put(fieldName, buttonGroup); } else if ("selection".equals(fieldType)) { if (fieldOptions == null) { log.warn( "Radio button field '" + fieldName + "' is missing the required .options property"); continue; } JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JComboBox comboBox = skinsFactory.createSkinnedJComboBox(fieldName); StringTokenizer st = new StringTokenizer(fieldOptions, ","); while (st.hasMoreTokens()) { String option = st.nextToken(); comboBox.addItem(option); } if (fieldDefault != null) { comboBox.setSelectedItem(fieldDefault); } fieldsPanel.add(comboBox, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, comboBox); } else if ("text".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JTextField textField = skinsFactory.createSkinnedJTextField(fieldName); if (fieldDefault != null) { textField.setText(fieldDefault); } fieldsPanel.add(textField, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, textField); } else if ("password".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JPasswordField passwordField = skinsFactory.createSkinnedJPasswordField(fieldName); if (fieldDefault != null) { passwordField.setText(fieldDefault); } fieldsPanel.add(passwordField, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, passwordField); } else if (fieldType.equals("textarea")) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 2, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); JTextArea textArea = skinsFactory.createSkinnedJTextArea(fieldName); textArea.setLineWrap(true); if (fieldDefault != null) { textArea.setText(fieldDefault); } JScrollPane scrollPane = skinsFactory.createSkinnedJScrollPane(fieldName); scrollPane.setViewportView(textArea); fieldsPanel.add(scrollPane, new GridBagConstraints(0, fieldIndex++, 2, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, insetsDefault, 0, 0)); userInputComponentsMap.put(fieldName, textArea); } else { log.warn("Unrecognised .type setting for field '" + fieldName + "'"); } } } return isUserInputFieldsAvailable(); }
From source file:org.kuali.test.ui.components.sqlquerypanel.WhereValueCellEditor.java
@Override public void actionPerformed(ActionEvent e) { if (currentRowData != null) { if (e.getSource() == lookup) { Column col = findColumn(currentRowData); String sql = col.getLookupSqlSelect(); if (StringUtils.isBlank(sql)) { sql = dbPanel.getGlobalLookupSql(col.getColumnName()); }//from w w w. j a v a2s. co m if (StringUtils.isNotBlank(sql)) { WhereValueLookupDlg dlg = null; if (dbPanel.isForCheckpoint()) { dlg = new WhereValueLookupDlg(dbPanel.getMainframe(), Utils.getParentDialog(this), dbPanel.getPlatform(), sql); } else { dlg = new WhereValueLookupDlg(dbPanel.getMainframe(), dbPanel.getPlatform(), sql); } LookupValue value = dlg.getLookupValue(); if (value != null) { JTextField tf = (JTextField) cellEditor.getComponent(); tf.setText(value.getName()); } } } else if (e.getSource() == executionParameter) { handleTestExecutionParameterSelect(); } currentRowData = null; stopCellEditing(); } }
From source file:org.kuali.test.ui.components.sqlquerypanel.WhereValueCellEditor.java
private void handleTestExecutionParameterSelect() { ItemSelectDlg dlg = new ItemSelectDlg(dbPanel.getMainframe(), "Available Parameters", this.getAvailableTestExecutionParameters()); String param = dlg.getSelectedValue(); if (StringUtils.isNotBlank(param)) { JTextField tf = (JTextField) cellEditor.getComponent(); tf.setText( Constants.TEST_EXECUTION_PARAMETER_PREFIX + param + Constants.TEST_EXECUTION_PARAMETER_SUFFIX); }// w ww. j av a 2s . co m }
From source file:org.languagetool.gui.ConfigurationDialog.java
private void createOfficeElements(GridBagConstraints cons, JPanel portPanel) { int numParaCheck = config.getNumParasToCheck(); JRadioButton[] radioButtons = new JRadioButton[3]; ButtonGroup numParaGroup = new ButtonGroup(); radioButtons[0] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckOnlyParagraph"))); radioButtons[0].setActionCommand("ParagraphCheck"); radioButtons[1] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckFullText"))); radioButtons[1].setActionCommand("FullTextCheck"); radioButtons[2] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckNumParagraphs"))); radioButtons[2].setActionCommand("NParagraphCheck"); radioButtons[2].setSelected(true);/*ww w.ja v a 2 s . c o m*/ JTextField numParaField = new JTextField(Integer.toString(5), 2); numParaField.setEnabled(radioButtons[2].isSelected()); numParaField.setMinimumSize(new Dimension(30, 25)); for (int i = 0; i < 3; i++) { numParaGroup.add(radioButtons[i]); } if (numParaCheck == 0) { radioButtons[0].setSelected(true); numParaField.setEnabled(false); } else if (numParaCheck < 0) { radioButtons[1].setSelected(true); numParaField.setEnabled(false); } else { radioButtons[2].setSelected(true); numParaField.setText(Integer.toString(numParaCheck)); numParaField.setEnabled(true); } radioButtons[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { numParaField.setEnabled(false); config.setNumParasToCheck(0); } }); radioButtons[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { numParaField.setEnabled(false); config.setNumParasToCheck(-1); } }); radioButtons[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int numParaCheck = Integer.parseInt(numParaField.getText()); if (numParaCheck < 1) numParaCheck = 1; else if (numParaCheck > 99) numParaCheck = 99; config.setNumParasToCheck(numParaCheck); numParaField.setForeground(Color.BLACK); numParaField.setText(Integer.toString(numParaCheck)); numParaField.setEnabled(true); } }); numParaField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { try { int numParaCheck = Integer.parseInt(numParaField.getText()); if (numParaCheck > 0 && numParaCheck < 99) { numParaField.setForeground(Color.BLACK); config.setNumParasToCheck(numParaCheck); } else { numParaField.setForeground(Color.RED); } } catch (NumberFormatException ex) { numParaField.setForeground(Color.RED); } } }); JLabel textChangedLabel = new JLabel(Tools.getLabel(messages.getString("guiTextChangeLabel"))); cons.gridy++; portPanel.add(textChangedLabel, cons); cons.gridy++; cons.insets = new Insets(0, 30, 0, 0); for (int i = 0; i < 3; i++) { portPanel.add(radioButtons[i], cons); if (i < 2) cons.gridy++; } cons.gridx = 1; portPanel.add(numParaField, cons); JCheckBox noMultiResetbox = new JCheckBox(Tools.getLabel(messages.getString("guiNoMultiReset"))); noMultiResetbox.setSelected(config.isNoMultiReset()); noMultiResetbox.setEnabled(config.isResetCheck()); noMultiResetbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setNoMultiReset(noMultiResetbox.isSelected()); } }); JCheckBox resetCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiDoResetCheck"))); resetCheckbox.setSelected(config.isResetCheck()); resetCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setDoResetCheck(resetCheckbox.isSelected()); noMultiResetbox.setEnabled(resetCheckbox.isSelected()); } }); cons.insets = new Insets(0, 4, 0, 0); cons.gridx = 0; // JLabel dummyLabel = new JLabel(" "); // cons.gridy++; // portPanel.add(dummyLabel, cons); cons.gridy++; portPanel.add(resetCheckbox, cons); cons.insets = new Insets(0, 30, 0, 0); cons.gridx = 0; cons.gridy++; portPanel.add(noMultiResetbox, cons); JCheckBox fullTextCheckAtFirstBox = new JCheckBox( Tools.getLabel(messages.getString("guiCheckFullTextAtFirst"))); fullTextCheckAtFirstBox.setSelected(config.doFullCheckAtFirst()); fullTextCheckAtFirstBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setFullCheckAtFirst(fullTextCheckAtFirstBox.isSelected()); } }); cons.insets = new Insets(0, 4, 0, 0); cons.gridx = 0; // cons.gridy++; // JLabel dummyLabel2 = new JLabel(" "); // portPanel.add(dummyLabel2, cons); cons.gridy++; portPanel.add(fullTextCheckAtFirstBox, cons); JCheckBox isMultiThreadBox = new JCheckBox(Tools.getLabel(messages.getString("guiIsMultiThread"))); isMultiThreadBox.setSelected(config.isMultiThread()); isMultiThreadBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setMultiThreadLO(isMultiThreadBox.isSelected()); } }); cons.gridy++; JLabel dummyLabel3 = new JLabel(" "); portPanel.add(dummyLabel3, cons); cons.gridy++; portPanel.add(isMultiThreadBox, cons); }
From source file:org.metawidget.swing.widgetprocessor.binding.beanutils.BeanUtilsBindingProcessorTest.java
public void testScalaBinding() throws Exception { // Model// w w w . j a v a 2 s.c o m Date dateFirst = new GregorianCalendar(1975, Calendar.APRIL, 9).getTime(); ScalaFoo scalaFoo = new ScalaFoo(); scalaFoo.bar_$eq(dateFirst); ScalaFoo scalaFoo2 = new ScalaFoo(); scalaFoo.nestedFoo = scalaFoo2; ScalaFoo scalaFoo3 = new ScalaFoo(); scalaFoo2.nestedFoo = scalaFoo3; scalaFoo3.bar_$eq(new GregorianCalendar(1976, Calendar.MAY, 16).getTime()); // BeanUtilsBinding ConvertUtils.register(new DateConverter(DATE_FORMAT), Date.class); // Inspect SwingMetawidget metawidget = new SwingMetawidget(); metawidget.addWidgetProcessor(new BeanUtilsBindingProcessor( new BeanUtilsBindingProcessorConfig().setPropertyStyle(new ScalaPropertyStyle()))); BaseObjectInspectorConfig config = new BaseObjectInspectorConfig() .setPropertyStyle(new ScalaPropertyStyle()); metawidget.setInspector(new PropertyTypeInspector(config)); metawidget.setToInspect(scalaFoo); // Loading JTextField textField = (JTextField) metawidget.getComponent(1); DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); assertEquals(dateFormat.format(dateFirst), textField.getText()); JLabel label = (JLabel) metawidget.getComponent(5); assertEquals("Not settable", label.getText()); JTextField nestedTextField = (JTextField) ((SwingMetawidget) metawidget.getComponent(3)).getComponent(1); assertEquals("", nestedTextField.getText()); JTextField nestedNestedTextField = (JTextField) ((SwingMetawidget) ((SwingMetawidget) metawidget .getComponent(3)).getComponent(3)).getComponent(1); assertEquals(dateFormat.format(scalaFoo3.bar()), nestedNestedTextField.getText()); // Saving Date dateSecond = new GregorianCalendar(1976, Calendar.MAY, 10).getTime(); textField.setText(dateFormat.format(dateSecond)); nestedNestedTextField.setText(dateFormat.format(new GregorianCalendar(1977, Calendar.JUNE, 17).getTime())); metawidget.getWidgetProcessor(BeanUtilsBindingProcessor.class).save(metawidget); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(scalaFoo.bar()); assertEquals(1976, calendar.get(Calendar.YEAR)); assertEquals(null, scalaFoo2.bar()); calendar.setTime(scalaFoo3.bar()); assertEquals(1977, calendar.get(Calendar.YEAR)); // Rebinding textField = (JTextField) metawidget.getComponent(1); assertEquals(dateFormat.format(dateSecond), textField.getText()); scalaFoo.bar_$eq(dateFirst); metawidget.getWidgetProcessor(BeanUtilsBindingProcessor.class).rebind(scalaFoo, metawidget); textField = (JTextField) metawidget.getComponent(1); assertEquals(dateFormat.format(dateFirst), textField.getText()); }
From source file:org.micromanager.asidispim.AcquisitionPanel.java
private void setRootDirectory(JTextField rootField) { File result = FileDialogs.openDir(null, "Please choose a directory root for image data", MMStudio.MM_DATA_SET);//from w ww .j a va2s . c o m if (result != null) { rootField.setText(result.getAbsolutePath()); } }