List of usage examples for javax.swing JSpinner JSpinner
public JSpinner(SpinnerModel model)
From source file:org.cytoscape.dyn.internal.graphMetrics.SaveChartDialog.java
public SaveChartDialog(JFrame frame, JFreeChart chart) { super(frame, "Save Chart to File", false); this.chart = chart; JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4)); sizePanel.setBorder(BorderFactory.createTitledBorder("Image Size")); // Add a spinner for choosing width sizePanel.add(new JLabel("Width:", SwingConstants.RIGHT)); int width = ChartPanel.DEFAULT_WIDTH; int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH; int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH; SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1); sizePanel.add(widthSpinner = new JSpinner(widthSettings)); sizePanel.add(new JLabel("pixels")); // Add a spinner for choosing height sizePanel.add(new JLabel("Height:", SwingConstants.RIGHT)); int height = ChartPanel.DEFAULT_HEIGHT; int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT; int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT; SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1); sizePanel.add(heightSpinner = new JSpinner(heightSettings)); sizePanel.add(new JLabel("pixels")); JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 4, 0)); saveChartButton = new JButton("Save"); saveChartButton.setMaximumSize(new Dimension(Short.MAX_VALUE, saveChartButton.getHeight())); saveChartButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.setMaximumSize(new Dimension(Short.MAX_VALUE, cancelButton.getHeight())); cancelButton.addActionListener(this); buttonsPanel.add(saveChartButton);//w w w . j a v a 2 s . co m buttonsPanel.add(cancelButton); Box buttonsBox = Box.createHorizontalBox(); buttonsBox.add(Box.createHorizontalGlue()); buttonsBox.add(buttonsPanel); buttonsBox.add(Box.createHorizontalGlue()); Container contentPane = getContentPane(); contentPane.add(sizePanel, BorderLayout.NORTH); contentPane.add(Box.createVerticalStrut(3)); contentPane.add(buttonsBox, BorderLayout.PAGE_END); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getRootPane().setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); pack(); setModal(true); setResizable(false); setLocationRelativeTo(frame); }
From source file:be.fedict.eid.tsl.tool.SignSelectPkcs11FinishablePanel.java
@Override public Component getComponent() { LOG.debug("get component"); if (null == this.component) { /*//w ww . j a va 2s. co m * We need to return the same component each time, else the * validate() logic doesn't work as expected. */ JPanel panel = new JPanel(); BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.PAGE_AXIS); panel.setLayout(boxLayout); JPanel infoPanel = new JPanel(); infoPanel.add(new JLabel("Please select a PKCS#11 library.")); panel.add(infoPanel); JPanel browsePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(browsePanel); browsePanel.add(new JLabel("PKCS#11 library:")); this.pkcs11TextField = new JTextField(30); browsePanel.add(this.pkcs11TextField); JButton browseButton = new JButton("Browse..."); browseButton.addActionListener(this); browsePanel.add(browseButton); JPanel slotIdxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(slotIdxPanel); slotIdxPanel.add(new JLabel("Slot index:")); SpinnerModel spinnerModel = new SpinnerNumberModel(0, 0, 10, 1); this.slotIdxSpinner = new JSpinner(spinnerModel); slotIdxPanel.add(this.slotIdxSpinner); this.component = panel; } return this.component; }
From source file:filterviewplugin.FilterViewSettingsTab.java
public JPanel createSettingsPanel() { final EnhancedPanelBuilder panelBuilder = new EnhancedPanelBuilder(FormFactory.RELATED_GAP_COLSPEC.encode() + ',' + FormFactory.PREF_COLSPEC.encode() + ',' + FormFactory.RELATED_GAP_COLSPEC.encode() + ',' + FormFactory.PREF_COLSPEC.encode() + ", fill:default:grow"); final CellConstraints cc = new CellConstraints(); final JLabel label = new JLabel(mLocalizer.msg("daysToShow", "Days to show")); panelBuilder.addRow();//from w w w . ja v a2s. c o m panelBuilder.add(label, cc.xy(2, panelBuilder.getRow())); final SpinnerNumberModel model = new SpinnerNumberModel(3, 1, 7, 1); mSpinner = new JSpinner(model); mSpinner.setValue(mSettings.getDays()); panelBuilder.add(mSpinner, cc.xy(4, panelBuilder.getRow())); panelBuilder.addParagraph(mLocalizer.msg("filters", "Filters to show")); mFilterList = new SelectableItemList(mSettings.getActiveFilterNames(), FilterViewSettings.getAvailableFilterNames()); mIcons.clear(); for (String filterName : FilterViewSettings.getAvailableFilterNames()) { mIcons.put(filterName, mSettings.getFilterIconName(mSettings.getFilter(filterName))); } mFilterList.addCenterRendererComponent(String.class, new SelectableItemRendererCenterComponentIf() { private DefaultListCellRenderer mRenderer = new DefaultListCellRenderer(); public void calculateSize(JList list, int index, JPanel contentPane) { } public JPanel createCenterPanel(JList list, Object value, int index, boolean isSelected, boolean isEnabled, JScrollPane parentScrollPane, int leftColumnWidth) { DefaultListCellRenderer label = (DefaultListCellRenderer) mRenderer .getListCellRendererComponent(list, value, index, isSelected, false); String filterName = value.toString(); String iconFileName = mIcons.get(filterName); Icon icon = null; if (!StringUtils.isEmpty(iconFileName)) { try { icon = FilterViewPlugin.getInstance().getIcon( FilterViewSettings.getIconDirectoryName() + File.separatorChar + iconFileName); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } label.setIcon(icon); } String text = filterName; if (icon == null) { text += " (" + mLocalizer.msg("noIcon", "no icon") + ')'; } label.setText(text); label.setHorizontalAlignment(SwingConstants.LEADING); label.setVerticalAlignment(SwingConstants.CENTER); label.setOpaque(false); JPanel panel = new JPanel(new BorderLayout()); if (isSelected && isEnabled) { panel.setOpaque(true); panel.setForeground(list.getSelectionForeground()); panel.setBackground(list.getSelectionBackground()); } else { panel.setOpaque(false); panel.setForeground(list.getForeground()); panel.setBackground(list.getBackground()); } panel.add(label, BorderLayout.WEST); return panel; } }); panelBuilder.addGrowingRow(); panelBuilder.add(mFilterList, cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1)); panelBuilder.addRow(); mFilterButton = new JButton(mLocalizer.msg("changeIcon", "Change icon")); mFilterButton.setEnabled(false); panelBuilder.add(mFilterButton, cc.xyw(2, panelBuilder.getRow(), 1)); mRemoveButton = new JButton(mLocalizer.msg("deleteIcon", "Remove icon")); mRemoveButton.setEnabled(false); panelBuilder.add(mRemoveButton, cc.xyw(4, panelBuilder.getRow(), 1)); mFilterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SelectableItem item = (SelectableItem) mFilterList.getSelectedValue(); String filterName = (String) item.getItem(); chooseIcon(filterName); } }); mFilterList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { mFilterButton.setEnabled(mFilterList.getSelectedValue() != null); mRemoveButton.setEnabled(mFilterButton.isEnabled()); } }); mRemoveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SelectableItem item = (SelectableItem) mFilterList.getSelectedValue(); String filterName = (String) item.getItem(); mIcons.put(filterName, ""); mFilterList.updateUI(); } }); return panelBuilder.getPanel(); }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel constructTrainingOptions() { _maxTrainingCycles = new JSpinner(new SpinnerNumberModel(5, 1, 1000, 1)); _numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1)); _maxNetworkSize = new JSpinner(new SpinnerNumberModel(100000, 1, 10000000, 1)); JPanel panel = new JPanel(); panel.setLayout(new SpringLayout()); Utilities.addLabel(panel, "Domain of scenes:", _domainSelector); Utilities.addLabel(panel, "Number of scenes:", new JLabel("" + _scenes.size())); Utilities.addLabel(panel, "Maximum training cycles:", _maxTrainingCycles); Utilities.addLabel(panel, "Number of fixations per scene:", _numFixations); Utilities.addLabel(panel, "Maximum network size:", _maxNetworkSize); Utilities.makeCompactGrid(panel, 5, 2, 3, 3, 10, 5); panel.setMaximumSize(panel.getPreferredSize()); JPanel ePanel = new JPanel(); ePanel.setLayout(new GridLayout(1, 1)); ePanel.add(panel);//from w w w. j a v a 2 s . c o m return ePanel; }
From source file:biomine.bmvis2.pipeline.KMedoidsHighlight.java
@Override public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { Box ret = new Box(BoxLayout.X_AXIS); ret.add(new JLabel("k:")); final JSpinner spin = new JSpinner(new SpinnerNumberModel(3, 1, 1000, 1)); spin.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setK(((Number) spin.getValue()).intValue()); v.settingsChanged(false);//from w ww.jav a 2 s . com } }); ret.add(spin); final JCheckBox showClustersBox = new JCheckBox("Color clusters"); ret.add(showClustersBox); showClustersBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { showClusters = showClustersBox.isSelected(); v.settingsChanged(false); } }); return ret; }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.DendogramView.java
/** * @param t//w w w . jav a 2 s.c om * @param numClusters2 */ public void update(ClusteringTree t, int numClusters) { frame.setVisible(true); frame.getContentPane().removeAll(); try { // create spinner-panel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters"); spinnerCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1)); spinnerCluster.setValue(numClusters); spinnerCluster.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (mMainSpinnerCluster != null) { mMainSpinnerCluster.setValue(((JSpinner) e.getSource()).getValue()); } } }); UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerCluster); frame.getContentPane().add(clusterPanel, BorderLayout.NORTH); // create graph VisualizationViewer g = generateGraph(t, numClusters); frame.getContentPane().add(g, BorderLayout.CENTER); frame.setSize(frame.getWidth() + 1, frame.getHeight() + 1); frame.setSize(frame.getWidth() - 1, frame.getHeight() - 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:endrov.typeTimeRemap.TimeRemapWindow.java
/** * Add an entry. Does not update UI/* ww w . j a v a2 s .c om*/ */ private void addEntry(EvDecimal frame, EvDecimal time) { TimeRemap meta = objectCombo.getSelectedObject(); if (meta != null) { InputLine inp = new InputLine(); inp.frame = new JSpinner(new SpinnerFrameModelFT()); inp.time = new JSpinner(new SpinnerFrameModelFT()); EvFrameEditor frameEditor = new EvFrameEditor(inp.frame); EvFrameEditor frameEditor2 = new EvFrameEditor(inp.time); inp.frame.setEditor(frameEditor); inp.time.setEditor(frameEditor2); inp.frame.setValue(frame); inp.time.setValue(time); inputVector.add(inp); inp.frame.addChangeListener(this); inp.time.addChangeListener(this); inp.bDelete.addActionListener(this); } else showErrorDialog("No object selected"); }
From source file:com.diversityarrays.kdxplore.design.SheetChooserPanel.java
public SheetChooserPanel(BackgroundRunner br, Consumer<String> onSheetChosen /*, Component ... more */) { super(new BorderLayout()); this.backgroundRunner = br; this.onChoice = onSheetChosen; sheetComboBox.addActionListener(new ActionListener() { @Override//w w w . j a v a 2 s . c o m public void actionPerformed(ActionEvent e) { Object item = sheetComboBox.getSelectedItem(); if (item == null) { selectedSheetName = null; } else { selectedSheetName = sheetComboBox.getSelectedItem().toString(); } updateUsingSelected(); } }); spinnerModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateUsingSelected(); } }); GuiUtil.setVisibleRowCount(dataPreviewTable, DEFAULT_VISIBLE_ROWCOUNT); Box top = Box.createHorizontalBox(); top.add(new JLabel("Select Sheet: ")); top.add(sheetComboBox); top.add(Box.createHorizontalGlue()); top.add(new JLabel("Preview:")); top.add(new JSpinner(spinnerModel)); top.add(Box.createHorizontalGlue()); top.add(new JButton(useAction)); // if (more != null) { // for (Component c : more) { // top.add(c); // } // } add(top, BorderLayout.NORTH); add(dataPreviewScrollPane, BorderLayout.CENTER); useAction.setEnabled(false); }
From source file:endrov.frameTime.FrameTimeWindow.java
/** * Add an entry. Does not update UI//from w ww . ja v a 2 s . c o m */ public void addEntry(EvDecimal frame, EvDecimal time) { FrameTime meta = objectCombo.getSelectedObject(); if (meta != null) { InputLine inp = new InputLine(); inp.frame = new JSpinner(new SpinnerFrameModelFT()); inp.time = new JSpinner(new SpinnerFrameModelFT()); EvFrameEditor frameEditor = new EvFrameEditor(inp.frame); EvFrameEditor frameEditor2 = new EvFrameEditor(inp.time); inp.frame.setEditor(frameEditor); inp.time.setEditor(frameEditor2); inp.frame.setValue(frame); inp.time.setValue(time); for (int i = 0; i < 2; i++) { // field[i]=new JSpinner(new EvDecimalSpinnerModel()); // field[i].setEditor(new EvDecimalEditor(field[i])); } inputVector.add(inp); inp.frame.addChangeListener(this); inp.time.addChangeListener(this); inp.bDelete.addActionListener(this); } }
From source file:e3fraud.gui.MainWindow.java
public MainWindow() { super(new BorderLayout(5, 5)); extended = false;/* w w w .j av a 2s. c o m*/ //Create the log first, because the action listeners //need to refer to it. log = new JTextArea(10, 50); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false); logScrollPane = new JScrollPane(log); DefaultCaret caret = (DefaultCaret) log.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); // create the progress bar progressBar = new JProgressBar(0, 100); progressBar.setValue(progressBar.getMinimum()); progressBar.setVisible(false); progressBar.setStringPainted(true); //Create the settings pane generationSettingLabel = new JLabel("Generate:"); SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1); collusionSettingsPanel = new JPanel(new FlowLayout()) { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS)); collusionsButton = new JSpinner(collusionsSpinnerModel); collusionsLabel = new JLabel("collusion(s)"); collusionSettingsPanel.add(collusionsButton); collusionSettingsPanel.add(collusionsLabel); rankingSettingLabel = new JLabel("Rank by:"); lossButton = new JRadioButton("loss"); lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)"); gainButton = new JRadioButton("gain"); gainButton.setToolTipText( "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)"); lossGainButton = new JRadioButton("loss + gain"); lossGainButton.setToolTipText( "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment"); //gainLossButton = new JRadioButton("gain + loss"); lossGainButton.setSelected(true); rankingGroup = new ButtonGroup(); rankingGroup.add(lossButton); rankingGroup.add(gainButton); rankingGroup.add(lossGainButton); //rankingGroup.add(gainLossButton); groupingSettingLabel = new JLabel("Group by:"); groupingButton = new JCheckBox("collusion"); groupingButton.setToolTipText( "Groups sub-ideal models based on the pair of actors colluding before ranking them"); groupingButton.setSelected(false); refreshButton = new JButton("Refresh"); refreshButton.addActionListener(this); settingsPanel = new JPanel(); settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS)); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(generationSettingLabel); collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(collusionSettingsPanel); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT); settingsPanel.add(rankingSettingLabel); settingsPanel.add(lossButton); settingsPanel.add(gainButton); settingsPanel.add(lossGainButton); //settingsPanel.add(gainLossButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(groupingSettingLabel); settingsPanel.add(groupingButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(refreshButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 20))); progressBar.setPreferredSize( new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height)); settingsPanel.add(progressBar); //Create the result tree root = new DefaultMutableTreeNode("No models to display"); treeModel = new DefaultTreeModel(root); tree = new JTree(treeModel); //tree.setUI(new CustomTreeUI()); tree.setCellRenderer(new CustomTreeCellRenderer(tree)); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setLargeModel(true); resultScrollPane = new JScrollPane(tree); tree.addTreeSelectionListener(treeSelectionListener); //tree.setShowsRootHandles(true); //Create a file chooser for saving sfc = new JFileChooser(); FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" }); sfc.addChoosableFileFilter(jpegFilter); sfc.setFileFilter(jpegFilter); //Create a file chooser for loading fc = new JFileChooser(); FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF"); fc.addChoosableFileFilter(rdfFilter); fc.setFileFilter(rdfFilter); //Create the open button. openButton = new JButton("Load model", createImageIcon("images/Open24.png")); openButton.addActionListener(this); openButton.setToolTipText("Load a e3value model"); //Create the ideal graph button. idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png")); idealGraphButton.setToolTipText("Display ideal profitability graph"); idealGraphButton.addActionListener(this); Dimension thinButtonDimension = new Dimension(15, 420); //Create the expand subideal graph button. expandButton = new JButton(">"); expandButton.setPreferredSize(thinButtonDimension); expandButton.setMargin(new Insets(0, 0, 0, 0)); expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model"); expandButton.addActionListener(this); //Create the collapse sub-ideal graph button. collapseButton = new JButton("<"); collapseButton.setPreferredSize(thinButtonDimension); collapseButton.setMargin(new Insets(0, 0, 0, 0)); collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model"); collapseButton.addActionListener(this); //Create the generation button. generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png")); generateButton.addActionListener(this); generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded"); //Create the chart panel chartPane = new JPanel(); chartPane.setLayout(new FlowLayout(FlowLayout.LEFT)); chartPane.add(expandButton); //For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(openButton); buttonPanel.add(Box.createRigidArea(new Dimension(20, 0))); buttonPanel.add(generateButton); buttonPanel.add(Box.createRigidArea(new Dimension(10, 0))); buttonPanel.add(idealGraphButton); //Add the buttons, the ranking options, the result list and the log to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(settingsPanel, BorderLayout.LINE_START); add(resultScrollPane, BorderLayout.CENTER); add(logScrollPane, BorderLayout.PAGE_END); add(chartPane, BorderLayout.LINE_END); //and make a nice border around it setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); }