List of usage examples for javax.swing JSpinner JSpinner
public JSpinner(SpinnerModel model)
From source file:com.willwinder.ugs.platform.probe.ProbeTopComponent.java
private void initComponents() { // XYZ TAB//from w ww .ja v a 2 s. c o m JPanel xyz = new JPanel(new MigLayout("flowy, wrap 3")); xyz.add(new JLabel(X_DISTANCE)); xyz.add(new JLabel(Y_DISTANCE)); xyz.add(new JLabel(Z_DISTANCE)); xyz.add(new JSpinner(xyzXDistanceModel), "growx"); xyz.add(new JSpinner(xyzYDistanceModel), "growx"); xyz.add(new JSpinner(xyzZDistanceModel), "growx"); xyz.add(new JLabel(X_OFFSET)); xyz.add(new JLabel(Y_OFFSET)); xyz.add(new JLabel(Z_OFFSET)); xyz.add(new JSpinner(xyzXOffsetModel), "growx"); xyz.add(new JSpinner(xyzYOffsetModel), "growx"); xyz.add(new JSpinner(xyzZOffsetModel), "growx"); xyz.add(measureXYZ, "spanx 2, spany 3, growx, growy"); // TODO: INSIDE Probe JPanel inside = new JPanel(new MigLayout("flowy, wrap 2")); inside.add(new JLabel(X_DISTANCE)); inside.add(new JLabel(Y_DISTANCE)); inside.add(new JSpinner(insideXDistanceModel), "growx"); inside.add(new JSpinner(insideYDistanceModel), "growx"); inside.add(new JLabel(X_OFFSET)); inside.add(new JLabel(Y_OFFSET)); inside.add(new JSpinner(insideXOffsetModel), "growx"); inside.add(new JSpinner(insideYOffsetModel), "growx"); inside.add(measureInside, "spanx 2, spany 2, growx, growy"); // OUTSIDE TAB JPanel outside = new JPanel(new MigLayout("flowy, wrap 2")); outside.add(new JLabel(X_DISTANCE)); outside.add(new JLabel(Y_DISTANCE)); outside.add(new JSpinner(outsideXDistanceModel), "growx"); outside.add(new JSpinner(outsideYDistanceModel), "growx"); outside.add(new JLabel(X_OFFSET)); outside.add(new JLabel(Y_OFFSET)); outside.add(new JSpinner(outsideXOffsetModel), "growx"); outside.add(new JSpinner(outsideYOffsetModel), "growx"); outside.add(measureOutside, "spanx 2, spany 2, growx, growy"); // Z PROBE TAB JPanel z = new JPanel(new MigLayout("wrap 4")); z.add(new JLabel(Z_OFFSET)); z.add(new JSpinner(this.zProbeOffset), "growx"); z.add(this.zProbeButton, "spanx 2, spany 2, growx, growy"); z.add(new JLabel(Z_DISTANCE)); z.add(new JSpinner(this.zProbeDistance), "growx"); // SETTINGS TAB JPanel settings = new JPanel(new MigLayout("wrap 6")); settings.add(new JLabel(Localization.getString("gcode.setting.units") + ":"), "al right"); settings.add(settingsUnits, "growx"); settings.add(new JLabel(Localization.getString("gcode.setting.endmill-diameter") + ":"), "al right"); settings.add(new JSpinner(settingsProbeDiameter), "growx"); settings.add(new JLabel(Localization.getString("probe.find-rate") + ":"), "al right"); settings.add(new JSpinner(settingsFastFindRate), "growx"); settings.add(new JLabel("Work Coordinates:"), "al right"); settings.add(settingsWorkCoordinate, "growx"); settings.add(new JLabel(Localization.getString("probe.measure-rate") + ":"), "al right"); settings.add(new JSpinner(settingsSlowMeasureRate), "growx"); settings.add(new JLabel(Localization.getString("probe.retract-amount") + ":"), "al right"); settings.add(new JSpinner(settingsRetractAmount), "growx"); jtp.add(XYZ_TAB, xyz); jtp.add(OUTSIDE_TAB, outside); jtp.add(Z_TAB, z); //jtp.add("inside", inside); jtp.add(SETTINGS_TAB, settings); this.setLayout(new BorderLayout()); this.add(jtp); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendSurvivalRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from w w w.j a va 2 s . co m SpinnerModel survivalRateModel = new SpinnerNumberModel(survivalInitial, SURVIVAL_MIN, SURVIVAL_MAX, SURVIVAL_STEP); survivalRateSpinner = new JSpinner(survivalRateModel); JLabel survivalRateLabel = new JLabel(survivalRateText); survivalRateLabel.setLabelFor(survivalRateSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(survivalRateLabel, constraints); mainPanel.add(survivalRateLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(survivalRateSpinner, constraints); mainPanel.add(survivalRateSpinner); }
From source file:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java
/** * Creates the UI for the login and hooks up any listeners. * @param isDlg whether the parent is a dialog (false mean JFrame) * @param iconName the icon that will be shown in the panel * @param engageUPPrefs whether it should load and save the username password into the prefs * @param helpContext the help context to use. *//*from w w w . j a va 2 s . c om*/ protected void createUI(final boolean isDlg, final String iconName, final String helpContext) { final boolean isNotEmbedded = !DBConnection.getInstance().isEmbedded() && !UIRegistry.isMobile(); final AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //Font cachedFont = UIManager.getFont("JLabel.font"); SkinItem skinItem = SkinsMgr.getSkinItem("LoginPanel"); if (skinItem != null) { skinItem.pushFG("Label.foreground"); } if (isNotEmbedded) { SpinnerModel portModel = new SpinnerNumberModel(3306, //initial value 0, //min Integer.MAX_VALUE, //max 1); //step portSpinner = new JSpinner(portModel); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#"); portSpinner.setEditor(editor); portSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { drvInfo.setPort((Integer) portSpinner.getValue()); } } }); setControlSize(portSpinner); } // First create the controls and hook up listeners dbPickList = new PropertiesPickListAdapter("login.databases"); //$NON-NLS-1$ svPickList = new PropertiesPickListAdapter("login.servers"); //$NON-NLS-1$ username = createTextField(15); password = createPasswordField(15); FocusAdapter focusAdp = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { super.focusGained(e); JTextField tf = (JTextField) e.getSource(); tf.selectAll(); } }; username.addFocusListener(focusAdp); password.addFocusListener(focusAdp); databases = new ValComboBox(dbPickList); if (databases.getComboBox() instanceof Java2sAutoComboBox) { ((Java2sAutoComboBox) databases.getComboBox()).setCaseSensitive(true); } servers = new ValComboBox(svPickList); dbPickList.setComboBox(databases); svPickList.setComboBox(servers); setControlSize(password); setControlSize(databases); setControlSize(servers); if (masterUsrPwdProvider != null) { editKeyInfoBtn = UIHelper.createI18NButton("CONFIG_MSTR_KEY"); editKeyInfoBtn.setIcon(IconManager.getIcon("Key", IconManager.IconSize.Std20)); editKeyInfoBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (masterUsrPwdProvider != null && databases != null) { String itemName = null; if (databases.getComboBox().getSelectedItem() instanceof String) { itemName = (String) databases.getComboBox().getSelectedItem(); } else { PickListItemIFace pli = (PickListItemIFace) databases.getComboBox().getSelectedItem(); if (pli != null && pli.getValue() != null) { itemName = pli.getValue(); } } if (itemName != null) { masterUsrPwdProvider.editMasterInfo(username.getText(), itemName, false); } } } }); } rememberUsernameCBX = createCheckBox(getResourceString("rememberuser")); //$NON-NLS-1$ rememberUsernameCBX.setEnabled(engageUPPrefs); statusBar = new JStatusBar(); statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); //$NON-NLS-1$ cancelBtn = createButton(getResourceString("CANCEL")); //$NON-NLS-1$ loginBtn = createButton(getResourceString("Login")); //$NON-NLS-1$ helpBtn = createButton(getResourceString("HELP")); //$NON-NLS-1$ forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$ downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$ moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); // XXX I18N //$NON-NLS-1$ setControlSize(moreBtn); // Extra dbDrivers = DatabaseDriverInfo.getDriversList(); dbDriverCBX = createComboBox(dbDrivers); dbDriverCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUIControls(); DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { Integer defPort = drvInfo.getPortAsInt(); int portFromPref = localPrefs.getInt(LOGIN_PORT, defPort); portSpinner.setValue(portFromPref); drvInfo.setPort(portFromPref); } } }); if (dbDrivers.size() > 0) { if (dbDrivers.size() == 1) { dbDriverCBX.setSelectedIndex(0); dbDriverCBX.setEnabled(false); } else { String selectedStr = localPrefs.get("login.dbdriver_selected", "MySQL"); //$NON-NLS-1$ //$NON-NLS-2$ int inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(selectedStr, null, null, false, null)); dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1); } } else { JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), //$NON-NLS-1$ getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); //$NON-NLS-1$ System.exit(1); } addFocusListenerForTextComp(username); addFocusListenerForTextComp(password); addKeyListenerFor(username, !isDlg); addKeyListenerFor(password, !isDlg); addKeyListenerFor(databases.getTextField(), !isDlg); addKeyListenerFor(servers.getTextField(), !isDlg); if (!isDlg) { addKeyListenerFor(loginBtn, true); } rememberUsernameCBX.setSelected(engageUPPrefs ? localPrefs.getBoolean("login.rememberuser", false) : false); //$NON-NLS-1$ cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (dbListener != null) { dbListener.cancelled(); } } }); loginBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doLogin(); } }); HelpMgr.registerComponent(helpBtn, helpContext); //$NON-NLS-1$ moreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (extraPanel.isVisible()) { if (dbDriverCBX.getSelectedIndex() != -1) { extraPanel.setVisible(false); moreBtn.setIcon(forwardImgIcon); } } else { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } if (window != null) { window.pack(); } } }); // Ask the PropertiesPickListAdapter to set the index from the prefs dbPickList.setSelectedIndex(); svPickList.setSelectedIndex(); servers.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addFocusListener(new FocusAdapter() { String server = null; private String getServerStr() { String serverStr = null; Object serverObj = servers.getValue(); if (serverObj != null) { serverStr = serverObj.toString(); } return serverStr; } @Override public void focusGained(FocusEvent e) { server = getServerStr(); } @Override public void focusLost(FocusEvent e) { if (server != null) { String newVal = getServerStr(); if (newVal != null && !newVal.equals(server)) { setUsrPwdControlsFromPrefs(); } } } }); setUsrPwdControlsFromPrefs(); // Layout the form PanelBuilder formBuilder = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p,2dlu,p,2dlu,p")); //$NON-NLS-1$ //$NON-NLS-2$ CellConstraints cc = new CellConstraints(); formBuilder.addSeparator(getResourceString("LOGINLABEL"), cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ addLine("username", username, formBuilder, cc, 3); //$NON-NLS-1$ addLine("password", password, formBuilder, cc, 5); //$NON-NLS-1$ formBuilder.add(moreBtn, cc.xy(3, 7)); PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,p:g", //$NON-NLS-1$ UIHelper.createDuplicateJGoodiesDef("p", "2dlu", isNotEmbedded ? 9 : 11))); //$NON-NLS-1$ //$NON-NLS-2$ extraPanel = extraPanelBlder.getPanel(); extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2)); //extraPanelBlder.addSeparator("", cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ int y = 1; y = addLine(null, rememberUsernameCBX, extraPanelBlder, cc, y); y = addLine("databases", databases, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("servers", servers, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("driver", dbDriverCBX, extraPanelBlder, cc, y); //$NON-NLS-1$ if (isNotEmbedded) { y = addLine("port", portSpinner, extraPanelBlder, cc, y); //$NON-NLS-1$ } if (editKeyInfoBtn != null) { PanelBuilder pb = new PanelBuilder(new FormLayout("p,f:p:g", "p")); pb.add(editKeyInfoBtn, cc.xy(1, 1)); y = addLine(null, pb.getPanel(), extraPanelBlder, cc, y); pb.getPanel().setOpaque(false); } extraPanel.setVisible(false); formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(3, 9, 1, 1)); PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "t:p,2dlu,p,2dlu,p"), this); //$NON-NLS-1$ //$NON-NLS-2$ JLabel icon = StringUtils.isNotEmpty(iconName) ? new JLabel(IconManager.getIcon(iconName)) : null; if (icon != null) { icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 2)); } formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5)); if (icon != null) { outerPanel.add(icon, cc.xy(1, 1)); } JPanel btnPanel = ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn); outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1)); outerPanel.add(btnPanel, cc.xywh(1, 3, 3, 1)); outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1)); formBuilder.getPanel().setOpaque(false); outerPanel.getPanel().setOpaque(false); btnPanel.setOpaque(false); updateUIControls(); if (skinItem != null) { skinItem.popFG("Label.foreground"); } if (AppPreferences.getLocalPrefs().getBoolean(expandExtraPanelName, false)) { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendMutationRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/*w w w. ja va 2 s .co m*/ SpinnerModel mutationRateModel = new SpinnerNumberModel(mutationInitial, MUTATION_MIN, MUTATION_MAX, MUTATION_STEP); mutationRateSpinner = new JSpinner(mutationRateModel); JLabel mutationRateLabel = new JLabel(mutationRateText); mutationRateLabel.setLabelFor(mutationRateSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(mutationRateLabel, constraints); mainPanel.add(mutationRateLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(mutationRateSpinner, constraints); mainPanel.add(mutationRateSpinner); }
From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java
private JSpinner initializeSpinner(final Calendar instance) { JSpinner res = new JSpinner(new SpinnerDateModel()); JSpinner.DateEditor startEditor = new JSpinner.DateEditor(res, "HH:mm:ss"); res.setEditor(startEditor);//from www. ja va 2 s. c o m res.setValue(instance.getTime()); res.addChangeListener(changeListener); return res; }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendMaxMutationsPerIndividualSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from w ww . j ava 2s . com SpinnerModel maxMutationsPerIndividualModel = new SpinnerNumberModel(maxMutationsPerIndividualInitial, MAX_MUTATION_MIN, MAX_MUTATION_MAX, MAX_MUTATION_STEP); maxMutationsPerIndividualSpinner = new JSpinner(maxMutationsPerIndividualModel); JLabel maxMutationsPerIndividualLabel = new JLabel(maxMutationsPerIndividualText); maxMutationsPerIndividualLabel.setLabelFor(maxMutationsPerIndividualSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(maxMutationsPerIndividualLabel, constraints); mainPanel.add(maxMutationsPerIndividualLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(maxMutationsPerIndividualSpinner, constraints); mainPanel.add(maxMutationsPerIndividualSpinner); }
From source file:userinterface.graph.Histogram.java
/** * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram * to plot data on//from w w w .j a v a 2 s .com * * @param defaultSeriesName * @param handler instance of {@link GUIGraphHandler} * @param minVal the min value in data cache * @param maxVal the max value in data cache * @return Either a new instance of a Histogram or an old one depending on what the user selects */ public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler, double minVal, double maxVal) { // make sure that the probabilities are valid if (maxVal > 1.0) maxVal = 1.0; if (minVal < 0.0) minVal = 0.0; // set properties for the dialog JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true); dialog.setLayout(new BorderLayout()); JPanel p1 = new JPanel(new FlowLayout()); p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Number of buckets")); JPanel p2 = new JPanel(new FlowLayout()); p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1)); buckets.setToolTipText("Select the number of buckets for this Histogram"); // provides the ability to select a new or an old histogram to plot the series on JTextField seriesName = new JTextField(defaultSeriesName); JRadioButton newSeries = new JRadioButton("New Histogram"); JRadioButton existing = new JRadioButton("Existing Histogram"); newSeries.setSelected(true); JPanel seriesSelectPanel = new JPanel(); seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS)); JPanel seriesTypeSelect = new JPanel(new FlowLayout()); JPanel seriesOptionsPanel = new JPanel(new FlowLayout()); seriesTypeSelect.add(newSeries); seriesTypeSelect.add(existing); JComboBox<String> seriesOptions = new JComboBox<>(); seriesOptionsPanel.add(seriesOptions); seriesSelectPanel.add(seriesTypeSelect); seriesSelectPanel.add(seriesOptionsPanel); seriesSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to")); // provides ability to select the min/max range of the plot JLabel minValsLabel = new JLabel("Min range:"); JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01)); minVals.setToolTipText("Does not allow value more than the min value in the probabilities"); JLabel maxValsLabel = new JLabel("Max range:"); JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01)); maxVals.setToolTipText("Does not allow value less than the max value in the probabilities"); JPanel minMaxPanel = new JPanel(); minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS)); JPanel leftValsPanel = new JPanel(new BorderLayout()); JPanel rightValsPanel = new JPanel(new BorderLayout()); minMaxPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range")); leftValsPanel.add(minValsLabel, BorderLayout.WEST); leftValsPanel.add(minVals, BorderLayout.CENTER); rightValsPanel.add(maxValsLabel, BorderLayout.WEST); rightValsPanel.add(maxVals, BorderLayout.CENTER); minMaxPanel.add(leftValsPanel); minMaxPanel.add(rightValsPanel); // fill the old histograms in the property dialog boolean found = false; for (int i = 0; i < handler.getNumModels(); i++) { if (handler.getModel(i) instanceof Histogram) { seriesOptions.addItem(handler.getGraphName(i)); found = true; } } existing.setEnabled(found); seriesOptions.setEnabled(false); // the bottom panel JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton ok = new JButton("Plot"); JButton cancel = new JButton("Cancel"); // bind keyboard keys to plot and cancel buttons to improve usability ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = -7324877661936685228L; @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ok"); cancel.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = 2642213543774356676L; @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); //Action listener for the new series radio button newSeries.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newSeries.isSelected()) { existing.setSelected(false); seriesOptions.setEnabled(false); buckets.setEnabled(true); buckets.setToolTipText("Select the number of buckets for this Histogram"); minVals.setEnabled(true); maxVals.setEnabled(true); } } }); //Action listener for the existing series radio button existing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existing.isSelected()) { newSeries.setSelected(false); seriesOptions.setEnabled(true); buckets.setEnabled(false); minVals.setEnabled(false); maxVals.setEnabled(false); buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram"); } } }); //Action listener for the plot button ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); if (newSeries.isSelected()) { hist = new Histogram(); hist.setNumOfBuckets((int) buckets.getValue()); hist.setIsNew(true); } else if (existing.isSelected()) { String HistName = (String) seriesOptions.getSelectedItem(); hist = (Histogram) handler.getModel(HistName); hist.setIsNew(false); } key = hist.addSeries(seriesName.getText()); if (minVals.isEnabled() && maxVals.isEnabled()) { hist.setMinProb((double) minVals.getValue()); hist.setMaxProb((double) maxVals.getValue()); } } }); //Action listener for the cancel button cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); hist = null; } }); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { hist = null; } }); p1.add(buckets, BorderLayout.CENTER); p2.add(seriesName, BorderLayout.CENTER); options.add(ok); options.add(cancel); // add everything to the main panel of the dialog JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(seriesSelectPanel); mainPanel.add(p1); mainPanel.add(p2); mainPanel.add(minMaxPanel); // add main panel to the dialog dialog.add(mainPanel, BorderLayout.CENTER); dialog.add(options, BorderLayout.SOUTH); // set dialog properties dialog.setSize(320, 290); dialog.setLocationRelativeTo(GUIPrism.getGUI()); dialog.setVisible(true); // return the user selected Histogram with the properties set return new Pair<Histogram, SeriesKey>(hist, key); }
From source file:com.vladsch.idea.multimarkdown.settings.MultiMarkdownSettingsPanel.java
private void createUIComponents() { // TODO: place custom component creation code here // create the css themes combobox, make it locale aware ArrayList<String> options = new ArrayList<String>(10); for (int i = 0;; i++) { String message = MultiMarkdownBundle.messageOrBlank("settings.html-theme-" + (i + 1)); if (message.isEmpty()) break; options.add(message);/*www. j a v a 2 s. co m*/ } // we use the list to report but combo box if available htmlThemeList = new JBList(options); htmlThemeList.setSelectedIndex(2); htmlThemeComboBox = new JLabel(); htmlThemeComboBox.setVisible(false); haveCustomizableEditor = false; try { htmlThemeComboBox = new ComboBox(options.toArray(new String[options.size()])); ((JComboBox) htmlThemeComboBox).setSelectedIndex(2); htmlThemeList.setVisible(false); haveCustomizableEditor = true; } catch (NoSuchMethodError e) { // does not exist, use list box } catch (NoClassDefFoundError e) { // does not exist, use list box } // create the CSS text edit control Language language = Language.findLanguageByID("CSS"); final boolean foundCSS = language != null; final FileType fileType = language != null && language.getAssociatedFileType() != null ? language.getAssociatedFileType() : StdFileTypes.PLAIN_TEXT; // Set zoom to 0.1 increments final SpinnerNumberModel model = new SpinnerNumberModel(1.0, 0.2, 5.0, 0.01); pageZoomSpinner = new JSpinner(model); JSpinner.NumberEditor decimalFormat = new JSpinner.NumberEditor(pageZoomSpinner, "0.00"); CustomizableEditorTextField.EditorCustomizationListener listener = new CustomizableEditorTextField.EditorCustomizationListener() { @Override public boolean editorCreated(@NotNull EditorEx editor, @NotNull Project project) { EditorSettings settings = editor.getSettings(); settings.setRightMarginShown(true); //settings.setRightMargin(-1); if (foundCSS) settings.setFoldingOutlineShown(true); settings.setLineNumbersShown(true); if (foundCSS) settings.setLineMarkerAreaShown(true); settings.setIndentGuidesShown(true); settings.setVirtualSpace(true); //settings.setWheelFontChangeEnabled(false); editor.setHorizontalScrollbarVisible(true); editor.setVerticalScrollbarVisible(true); FileType fileTypeH = FileTypeManagerEx.getInstanceEx().getFileTypeByExtension(".css"); FileType highlighterFileType = foundCSS ? fileType : fileTypeH; if (highlighterFileType != null && project != null) { editor.setHighlighter(HighlighterFactory.createHighlighter(project, highlighterFileType)); } int lineCursorWidth = 2; if (haveCustomizableEditor) { // get the standard caret width from the registry try { RegistryValue value = Registry.get("editor.caret.width"); if (value != null) { lineCursorWidth = value.asInteger(); } } catch (Exception ex) { // ignore } focusEditorButton .setEnabled(((CustomizableEditorTextField) textCustomCss).haveSavedState(editor)); } settings.setLineCursorWidth(lineCursorWidth); return false; } }; if (!haveCustomizableEditor) { Project project = CustomizableEditorTextField.getAnyProject(null, true); Document document = CustomizableEditorTextField.createDocument("", fileType, project, new CustomizableEditorTextField.SimpleDocumentCreator()); textCustomCss = new CustomizableLanguageEditorTextField(document, project, fileType, false, false); textCustomCss.setFontInheritedFromLAF(false); ((CustomizableLanguageEditorTextField) textCustomCss).registerListener(listener); //focusEditorButton.setEnabled(false); } else { // we pass a null project because we don't have one, the control will grab any project so that // undo works properly in the edit control. Project project = CustomizableEditorTextField.getAnyProject(null, true); textCustomCss = new CustomizableEditorTextField(fileType, project, "", false); textCustomCss.setFontInheritedFromLAF(false); ((CustomizableEditorTextField) textCustomCss).registerListener(listener); } }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendCrossoverRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from ww w.j a v a 2 s . co m SpinnerModel crossoverRateModel = new SpinnerNumberModel(crossoverInitial, CROSSOVER_MIN, CROSSOVER_MAX, CROSSOVER_STEP); crossoverRateSpinner = new JSpinner(crossoverRateModel); JLabel crossoverRateLabel = new JLabel(crossoverRateText); crossoverRateLabel.setLabelFor(crossoverRateSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(crossoverRateLabel, constraints); mainPanel.add(crossoverRateLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(crossoverRateSpinner, constraints); mainPanel.add(crossoverRateSpinner); }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel constructButtons() { Box buttons = Box.createVerticalBox(); JSpinner numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1)); JPanel labelledSpinner = new JPanel(); labelledSpinner.setLayout(new GridLayout(1, 2)); labelledSpinner.add(new JLabel("Number of fixations: ")); labelledSpinner.add(numFixations);// w ww .ja v a2s .c o m JButton recallButton = new JButton(new RecallAction(numFixations)); recallButton.setToolTipText("Scan shown scene and display results"); final JCheckBox showFixations = new JCheckBox("Show fixations", false); showFixations.setToolTipText("Show fixations for recalled scene"); showFixations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { _sceneDisplay.setShowFixations(showFixations.isSelected()); } }); buttons.add(Box.createRigidArea(new Dimension(0, 20))); buttons.add(labelledSpinner); buttons.add(recallButton); buttons.add(Box.createRigidArea(new Dimension(0, 20))); buttons.add(showFixations); buttons.add(Box.createRigidArea(new Dimension(0, 20))); // TODO: There must be a better solution to this problem! JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(buttons, BorderLayout.NORTH); return panel; }