List of usage examples for javax.swing SpinnerNumberModel SpinnerNumberModel
public SpinnerNumberModel()
SpinnerNumberModel
with no minimum
or maximum
value, stepSize
equal to one, and an initial value of zero. From source file:SpinnerNumberSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerNumberModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("Numbers"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90);/*from w w w. j a v a 2 s. c o m*/ frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model3 = new SpinnerNumberModel(); JSpinner spinner3 = new JSpinner(model3); JLabel label3 = new JLabel("Numbers"); JPanel panel3 = new JPanel(new BorderLayout()); panel3.add(label3, BorderLayout.WEST); panel3.add(spinner3, BorderLayout.CENTER); frame.add(panel3, BorderLayout.SOUTH); frame.setSize(200, 90);//ww w .java2s .co m frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Source: " + e.getSource()); }//from ww w . j a va2s . c o m }; SpinnerModel model3 = new SpinnerNumberModel(); JSpinner spinner3 = new JSpinner(model3); spinner3.addChangeListener(listener); ChangeListener[] changeListeners = spinner3.getChangeListeners(); frame.add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Source: " + e.getSource()); }/* w w w. j a va 2 s. co m*/ }; SpinnerModel model3 = new SpinnerNumberModel(); JSpinner spinner3 = new JSpinner(model3); spinner3.addChangeListener(listener); frame.add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); }
From source file:Main.java
private static JSpinner makeDigitsOnlySpinnerUsingDocumentFilter() { JSpinner spinner = new JSpinner(new SpinnerNumberModel()); JSpinner.NumberEditor jsEditor = (JSpinner.NumberEditor) spinner.getEditor(); JFormattedTextField textField = jsEditor.getTextField(); DocumentFilter digitOnlyFilter = new DocumentFilter() { @Override// www. java 2s . co m public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { if (stringContainsOnlyDigits(string)) { super.insertString(fb, offset, string, attr); } } @Override public void remove(FilterBypass fb, int offset, int length) throws BadLocationException { super.remove(fb, offset, length); } @Override public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException { if (stringContainsOnlyDigits(text)) { super.replace(fb, offset, length, text, attrs); } } private boolean stringContainsOnlyDigits(String text) { for (int i = 0; i < text.length(); i++) { if (!Character.isDigit(text.charAt(i))) { return false; } } return true; } }; NumberFormat format = NumberFormat.getPercentInstance(); format.setGroupingUsed(false); format.setGroupingUsed(true); format.setMaximumIntegerDigits(10); format.setMaximumFractionDigits(2); format.setMinimumFractionDigits(5); textField.setFormatterFactory(new DefaultFormatterFactory(new InternationalFormatter(format) { @Override protected DocumentFilter getDocumentFilter() { return digitOnlyFilter; } })); return spinner; }
From source file:net.pms.movieinfo.MovieInfo.java
@Override public JComponent config() { FormLayout layout = new FormLayout( "left:pref, 2dlu, p,2dlu, p,2dlu, p, 2dlu, p, 2dlu, p,2dlu, p,200dlu, pref:grow", //$NON-NLS-1$ "p, 5dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p,0:grow"); //$NON-NLS-1$ PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.EMPTY);/*ww w .j av a2 s. co m*/ builder.opaque(false); CellConstraints cc = new CellConstraints(); JComponent cmp = builder.addSeparator("MOVIE INFO CONFIG", cc.xy(1, 1)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); pluginsField = new JTextField(); pluginsField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented if (configuration.getPlugins() != null) pluginsField.setText(configuration.getPlugins()); pluginsField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configuration.setPlugins(pluginsField.getText()); } }); builder.addLabel("Plugins to use (in prioritized order):", cc.xy(1, 3)); builder.add(pluginsField, cc.xyw(3, 3, 12)); maxNumberOfActorsField = new JSpinner(new SpinnerNumberModel()); maxNumberOfActorsField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented maxNumberOfActorsField.setValue(configuration.getMaxNumberOfActors()); maxNumberOfActorsField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { configuration.setMaxNumberOfActors((Integer) maxNumberOfActorsField.getValue()); } }); builder.addLabel("Maximum number of actors to display:", cc.xy(1, 5)); builder.add(maxNumberOfActorsField, cc.xy(3, 5)); downloadCoverField = new JCheckBox(); downloadCoverField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented downloadCoverField.setSelected(configuration.getDownloadCover()); downloadCoverField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { configuration.setDownloadCover(downloadCoverField.isSelected()); } }); builder.addLabel("Download cover to movie folder:", cc.xy(5, 5)); builder.add(downloadCoverField, cc.xy(7, 5)); displayInfoField = new JTextField(); displayInfoField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented if (configuration.getDisplayInfo() != null) { displayInfoField.setText(configuration.getDisplayInfoAsString()); } displayInfoField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //TODO: Needs verification logics configuration.setDisplayInfoFromString(displayInfoField.getText()); } }); builder.addLabel("DisplayInfo:", cc.xy(13, 5)); builder.add(displayInfoField, cc.xyw(14, 5, 2)); plotLineLengthField = new JSpinner(new SpinnerNumberModel()); plotLineLengthField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented plotLineLengthField.setValue(configuration.getPlotLineLength()); plotLineLengthField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { configuration.setPlotLineLength((Integer) plotLineLengthField.getValue()); } }); builder.addLabel("Plot line length:", cc.xy(9, 5)); builder.add(plotLineLengthField, cc.xy(11, 5)); filterField = new JTextField(); filterField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented if (configuration.getFilters() != null) { filterField.setText(configuration.getFiltersAsString()); } filterField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //TODO: Needs verification logics configuration.setFiltersFromString(filterField.getText()); } }); ScanPath = new JTextField(); builder.addLabel("Filter:", cc.xy(1, 7)); builder.add(filterField, cc.xyw(3, 7, 12)); builder.addLabel("Scan path:", cc.xy(1, 9)); builder.add(ScanPath, cc.xyw(3, 9, 12)); ScanPath.setText((String) PMS.getConfiguration().getCustomProperty("movieinfo.scan_path")); JButton scan = new JButton("Scan files"); scan.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (mdb != null) { if (!mdb.isScanLibraryRunning()) { int option = JOptionPane.showConfirmDialog(LooksFrame.get(), Messages.getString("FoldTab.3") + Messages.getString("FoldTab.4"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { mdb.scanLibrary(ScanPath.getText()); } } else { int option = JOptionPane.showConfirmDialog(LooksFrame.get(), Messages.getString("FoldTab.10"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { mdb.stopScanLibrary(); } } } } }); builder.add(scan, cc.xy(1, 11)); return builder.getPanel(); }
From source file:ch.epfl.lis.gnwgui.Simulation.java
/** * Constructor/*from w w w .java2s. co m*/ */ public Simulation(Frame aFrame, NetworkElement item) { super(aFrame); item_ = item; GnwSettings settings = GnwSettings.getInstance(); // Model model_.setModel(new DefaultComboBoxModel( new String[] { "Deterministic (ODEs)", "Stochastic (SDEs)", "Run both (ODEs and SDEs)" })); if (settings.getSimulateODE() && !settings.getSimulateSDE()) model_.setSelectedIndex(0); else if (!settings.getSimulateODE() && settings.getSimulateSDE()) model_.setSelectedIndex(1); else if (settings.getSimulateODE() && settings.getSimulateSDE()) model_.setSelectedIndex(2); // Experiments wtSS_.setSelected(true); wtSS_.setEnabled(false); knockoutSS_.setSelected(settings.generateSsKnockouts()); knockdownSS_.setSelected(settings.generateSsKnockdowns()); multifactorialSS_.setSelected(settings.generateSsMultifactorial()); dualKnockoutSS_.setSelected(settings.generateSsDualKnockouts()); knockoutTS_.setSelected(settings.generateTsKnockouts()); knockdownTS_.setSelected(settings.generateTsKnockdowns()); multifactorialTS_.setSelected(settings.generateTsMultifactorial()); dualKnockoutTS_.setSelected(settings.generateTsDualKnockouts()); timeSeriesAsDream4_.setSelected(settings.generateTsDREAM4TimeSeries()); // Set model of "number of time series" spinner SpinnerNumberModel model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum(10000); model.setStepSize(1); model.setValue(settings.getNumTimeSeries()); numTimeSeries_.setModel(model); // Set model of "duration" spinner model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum(100000); model.setStepSize(10); model.setValue((int) settings.getMaxtTimeSeries()); tmax_.setModel(model); // Set model of "number of points per time series" spinner model = new SpinnerNumberModel(); model.setMinimum(3); model.setMaximum(100000); model.setStepSize(10); double dt = settings.getDt(); double maxt = settings.getMaxtTimeSeries(); int numMeasuredPoints = (int) Math.round(maxt / dt) + 1; if (dt * (numMeasuredPoints - 1) != maxt) throw new RuntimeException( "Duration of time series (GnwSettings.maxtTimeSeries_) must be a multiple of the time step (GnwSettings.dt_)"); model.setValue(numMeasuredPoints); numPointsPerTimeSeries_.setModel(model); perturbationNew_.setSelected(!settings.getLoadPerturbations()); perturbationLoad_.setSelected(settings.getLoadPerturbations()); // Noise // Diffusion multiplier (SDE only) model = new SpinnerNumberModel(); model.setMinimum(0.0); model.setMaximum(10.); model.setStepSize(0.01); model.setValue(settings.getNoiseCoefficientSDE()); sdeDiffusionCoeff_.setModel(model); noNoise_.setSelected(!settings.getAddMicroarrayNoise() && !settings.getAddNormalNoise() && !settings.getAddLognormalNoise()); useMicroarrayNoise_.setSelected(settings.getAddMicroarrayNoise()); useLogNormalNoise_.setSelected(settings.getAddNormalNoise() || settings.getAddLognormalNoise()); addGaussianNoise_.setSelected(settings.getAddNormalNoise()); addLogNormalNoise_.setSelected(settings.getAddLognormalNoise()); // Set model of "Gaussian noise std" spinner model = new SpinnerNumberModel(); model.setMinimum(0.000001); model.setMaximum(10.); model.setStepSize(0.01); model.setValue(settings.getNormalStdev()); gaussianNoise_.setModel(model); // Set model of "log-normal noise std" spinner model = new SpinnerNumberModel(); model.setMinimum(0.000001); model.setMaximum(10.); model.setStepSize(0.01); model.setValue(settings.getLognormalStdev()); logNormalNoise_.setModel(model); normalizeNoise_.setSelected(settings.getNormalizeAfterAddingNoise()); // Set the text field with the user path userPath_.setText(GnwSettings.getInstance().getOutputDirectory()); setModelAction(); setExperimentAction(); setNoiseAction(); String title1, title2; title1 = title2 = ""; if (item_ instanceof StructureElement) { ImodNetwork network = ((StructureElement) item_).getNetwork(); title1 = item_.getLabel(); title2 = network.getSize() + " nodes, " + network.getNumEdges() + " edges"; } else if (item_ instanceof DynamicalModelElement) { GeneNetwork geneNetwork = ((DynamicalModelElement) item_).getGeneNetwork(); title1 = item_.getLabel(); title2 = geneNetwork.getSize() + " genes, " + geneNetwork.getNumEdges() + " interactions"; } setHeaderInfo(title1 + " (" + title2 + ")"); // Set tool tips for all elements of the window addTooltips(); /** * ACTIONS */ model_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setModelAction(); } }); dream4Settings_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setDream4Settings(); } }); browse_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { IODialog dialog = new IODialog(new Frame(""), "Select Target Folder", GnwSettings.getInstance().getOutputDirectory(), IODialog.LOAD); dialog.selectOnlyFolder(true); dialog.display(); if (dialog.getSelection() != null) userPath_.setText(dialog.getSelection()); } }); runButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { enterAction(); } }); cancelButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { GnwSettings.getInstance().stopBenchmarkGeneration(true); escapeAction(); } }); knockoutSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); knockdownSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); multifactorialSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); dualKnockoutSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); knockoutTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); knockdownTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); multifactorialTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); dualKnockoutTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); timeSeriesAsDream4_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); noNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); useMicroarrayNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); useLogNormalNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); addGaussianNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); addLogNormalNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); }
From source file:com.anrisoftware.prefdialog.fields.spinner.SpinnerField.java
private SpinnerModel createDefaultModel() { SpinnerModel model = createNumberModel(); model = model == null ? createDateModel() : model; model = model == null ? createListModel() : model; model = model == null ? new SpinnerNumberModel() : model; return model; }
From source file:adams.gui.tools.TelnetPanel.java
/** * For initializing the GUI./*from w ww.java 2 s.c o m*/ */ @Override protected void initGUI() { JPanel topPanel; JPanel bottomPanel; JLabel label; super.initGUI(); setLayout(new BorderLayout()); // connection topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); add(topPanel, BorderLayout.NORTH); m_TextRemote = new BaseTextField(20); label = new JLabel("Remote"); label.setDisplayedMnemonic('R'); label.setLabelFor(m_TextRemote); topPanel.add(label); topPanel.add(m_TextRemote); m_PortModel = new SpinnerNumberModel(); m_PortModel.setMinimum(1); m_PortModel.setMaximum(65536); m_PortModel.setStepSize(1); m_PortModel.setValue(23); m_SpinnerPort = new JSpinner(m_PortModel); label = new JLabel("Port"); label.setDisplayedMnemonic('P'); label.setLabelFor(m_SpinnerPort); topPanel.add(label); topPanel.add(m_SpinnerPort); m_ButtonConnection = new BaseButton(); m_ButtonConnection.setMnemonic('n'); m_ButtonConnection.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleConnectionEvent(); } }); topPanel.add(m_ButtonConnection); // output m_ButtonClear = new BaseButton("Clear", GUIHelper.getIcon("new.gif")); m_ButtonClear.setMnemonic('l'); m_ButtonClear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { m_TextOutput.setText(""); } }); m_ButtonCopy = new BaseButton("Copy", GUIHelper.getIcon("copy.gif")); m_ButtonCopy.setMnemonic('C'); m_ButtonCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (m_TextOutput.getSelectedText().length() > 0) ClipboardHelper.copyToClipboard(m_TextOutput.getSelectedText()); else if (m_TextOutput.getText().length() > 0) ClipboardHelper.copyToClipboard(m_TextOutput.getText()); } }); m_TextOutput = new BaseTextAreaWithButtons(10, 40); m_TextOutput.setTextFont(Fonts.getMonospacedFont()); m_TextOutput.addToButtonsPanel(m_ButtonClear); m_TextOutput.addToButtonsPanel(m_ButtonCopy); add(m_TextOutput, BorderLayout.CENTER); // commands bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); add(bottomPanel, BorderLayout.SOUTH); m_TextCommand = new BaseTextField(40); m_TextCommand.setFont(Fonts.getMonospacedFont()); m_TextCommand.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: e.consume(); execCommand(); break; case KeyEvent.VK_UP: e.consume(); previousCommand(); break; case KeyEvent.VK_DOWN: e.consume(); nextCommand(); break; } } }); label = new JLabel("Command"); label.setDisplayedMnemonic('m'); label.setLabelFor(m_TextCommand); bottomPanel.add(label); bottomPanel.add(m_TextCommand); m_ButtonCommand = new BaseButton(GUIHelper.getIcon("run.gif")); m_ButtonCommand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { execCommand(); } }); bottomPanel.add(m_ButtonCommand); }
From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java
public FieldViewDialog(Window owner, String title, SampleGroupChoice sgcSamples, Trial trial, SampleGroupChoice sgcNewMedia, KDSmartDatabase db) throws IOException { super(owner, title, ModalityType.MODELESS); advanceRetreatControls = Box.createHorizontalBox(); advanceRetreatControls.add(new JButton(retreatAction)); advanceRetreatControls.add(new JButton(advanceAction)); autoAdvanceControls = Box.createHorizontalBox(); autoAdvanceControls.add(new JButton(autoAdvanceAction)); autoAdvanceOption.addActionListener(new ActionListener() { @Override/* ww w. j a v a2 s . c o m*/ public void actionPerformed(ActionEvent e) { updateMovementControls(); } }); this.database = db; this.sampleGroupChoiceForSamples = sgcSamples; this.sampleGroupChoiceForNewMedia = sgcNewMedia; NumberSpinner fontSpinner = new NumberSpinner(new SpinnerNumberModel(), "0.00"); this.fieldViewPanel = FieldViewPanel.create(database, trial, SeparatorVisibilityOption.VISIBLE, null, Box.createHorizontalGlue(), new JButton(showInfoAction), Box.createHorizontalGlue(), new JLabel("Font Size:"), fontSpinner, Box.createHorizontalGlue(), advanceRetreatControls, autoAdvanceOption, autoAdvanceControls); initialiseAction(advanceAction, "ic_object_advance_black.png", "Auto-Advance"); this.xyProvider = fieldViewPanel.getXYprovider(); this.traitMap = fieldViewPanel.getTraitMap(); fieldLayoutTable = fieldViewPanel.getFieldLayoutTable(); JScrollPane scrollPane = fieldViewPanel.getFieldTableScrollPane(); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); fieldLayoutTable.setTransferHandler(flth); fieldLayoutTable.setDropMode(DropMode.ON); fieldLayoutTable.addMouseListener(new MouseAdapter() { JPopupMenu popupMenu; @Override public void mouseClicked(MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e) || 1 != e.getClickCount()) { return; } Point pt = e.getPoint(); int row = fieldLayoutTable.rowAtPoint(pt); if (row >= 0) { int col = fieldLayoutTable.columnAtPoint(pt); if (col >= 0) { Plot plot = fieldViewPanel.getPlotAt(col, row); if (plot != null) { if (popupMenu == null) { popupMenu = new JPopupMenu("View Attachments"); } popupMenu.removeAll(); Set<File> set = plot.getMediaFiles(); if (Check.isEmpty(set)) { popupMenu.add(new JMenuItem("No Attachments available")); } else { for (File file : set) { Action a = new AbstractAction(file.getName()) { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().browse(file.toURI()); } catch (IOException e1) { MsgBox.warn(FieldViewDialog.this, e1, file.getName()); } } }; popupMenu.add(new JMenuItem(a)); } } popupMenu.show(fieldLayoutTable, pt.x, pt.y); } } } } }); Font font = fieldLayoutTable.getFont(); float fontSize = font.getSize2D(); fontSizeModel = new SpinnerNumberModel(fontSize, fontSize, 50.0, 1.0); fontSpinner.setModel(fontSizeModel); fontSizeModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { float fsize = fontSizeModel.getNumber().floatValue(); System.out.println("Using fontSize=" + fsize); Font font = fieldLayoutTable.getFont().deriveFont(fsize); fieldLayoutTable.setFont(font); FontMetrics fm = fieldLayoutTable.getFontMetrics(font); int lineHeight = fm.getMaxAscent() + fm.getMaxDescent(); fieldLayoutTable.setRowHeight(4 * lineHeight); // GuiUtil.initialiseTableColumnWidths(fieldLayoutTable, false); fieldLayoutTable.repaint(); } }); fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fieldLayoutTable.setResizable(true, true); fieldLayoutTable.getTableColumnResizer().setResizeAllColumns(true); advanceAction.setEnabled(false); fieldLayoutTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { handlePlotSelection(); } } }); TableColumnModel columnModel = fieldLayoutTable.getColumnModel(); columnModel.addColumnModelListener(new TableColumnModelListener() { @Override public void columnSelectionChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { handlePlotSelection(); } } @Override public void columnRemoved(TableColumnModelEvent e) { } @Override public void columnMoved(TableColumnModelEvent e) { } @Override public void columnMarginChanged(ChangeEvent e) { } @Override public void columnAdded(TableColumnModelEvent e) { } }); PropertyChangeListener listener = new PropertyChangeListener() { // Use a timer and redisplay other columns when delay is GT 100 ms Timer timer = new Timer(true); TimerTask timerTask; long lastActive; boolean busy = false; private int eventColumnWidth; private TableColumn eventColumn; @Override public void propertyChange(PropertyChangeEvent evt) { if (busy) { return; } if (evt.getSource() instanceof TableColumn && "width".equals(evt.getPropertyName())) { eventColumn = (TableColumn) evt.getSource(); eventColumnWidth = eventColumn.getWidth(); lastActive = System.currentTimeMillis(); if (timerTask == null) { timerTask = new TimerTask() { @Override public void run() { if (System.currentTimeMillis() - lastActive > 200) { timerTask.cancel(); timerTask = null; busy = true; try { for (Enumeration<TableColumn> en = columnModel.getColumns(); en .hasMoreElements();) { TableColumn tc = en.nextElement(); if (tc != eventColumn) { tc.setWidth(eventColumnWidth); } } } finally { busy = false; } } } }; timer.scheduleAtFixedRate(timerTask, 100, 150); } } } }; for (Enumeration<TableColumn> en = columnModel.getColumns(); en.hasMoreElements();) { TableColumn tc = en.nextElement(); tc.addPropertyChangeListener(listener); } Map<Integer, Plot> plotById = new HashMap<>(); for (Plot plot : fieldViewPanel.getFieldLayout()) { plotById.put(plot.getPlotId(), plot); } TrialItemVisitor<Sample> sampleVisitor = new TrialItemVisitor<Sample>() { @Override public void setExpectedItemCount(int count) { } @Override public boolean consumeItem(Sample sample) throws IOException { Plot plot = plotById.get(sample.getPlotId()); if (plot == null) { throw new IOException("Missing plot for plotId=" + sample.getPlotId() + " sampleIdent=" + Util.createUniqueSampleKey(sample)); } plot.addSample(sample); SampleCounts counts = countsByTraitId.get(sample.getTraitId()); if (counts == null) { counts = new SampleCounts(); countsByTraitId.put(sample.getTraitId(), counts); } if (sample.hasBeenScored()) { ++counts.scored; } else { ++counts.unscored; } return true; } }; database.visitSamplesForTrial(sampleGroupChoiceForSamples, trial.getTrialId(), SampleOrder.ALL_BY_PLOT_ID_THEN_TRAIT_ID_THEN_INSTANCE_NUMBER_ORDER_THEN_SPECIMEN_NUMBER, sampleVisitor); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.trial = trial; KDClientUtils.initAction(ImageId.SETTINGS_24, showInfoAction, "Trial Summary"); Action clear = new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { infoTextArea.setText(""); } }; JPanel bottom = new JPanel(new BorderLayout()); bottom.add(GuiUtil.createLabelSeparator("Plot Details", new JButton(clear)), BorderLayout.NORTH); bottom.add(new JScrollPane(infoTextArea), BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, fieldViewPanel, new JScrollPane(infoTextArea)); splitPane.setResizeWeight(0.0); splitPane.setOneTouchExpandable(true); setContentPane(splitPane); updateMovementControls(); pack(); }