javax.swing.SpinnerListModel Java Examples

The following examples show how to use javax.swing.SpinnerListModel. 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 vote down vote up
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: JSpinnerOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a minimal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a minimal value.
 *
 * @return a minimal value.
 */
public Object getMinimum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMinimum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
 
Example #3
Source File: JSpinnerOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a maximal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a maximal value.
 *
 * @return a maximal value.
 */
public Object getMaximum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMaximum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
 
Example #4
Source File: IntegerListSpinner.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new IntegerListSpinner object.
 */
public IntegerListSpinner ()
{
    setModel(new SpinnerListModel());

    // Right alignment
    JSpinner.DefaultEditor editor;
    editor = (JSpinner.DefaultEditor) getEditor();
    editor.getTextField().setHorizontalAlignment(JTextField.RIGHT);
}
 
Example #5
Source File: SpinnerUtil.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Assign the List model (for a list-based spinner)
 *
 * @param spinner the spinner to update
 * @param values  the model list values
 */
public static void setList (JSpinner spinner,
                            List<?> values)
{
    SpinnerModel model = spinner.getModel();

    if (model instanceof SpinnerListModel) {
        ((SpinnerListModel) model).setList(values);
    } else {
        throw new IllegalArgumentException("Spinner model is not a SpinnerListModel");
    }
}
 
Example #6
Source File: TemplateBoard.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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 #7
Source File: IntegerListSpinner.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new IntegerListSpinner object.
 */
public IntegerListSpinner ()
{
    setModel(new SpinnerListModel());

    // Right alignment
    JSpinner.DefaultEditor editor;
    editor = (JSpinner.DefaultEditor) getEditor();
    editor.getTextField()
            .setHorizontalAlignment(JTextField.RIGHT);
}
 
Example #8
Source File: SpinnerUtil.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Assign the List model (for a list-based spinner)
 *
 * @param spinner the spinner to update
 * @param values  the model list values
 */
public static void setList (JSpinner spinner,
                            List<?> values)
{
    SpinnerModel model = spinner.getModel();

    if (model instanceof SpinnerListModel) {
        ((SpinnerListModel) model).setList(values);
    } else {
        throw new IllegalArgumentException(
                "Spinner model is not a SpinnerListModel");
    }
}
 
Example #9
Source File: JSpinnerOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private ListScrollAdjuster(JSpinnerOperator oper) {
    checkModel(oper, SpinnerListModel.class);
    model = (SpinnerListModel) oper.getModel();
    elements = model.getList();
}
 
Example #10
Source File: JSpinnerOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private ListSpinnerOperator(JSpinnerOperator spinner) {
    super((JSpinner) spinner.getSource());
    copyEnvironment(spinner);
    checkModel(this, SpinnerListModel.class);
}
 
Example #11
Source File: SymbolRipper.java    From libreveris with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new SymbolRipper object.
 */
public SymbolRipper ()
{
    // Related frame
    frame = new JFrame();
    frame.setTitle("Symbol Ripper");

    // Actors
    drawing = new Drawing();

    fontBase.setModel(
            new SpinnerListModel(new Integer[]{0, 0xf000, 0x1d100}));
    SpinnerUtil.setRightAlignment(fontBase);
    SpinnerUtil.fixIntegerList(fontBase);

    fontName.setModel(
            new SpinnerListModel(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()));

    // Initial values
    ///fontName.getSpinner().setValue("MusicalSymbols");
    fontName.getSpinner()
            .setValue("Symbola");
    fontBase.setValue(0); //0);
    fontSize.setValue(200);
    pointCode.setModel(new SpinnerNumberModel(0x1d100, 0, 0x1d1ff, 1));
    width.setValue(400);
    height.setValue(500);
    xOffset.setValue(200);
    yOffset.setValue(300);
    changeCode();
    defineFont();

    // Listeners
    fontName.addChangeListener(paramListener);
    fontBase.addChangeListener(paramListener);
    fontSize.addChangeListener(paramListener);
    pointCode.addChangeListener(paramListener);
    hexaCode.addChangeListener(paramListener);
    xOffset.addChangeListener(paramListener);
    yOffset.addChangeListener(paramListener);
    width.addChangeListener(paramListener);
    height.addChangeListener(paramListener);

    // Global layout
    defineLayout();

    // Frame behavior
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    MainGui.getInstance()
            .show(frame);

    // Actions
    image = buildImage();
    frame.repaint();
}
 
Example #12
Source File: JSpinnerOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Costs spinner's model to <code>SpinnerListModel<code>.
 *
 * @return a spinner model.
 */
public SpinnerListModel getListModel() {
    return (SpinnerListModel) getModel();
}