javax.swing.JSpinner#setName ( )源码实例Demo

下面列出了javax.swing.JSpinner#setName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: marathonv5   文件: JSpinnerJavaElementTest.java
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;
}
 
源代码2 项目: marathonv5   文件: JSpinnerJavaElementTest.java
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;
}
 
源代码3 项目: marathonv5   文件: JSpinnerJavaElementTest.java
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;
}
 
源代码4 项目: audiveris   文件: TemplateBoard.java
/**
 * 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();
}
 
源代码5 项目: megamek   文件: BayMunitionsChoicePanel.java
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();
}