List of usage examples for javax.swing SpinnerNumberModel SpinnerNumberModel
public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize)
SpinnerNumberModel
with the specified value
, minimum
/maximum
bounds, and stepSize
. From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.ConstraintPanel.java
/** * Inits the components.//from ww w. j a va2s. c o m */ private void initComponents() { String[] fields = new String[] { "has_dose", "has_value" }; fieldBox = new JComboBox(fields); fieldBox.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent arg0) { // get selected item selectedField = fieldBox.getSelectedItem().toString(); } }); // select has_value by default fieldBox.setSelectedItem(fields[1]); JPanel p1 = new JPanel(); p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS)); p1.add(new JLabel("Field Name")); p1.add(Box.createHorizontalStrut(10)); p1.add(fieldBox); Operator[] ops = { Operator.EQUAL_TO, Operator.BETWEEN, Operator.LESS_THAN, Operator.GREATER_THAN }; operatorsBox = new JComboBox(ops); // select operator 'equal to' by default operatorsBox.setSelectedItem(Operator.EQUAL_TO); selectedOperator = Operator.EQUAL_TO; operatorsBox.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { // get selected operator selectedOperator = Operator.valueOf(operatorsBox.getSelectedItem().toString()); if (selectedOperator == Operator.BETWEEN) { // enable second value spinner valueSpinner2.setEnabled(true); valueSpinnerCheckBox2.setEnabled(true); } else if (selectedOperator == Operator.EQUAL_TO) { // disable value 1 checkbox valueSpinnerCheckBox1.setEnabled(false); // disable value spinner 2 valueSpinner2.setEnabled(false); valueSpinnerCheckBox2.setEnabled(false); } else { // disable value 1 checkbox valueSpinnerCheckBox1.setEnabled(true); // disable value spinner 2 valueSpinner2.setEnabled(false); valueSpinnerCheckBox2.setEnabled(false); } } }); JPanel p2 = new JPanel(); p2.setLayout(new BoxLayout(p2, BoxLayout.LINE_AXIS)); p2.add(new JLabel("Operator")); p2.add(Box.createHorizontalStrut(20)); p2.add(operatorsBox); // create spinners SpinnerNumberModel model1 = new SpinnerNumberModel(0, 0, 10000, 0.1); SpinnerNumberModel model2 = new SpinnerNumberModel(0, 0, 10000, 0.1); valueSpinner1 = new JSpinner(model1); valueSpinner1.setName("valueSpinner1"); valueSpinner2 = new JSpinner(model2); valueSpinner2.setName("valueSpinner2"); // disable spinner 2 by default valueSpinner2.setEnabled(false); // create check boxes for inclusive ranges... valueSpinnerCheckBox1 = new JCheckBox(new AbstractAction("Inclusive") { public void actionPerformed(ActionEvent e) { value1Inclusive = valueSpinnerCheckBox1.isSelected(); } }); valueSpinnerCheckBox2 = new JCheckBox(new AbstractAction("Inclusive") { public void actionPerformed(ActionEvent e) { value2Inclusive = valueSpinnerCheckBox2.isSelected(); } }); JPanel p3 = new JPanel(); p3.setLayout(new BoxLayout(p3, BoxLayout.LINE_AXIS)); p3.add(new JLabel("Lower Bound")); p3.add(Box.createHorizontalStrut(10)); p3.add(valueSpinner1); JPanel lowerBoundPanel = new JPanel(new GridLayout(0, 1)); lowerBoundPanel.add(p3); lowerBoundPanel.add(valueSpinnerCheckBox1); JPanel p4 = new JPanel(); p4.setLayout(new BoxLayout(p4, BoxLayout.LINE_AXIS)); p4.add(new JLabel("Upper Bound")); p4.add(Box.createHorizontalStrut(10)); p4.add(valueSpinner2); JPanel upperBoundPanel = new JPanel(new GridLayout(0, 1)); upperBoundPanel.add(p4); upperBoundPanel.add(valueSpinnerCheckBox2); // set grid layout this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(p1); add(p2); add(lowerBoundPanel); add(upperBoundPanel); }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.simulator.viewcomponent.DataGenerationPanel.java
/** * Inits the components.//from w ww .j a va 2 s . c om */ public synchronized void initComponents() { while (activeFrame == null) { if (applicationService != null && applicationService.getFrameView() != null) { activeFrame = applicationService.getFrameView().getActiveFrame(); } } JPanel runPanel = new JPanel(); runPanel.setLayout(new BoxLayout(runPanel, BoxLayout.LINE_AXIS)); runPanel.setBorder(BorderFactory.createEmptyBorder(paddingSize, paddingSize, paddingSize, paddingSize)); JXLabel label = new JXLabel(); label.setLineWrap(true); label.setText( "<html>This panel allows the creation of clinically plausible data based on a query specification. " + "Please note that you <b>must</b> always specify a data generation source. " + "The rest of the parameters can be left in their default state. When you've configured the parameters " + "click the 'Generate data' button.</html>"); runPanel.add(label); runPanel.add(new JSeparator(SwingConstants.VERTICAL)); runPanel.add(Box.createHorizontalStrut(paddingSize)); JideButton runButton = new JideButton(new GenerateDataAction(applicationService, queryService, dataGenerationEngine, propertyChangeTrackerService)); runButton.setButtonStyle(ButtonStyle.HYPERLINK_STYLE); runPanel.add(runButton); runButton.setIcon(new ImageIcon(DataGenerationPanel.class.getResource("resources/linuxconf.png"))); runPanel.add(Box.createHorizontalStrut(paddingSize)); // create radio buttons for choosing source JRadioButton queryButton = new JRadioButton("Active Query"); queryButton.setSelected(true); queryButton.addActionListener(this); queryButton.setActionCommand("activeQuery"); JRadioButton fileButton = new JRadioButton("File"); fileButton.addActionListener(this); fileButton.setActionCommand("file"); JRadioButton folderButton = new JRadioButton("Folder"); folderButton.addActionListener(this); folderButton.setActionCommand("folder"); ButtonGroup bg = new ButtonGroup(); bg.add(queryButton); bg.add(fileButton); bg.add(folderButton); JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS)); // buttonsPanel.add(new JLabel("Select data generation source")); buttonsPanel.setBorder(BorderFactory.createTitledBorder("Select data generation source")); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(queryButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(fileButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(folderButton); locationField = new JTextField(100); JButton loadQueryButton = new JButton("Browse"); loadQueryButton.addActionListener(this); loadQueryButton.setActionCommand("load"); locationPanel = new JPanel(); locationPanel.setLayout(new BoxLayout(locationPanel, BoxLayout.LINE_AXIS)); locationPanel.add(new JLabel("Load file from")); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(locationField); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(loadQueryButton); JPanel lhsPanel = new JPanel(new GridLayout(0, 2)); JPanel rhsPanel = new JPanel(new GridLayout(0, 2)); lhsPanel.add(new JLabel("Max number of patients to generate")); SpinnerNumberModel model = new SpinnerNumberModel(initialPatientsNumber, 1, 1000000, 1); ptNumberSpinner = new JSpinner(model); ptNumberSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { // get value currently selected in spinner and set in engine dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // Object value = ptNumberSpinner.getValue(); // if(value instanceof Double) // { // Double d = (Double) ptNumberSpinner.getValue(); // dataGenerationEngine.setMaxPatientNumber(d.longValue()); // } // else // { // dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // } logger.debug("ptNumberSpinner.getValue().getClass() = " + ptNumberSpinner.getValue().getClass()); logger.debug("Max pt number in engine set to : " + dataGenerationEngine.getMaxPatientNumber()); } }); lhsPanel.add(ptNumberSpinner); lhsPanel.add(new JLabel("Min age of patients to generate")); SpinnerNumberModel ageModel = new SpinnerNumberModel(initialMinimumAge, 1, 120, 1); minAgeSpinner = new JSpinner(ageModel); minAgeSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // set min pt age to current value dataGenerationEngine.setMinPatientAgeInYears(Integer.parseInt(minAgeSpinner.getValue().toString())); logger.debug("Value of engine.getMinPatientAgeInYears() : " + dataGenerationEngine.getMinPatientAgeInYears()); } }); lhsPanel.add(minAgeSpinner); lhsPanel.add(new JLabel("Data generation strategy")); generationStrategyBox = new JComboBox(DataGenerationEngine.DataGenerationStrategy.values()); generationStrategyBox.setSelectedItem(DataGenerationEngine.DataGenerationStrategy.ADD_IF_NOT_EXISTS); generationStrategyBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setDataGenerationStrategy( (DataGenerationEngine.DataGenerationStrategy) generationStrategyBox.getSelectedItem()); } }); lhsPanel.add(generationStrategyBox); includeExcludedTermsBox = new JCheckBox(new AbstractAction("Include Excluded terms in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setIncludeExcludedTerms(includeExcludedTermsBox.isSelected()); logger.debug("dataGenerationEngine.isIncludeExcludedTerms() = " + dataGenerationEngine.isIncludeExcludedTerms()); } }); rhsPanel.add(includeExcludedTermsBox); randomiseNumericalValuesBox = new JCheckBox(new AbstractAction("Randomise Numerical values in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setRandomiseNumericalValues(randomiseNumericalValuesBox.isSelected()); logger.debug("dataGenerationEngine.isRandomiseNumericalValues() = " + dataGenerationEngine.isRandomiseNumericalValues()); } }); rhsPanel.add(randomiseNumericalValuesBox); refineQualifiersCheckBox = new JCheckBox(new AbstractAction("Refine Qualifiers in expression") { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setRefineQualifiers(refineQualifiersCheckBox.isSelected()); logger.debug( "dataGenerationEngine.isRefineQualifiers() = " + dataGenerationEngine.isRefineQualifiers()); } }); rhsPanel.add(refineQualifiersCheckBox); includePreCoordinatedDataCheckBox = new JCheckBox( new AbstractAction("Include pre-coordinated expressions") { public void actionPerformed(ActionEvent e) { dataGenerationEngine .setIncludePrecoordinatedData(includePreCoordinatedDataCheckBox.isSelected()); logger.debug("dataGenerationEngine.isIncludePrecoordinatedData() = " + dataGenerationEngine.isIncludePrecoordinatedData()); } }); rhsPanel.add(includePreCoordinatedDataCheckBox); rhsPanel.add(new JLabel(" ")); /* * create panel for parametrising engine */ JPanel parametrisationPanel = new JPanel(); parametrisationPanel.setLayout(new GridLayout(0, 2)); parametrisationPanel.setBorder(BorderFactory.createTitledBorder("Engine Parameters")); // add panels to parametrisation panel parametrisationPanel.add(lhsPanel); parametrisationPanel.add(rhsPanel); JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS)); topPanel.add(runPanel); topPanel.add(new JSeparator(SwingConstants.VERTICAL)); topPanel.add(buttonsPanel); // add all panels to this component setLayout(new BorderLayout()); add(topPanel, BorderLayout.NORTH); add(parametrisationPanel, BorderLayout.CENTER); // initialise values populateFields(dataGenerationEngine); }
From source file:view.WorkspacePanel.java
public void showPanelComponents() { jsPageNumber.setModel(new SpinnerNumberModel(1, 1, document.getNumberOfPages(), 1)); btnZoomIn.setEnabled(true);/*from www.ja va2s. c om*/ btnZoomOut.setEnabled(true); topToolbar.setVisible(true); lblTotalPageNumber.setText(" " + Bundle.getBundle().getString("of") + " " + document.getNumberOfPages() + " - Zoom: " + ((int) (imagePanel.getScale() * 100)) + "%"); bottomToolbar.setVisible(true); status = Status.READY; btnPageBackward.setEnabled(false); btnPageForward.setEnabled(document.getNumberOfPages() != 1); removeTempSignature(); hideRightPanel(); int numSigs = CCInstance.getInstance().getNumberOfSignatures(document.getDocumentLocation()); if (numSigs > 0) { startValidationThread(); } try { boolean permiteAlteracoes = CCInstance.getInstance().getCertificationLevel( document.getDocumentLocation()) != PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED; btnSign.setEnabled(permiteAlteracoes); btnSign.setToolTipText((permiteAlteracoes ? Bundle.getBundle().getString("sign") : Bundle.getBundle().getString("signedNoChangesAllowed"))); } catch (IOException ex) { controller.Logger.getLogger().addEntry(ex); } }