List of usage examples for javax.swing JSpinner JSpinner
public JSpinner(SpinnerModel model)
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
private JSpinner getTypeB_deltaRawMinimumSpinner() { if (typeB_deltaRawMinimumSpinner == null) { typeB_deltaRawMinimumSpinner = new JSpinner(new SpinnerNumberModel( TypeBEvaluationOptions.getDeltaRawDatasetMinimum(), Integer.MIN_VALUE, Integer.MAX_VALUE, 10)); typeB_deltaRawMinimumSpinner.setEnabled(!TypeBEvaluationOptions.isDeltaRawAutoscale()); }// w w w. j a v a2 s. c om return typeB_deltaRawMinimumSpinner; }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java
@Override public void createUI() { super.createUI(); CellConstraints cc = new CellConstraints(); orderUpBtn = createIconBtn("ReorderUp", "TCGD_MOVE_UP", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = fieldsTbl.getSelectedRow(); UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx); fields.remove(inx);// w w w .ja v a 2 s . c om fields.insertElementAt(item, inx - 1); fieldsTbl.getSelectionModel().setSelectionInterval(inx - 1, inx - 1); selectedFormat.resetLength(); updateEnabledState(); updateUIEnabled(); } }); orderDwnBtn = createIconBtn("ReorderDown", "TCGD_MOVE_DOWN", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = fieldsTbl.getSelectedRow(); UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx); fields.remove(inx); fields.insertElementAt(item, inx + 1); fieldsTbl.getSelectionModel().setSelectionInterval(inx + 1, inx + 1); selectedFormat.resetLength(); updateEnabledState(); updateUIEnabled(); } }); // get formatters for field List<UIFieldFormatterIFace> fmtrs = new Vector<UIFieldFormatterIFace>(uiFieldFormatterMgrCache .getFormatterList(fieldInfo.getTableInfo().getClassObj(), fieldInfo.getName())); Collections.sort(fmtrs, new Comparator<UIFieldFormatterIFace>() { public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) { return o1.toPattern().compareTo(o2.toPattern()); } }); // table and field titles PanelBuilder tblInfoPB = new PanelBuilder( new FormLayout("r:p,2px,f:p:g", "p,2px,p,2px,p,10px")/*, new FormDebugPanel()*/); String typeStr = fieldInfo.getType(); typeStr = typeStr.indexOf('.') > -1 ? StringUtils.substringAfterLast(fieldInfo.getType(), ".") : typeStr; JLabel tableTitleLbl = createI18NFormLabel("FFE_TABLE"); JLabel tableTitleValueLbl = createLabel(fieldInfo.getTableInfo().getTitle()); tableTitleValueLbl.setBackground(Color.WHITE); tableTitleValueLbl.setOpaque(true); JLabel fieldTitleLbl = createI18NFormLabel("FFE_FIELD"); JLabel fieldTitleValueLbl = createLabel(fieldInfo.getTitle()); fieldTitleValueLbl.setBackground(Color.WHITE); fieldTitleValueLbl.setOpaque(true); JLabel fieldLengthLbl = createI18NFormLabel("FFE_LENGTH"); JLabel fieldLengthValueLbl = createLabel(Integer.toString(fieldInfo.getLength())); fieldLengthValueLbl.setBackground(Color.WHITE); fieldLengthValueLbl.setOpaque(true); int y = 1; tblInfoPB.add(tableTitleLbl, cc.xy(1, y)); tblInfoPB.add(tableTitleValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldTitleLbl, cc.xy(1, y)); tblInfoPB.add(fieldTitleValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldLengthLbl, cc.xy(1, y)); tblInfoPB.add(fieldLengthValueLbl, cc.xy(3, y)); y += 2; // sample panel sampleLabel = createLabel("", SwingConstants.LEFT); JPanel samplePanel = new JPanel(); samplePanel.setBorder(BorderFactory.createTitledBorder(getResourceString("FFE_SAMPLE"))); //$NON-NLS-1$ samplePanel.add(sampleLabel); // name text field nameTF = createTextField(20); // title text field titleTF = createTextField(20); byYearCB = createCheckBox(getResourceString("FFE_BY_YEAR_CHECKBOX")); //$NON-NLS-1$ hookByYearCheckBoxListener(); fieldsPanel = new EditDeleteAddPanel(getSaveAL(), getDelAL(), getAddAL()); fieldsTbl = new JTable(fieldsModel = new FieldsTableModel()); fieldTypeCbx = new JComboBox(FieldType.values()); // I18N fieldTxt = createTextField(20); fieldsPanel.getAddBtn().setEnabled(true); fieldsPanel.getEditBtn().setIcon(IconManager.getIcon("Green Arrow Up", IconManager.IconSize.Std16)); UIHelper.makeTableHeadersCentered(fieldsTbl, true); fieldTxt.setDocument(new FieldDocument()); fieldsTbl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); int width = fieldTypeCbx.getPreferredSize().width; y = 1; PanelBuilder subPB = new PanelBuilder(new FormLayout("r:p,2px,p", "p,4px, p,4px, p,4px, p,4px")); subPB.add(createI18NFormLabel("FFE_NAME"), cc.xy(1, y)); subPB.add(nameTF, cc.xy(3, y)); y += 2; subPB.add(createI18NFormLabel("FFE_TITLE"), cc.xy(1, y)); subPB.add(titleTF, cc.xy(3, y)); y += 2; subPB.add(byYearCB, cc.xy(3, y)); y += 2; // CardLayout for Editor Panels SpinnerModel retModel = new SpinnerNumberModel(1, //initial value 1, //min fieldInfo.getLength(), //max 1); //step sizeSpinner = new JSpinner(retModel); isIncChk = new JCheckBox("Is Incrementer"); // I18N String colDefs = "f:p:g,p,2px," + width + "px,2px,p"; closeBtn = createClose(0); PanelBuilder numPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p,2px,p")); numPB.add(createI18NFormLabel("FFE_LENGTH"), cc.xy(2, 1)); numPB.add(sizeSpinner, cc.xy(4, 1)); //numPB.add(closeBtn, cc.xy(6, 1)); numPB.add(isIncChk, cc.xy(4, 3)); sepCbx = new JComboBox(new String[] { "-", ".", "/", "(space)", "_" }); closeBtn = createClose(1); PanelBuilder sepPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p")); sepPB.add(createI18NFormLabel("FFE_SEP"), cc.xy(2, 1)); sepPB.add(sepCbx, cc.xy(4, 1)); //sepPB.add(closeBtn, cc.xy(6, 1)); closeBtn = createClose(2); PanelBuilder txtPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p")); txtPB.add(createI18NFormLabel("FFE_TEXT"), cc.xy(2, 1)); txtPB.add(fieldTxt, cc.xy(4, 1)); cardPanel = new JPanel(cardLayout); cardPanel.add("size", numPB.getPanel()); cardPanel.add("text", txtPB.getPanel()); cardPanel.add("sep", sepPB.getPanel()); cardPanel.add("none", new JLabel(" ")); y = 1; PanelBuilder leftPB = new PanelBuilder(new FormLayout("f:p:g", "t:p,10px,p,f:p:g")); leftPB.add(tblInfoPB.getPanel(), cc.xy(1, y)); y += 2; leftPB.add(subPB.getPanel(), cc.xy(1, y)); y += 2; PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "f:p:g, p, 2px, p, f:p:g")); upDownPanel.add(orderUpBtn, cc.xy(1, 2)); upDownPanel.add(orderDwnBtn, cc.xy(1, 4)); totLenLbl = createLabel("XXXXX"); y = 1; PanelBuilder rightPB = new PanelBuilder(new FormLayout("p:g,2px,p,2px,p", "200px,2px,p,2px,p,2px,p")); rightPB.add(createScrollPane(fieldsTbl), cc.xywh(1, y, 3, 1)); rightPB.add(upDownPanel.getPanel(), cc.xywh(5, y, 1, 1)); y += 2; rightPB.add(totLenLbl, cc.xy(1, y)); rightPB.add(fieldsPanel, cc.xywh(3, y, 1, 1)); y += 2; rightPB.add(fieldTypeLbl = createI18NFormLabel("FFE_TYPE"), cc.xy(1, y)); rightPB.add(fieldTypeCbx, cc.xy(3, y)); rightPB.add(closeBtn, cc.xy(5, y)); y += 2; rightPB.add(cardPanel, cc.xyw(1, y, 3)); y += 2; y = 1; PanelBuilder pb = new PanelBuilder(new FormLayout("p:g,10px,p,10px,p:g,10px,p", "f:p:g,10px,p")); Color bg = getBackground(); pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xywh(3, 1, 1, 1)); pb.add(leftPB.getPanel(), cc.xy(1, y)); pb.add(rightPB.getPanel(), cc.xy(5, y)); //pb.add(keyPanel, cc.xy(7, y)); y += 2; pb.add(samplePanel, cc.xyw(1, y, 7)); y += 2; setByYearSelected(selectedFormat); nameTF.setEditable(isNew); nameTF.setText(selectedFormat.getName()); titleTF.setText(selectedFormat.getTitle()); updateSample(); hookTextChangeListener(nameTF, "FFE_NO_NAME", 32); hookTextChangeListener(titleTF, "FFE_NO_TITLE", 32); pb.setDefaultDialogBorder(); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); updateUIEnabled(); pack(); enabledEditorUI(false); hookFieldsTblSelectionListener(); fieldTypeCbx.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { typeChanged(); } }); sepCbx.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { fieldHasChanged = true; updateEnabledState(); hasChanged = true; updateUIEnabled(); } }); fieldTxt.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { fieldHasChanged = true; updateEnabledState(); hasChanged = true; updateUIEnabled(); } }); sizeSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { fieldHasChanged = true; updateEnabledState(); hasChanged = true; updateUIEnabled(); } }); isIncChk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fieldHasChanged = true; if (!isIncChk.isSelected()) { byYearCB.setSelected(false); } updateEntry(); updateUIEnabled(); updateEnabledState(); fieldsTbl.repaint(); } }); fieldTypeCbx.setSelectedIndex(-1); fieldHasChanged = false; updateEnabledState(); }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
private JSpinner getCo2Absolute_Co2AbsoluteMinimumSpinner() { if (co2Absolute_co2AbsoluteMinimumSpinner == null) { co2Absolute_co2AbsoluteMinimumSpinner = new JSpinner( new SpinnerNumberModel(CO2AbsoluteOnlyEvaluationOptions.getCo2AbsoluteDatasetMinimum(), Integer.MIN_VALUE, Integer.MAX_VALUE, 10)); co2Absolute_co2AbsoluteMinimumSpinner .setEnabled(!CO2AbsoluteOnlyEvaluationOptions.isAutoScaleCO2Absolute()); }// w w w .j av a 2 s .co m return co2Absolute_co2AbsoluteMinimumSpinner; }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
private JSpinner getCo2Absolute_Co2AbsoluteMaximumSpinner() { if (co2Absolute_co2AbsoluteMaximumSpinner == null) { co2Absolute_co2AbsoluteMaximumSpinner = new JSpinner(new SpinnerNumberModel( CO2AbsoluteOnlyEvaluationOptions.co2AbsoluteOnly_getCo2AbsoluteDatasetMaximum(), Integer.MIN_VALUE, Integer.MAX_VALUE, 10)); co2Absolute_co2AbsoluteMaximumSpinner .setEnabled(!CO2AbsoluteOnlyEvaluationOptions.isAutoScaleCO2Absolute()); }/*from w w w . j av a2 s .c o m*/ return co2Absolute_co2AbsoluteMaximumSpinner; }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
private JSpinner getCo2Absolute_deltaFiveMinutesMinimumSpinner() { if (co2Absolute_deltaFiveMinutesMinimumSpinner == null) { co2Absolute_deltaFiveMinutesMinimumSpinner = new JSpinner(new SpinnerNumberModel( CO2AbsoluteOnlyEvaluationOptions.co2AbsoluteOnly_getDeltaFiveMinutesMinimum(), Integer.MIN_VALUE, Integer.MAX_VALUE, 10)); co2Absolute_deltaFiveMinutesMinimumSpinner .setEnabled(!CO2AbsoluteOnlyEvaluationOptions.isAutoScaleDeltaFiveMinutes()); }/*from ww w . j av a 2 s . c o m*/ return co2Absolute_deltaFiveMinutesMinimumSpinner; }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendGenerationsSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//ww w.j a va 2 s .c om SpinnerModel generationsModel = new SpinnerNumberModel(generationsInitial, GENERATIONS_MIN, GENERATIONS_MAX, GENERATIONS_STEP); generationsSpinner = new JSpinner(generationsModel); generationsSpinner.setEnabled(false); JLabel generationsLabel = new JLabel(generationsText); generationsLabel.setLabelFor(generationsSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(generationsLabel, constraints); mainPanel.add(generationsLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(generationsSpinner, constraints); mainPanel.add(generationsSpinner); }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
private JSpinner getCo2Absolute_deltaFiveMinutesMaximumSpinner() { if (co2Absolute_deltaFiveMinutesMaximumSpinner == null) { co2Absolute_deltaFiveMinutesMaximumSpinner = new JSpinner(new SpinnerNumberModel( CO2AbsoluteOnlyEvaluationOptions.co2AbsoluteOnly_getDeltaFiveMinutesMaximum(), Integer.MIN_VALUE, Integer.MAX_VALUE, 10)); co2Absolute_deltaFiveMinutesMaximumSpinner .setEnabled(!CO2AbsoluteOnlyEvaluationOptions.isAutoScaleDeltaFiveMinutes()); }/* w w w. java 2 s . c om*/ return co2Absolute_deltaFiveMinutesMaximumSpinner; }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendPopulationSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from w w w .ja v a 2s . c o m SpinnerModel populationModel = new SpinnerNumberModel(populationInitial, POPULATION_MIN, POPULATION_MAX, POPULATION_STEP); populationSpinner = new JSpinner(populationModel); JLabel populationLabel = new JLabel(populationText); populationLabel.setLabelFor(populationSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(populationLabel, constraints); mainPanel.add(populationLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(populationSpinner, constraints); mainPanel.add(populationSpinner); }
From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newMarkupPanel(NounPhrase np, ReviewElement reviewElement) { //MODEL/*from w ww. j a va2 s. com*/ Element element = new Element(); //Newly added ScrollablePanel markupPanel = new ScrollablePanel(); markupPanel.setLayout(new BoxLayout(markupPanel, BoxLayout.X_AXIS)); markupPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); JTextArea npContentTxtArea = new JTextArea(); npContentTxtArea.setEditable(false); npContentTxtArea.setText(((MarkupNounPhrase) np).content); markupPanel.add(npContentTxtArea); //REF SpinnerModel refSpinnerModel = new SpinnerNumberModel(np.getChainId(), -1, COLORS.length - 1, 1); JSpinner refSpinner = new JSpinner(refSpinnerModel); refSpinner.setValue(np.getChainId()); refSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { np.setChainId((int) refSpinner.getValue()); try { rePaint(reviewElements.get(np.getReviewId()), np); } catch (BadLocationException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }); element.refSpinner = refSpinner; //TYPE String[] typeValues = { "Object", "Other", "Candidate", "Attribute" }; SpinnerModel typeSpinnerModel = new SpinnerListModel(typeValues); JSpinner typeSpinner = new JSpinner(typeSpinnerModel); typeSpinner.setValue(typeValues[np.getType()]); element.typeSpinner = typeSpinner; //REF + TYPE ScrollablePanel spinners = new ScrollablePanel(); spinners.setLayout(new BoxLayout(spinners, BoxLayout.X_AXIS)); spinners.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); spinners.add(refSpinner); spinners.add(typeSpinner); markupPanel.add(spinners); reviewElement.addElement(element); JScrollPane scrollMarkupPanel = new JScrollPane(markupPanel); return scrollMarkupPanel; }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendLifespanSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from w w w. ja v a 2 s .c o m SpinnerModel lifespanModel = new SpinnerNumberModel(lifespanInitial, LIFESPAN_MIN, LIFESPAN_MAX, LIFESPAN_STEP); lifespanSpinner = new JSpinner(lifespanModel); JLabel lifespanLabel = new JLabel(lifespanText); lifespanLabel.setLabelFor(lifespanSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(lifespanLabel, constraints); mainPanel.add(lifespanLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(lifespanSpinner, constraints); mainPanel.add(lifespanSpinner); }