Java Code Examples for javax.swing.JSpinner#setName()
The following examples show how to use
javax.swing.JSpinner#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSpinnerJavaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
private JSpinner createListSpinner() { String[] monthStrings = { "January", "February", "March", "April" }; SpinnerListModel spinnerListModel = new SpinnerListModel(monthStrings); JSpinner listSpinner = new JSpinner(spinnerListModel); listSpinner.setName("list-spinner"); return listSpinner; }
Example 2
Source File: JSpinnerJavaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
private JSpinner createNumberSpinner(Calendar calendar) { int currentYear = calendar.get(Calendar.YEAR); SpinnerModel yearModel = new SpinnerNumberModel(currentYear, currentYear - 100, currentYear + 100, 1); JSpinner numberSpinner = new JSpinner(yearModel); numberSpinner.setEditor(new JSpinner.NumberEditor(numberSpinner, "#")); numberSpinner.setName("number-spinner"); return numberSpinner; }
Example 3
Source File: JSpinnerJavaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
private JSpinner createDateSpinner(Calendar calendar) { Date initDate = calendar.getTime(); calendar.add(Calendar.YEAR, -100); Date earliestDate = calendar.getTime(); calendar.add(Calendar.YEAR, 200); Date latestDate = calendar.getTime(); SpinnerDateModel spinnerDateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR); JSpinner dateSpinner = new JSpinner(spinnerDateModel); dateSpinner.setEditor(new JSpinner.DateEditor(dateSpinner, "MM/yyyy")); dateSpinner.setName("date-spinner"); return dateSpinner; }
Example 4
Source File: TemplateBoard.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a new {@code TemplateBoard} object. * * @param sheet related sheet * @param table the table of distances * @param templateService template bus */ public TemplateBoard (Sheet sheet, DistanceTable table, SelectionService templateService) { super(Board.TEMPLATE, sheet.getLocationService(), eventsRead, true, false, false, false); this.sheet = sheet; this.table = table; this.templateService = templateService; // Shape spinner shapeSpinner = new JSpinner( new SpinnerListModel(new ArrayList<>(ShapeSet.getTemplateNotes(sheet)))); shapeSpinner.addChangeListener(this); shapeSpinner.setName("shapeSpinner"); shapeSpinner.setToolTipText("Selection of template shape"); // Anchor spinner (with only relevant anchor values for templates) anchorSpinner = new JSpinner( new SpinnerListModel( Arrays.asList(Anchor.LEFT_STEM, Anchor.RIGHT_STEM, Anchor.MIDDLE_LEFT))); anchorSpinner.addChangeListener(this); anchorSpinner.setName("anchorSpinner"); anchorSpinner.setToolTipText("Selection of template anchor"); // Eval field evalField.setEditable(false); evalField.setHorizontalAlignment(JTextField.CENTER); evalField.setToolTipText("Matching grade"); defineLayout(); }
Example 5
Source File: BayMunitionsChoicePanel.java From megamek with GNU General Public License v2.0 | 4 votes |
AmmoRowPanel(Mounted bay, int at, int rackSize, List<Mounted> ammoMounts) { this.bay = bay; this.at = at; this.rackSize = rackSize; this.ammoMounts = new ArrayList<>(ammoMounts); this.spinners = new ArrayList<>(); Dimension spinnerSize =new Dimension(55, 25); final Optional<WeaponType> wtype = bay.getBayWeapons().stream() .map(wNum -> entity.getEquipment(wNum)) .map(m -> (WeaponType) m.getType()).findAny(); // set the bay's tech base to that of any weapon in the bay // an assumption is made here that bays don't mix clan-only and IS-only tech base this.techBase = wtype.isPresent() ? wtype.get().getTechBase() : WeaponType.TECH_BASE_ALL; munitions = AmmoType.getMunitionsFor(at).stream() .filter(this::includeMunition).collect(Collectors.toList()); tonnage = ammoMounts.stream().mapToDouble(m -> m.getAmmoCapacity()).sum(); Map<String,Integer> starting = new HashMap<>(); ammoMounts.forEach(m -> starting.merge(m.getType().getInternalName(), m.getBaseShotsLeft(), Integer::sum)); for (AmmoType atype : munitions) { JSpinner spn = new JSpinner(new SpinnerNumberModel(starting.getOrDefault(atype.getInternalName(), 0), 0, null, 1)); spn.setPreferredSize(spinnerSize); spn.setName(atype.getInternalName()); spn.addChangeListener(this); if (atype.getTonnage(entity) > 1) { spn.setToolTipText(String.format(Messages.getString("CustomMechDialog.formatMissileTonnage"), atype.getName(), atype.getTonnage(entity))); } else { spn.setToolTipText(String.format(Messages.getString("CustomMechDialog.formatShotsPerTon"), atype.getName(), atype.getShots())); } spinners.add(spn); } setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 5); gbc.gridwidth = 5; add(new JLabel("(" + entity.getLocationAbbr(bay.getLocation()) + ") " + (wtype.isPresent()? wtype.get().getName() : "?")), gbc); gbc.gridx = 5; gbc.gridwidth = 1; gbc.weightx = 1.0; add(lblTonnage, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 1; gbc.weightx = 0.0; for (int i = 0; i < munitions.size(); i++) { add(new JLabel(createMunitionLabel(munitions.get(i))), gbc); gbc.gridx++; add(spinners.get(i), gbc); gbc.gridx++; if (gbc.gridx > 5) { gbc.gridx = 0; gbc.gridy++; } } recalcMaxValues(); }