本文整理汇总了Java中javax.swing.JSpinner.setName方法的典型用法代码示例。如果您正苦于以下问题:Java JSpinner.setName方法的具体用法?Java JSpinner.setName怎么用?Java JSpinner.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSpinner
的用法示例。
在下文中一共展示了JSpinner.setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDateSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
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;
}
示例2: createListSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
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;
}
示例3: createNumberSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
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;
}