e786. 创建JSpinner组件
This example demonstrates how to build three kinds of spinners. A number spinner:
// Create a number spinner
JSpinner spinner = new JSpinner();
// Set its value
spinner.setValue(new Integer(100));
A list spinner:
// Create a list spinner SpinnerListModel listModel = new SpinnerListModel( new String[]{"red", "green", "blue"}); spinner = new JSpinner(listModel); // Set its value spinner.setValue("blue");
A date spinner:
// Create a date spinner SpinnerDateModel dateModel = new SpinnerDateModel(); spinner = new JSpinner(dateModel); // Set its value to jan 1 2000 Calendar calendar = new GregorianCalendar(2000, Calendar.JANUARY, 1); spinner.setValue(calendar.getTime());
Related Examples |