本文整理匯總了Java中javax.swing.SpinnerDateModel.setCalendarField方法的典型用法代碼示例。如果您正苦於以下問題:Java SpinnerDateModel.setCalendarField方法的具體用法?Java SpinnerDateModel.setCalendarField怎麽用?Java SpinnerDateModel.setCalendarField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.SpinnerDateModel
的用法示例。
在下文中一共展示了SpinnerDateModel.setCalendarField方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: MissingTimePanel
import javax.swing.SpinnerDateModel; //導入方法依賴的package包/類
public MissingTimePanel(DateAndTime dateAndTime) {
super(dateAndTime);
timeModel = new SpinnerDateModel();
GregorianCalendar gc = new GregorianCalendar(0, 0, 0, 0, 0, 0);
timeModel.setValue(gc.getTime());
timeModel.setCalendarField(Calendar.HOUR_OF_DAY);
timeSpinner = new JSpinner(timeModel);
timeSpinner.setEditor(new JSpinner.DateEditor(timeSpinner, "HH:mm:ss"));
this.setLayout(new FlowLayout(FlowLayout.LEFT));
this.timeLabel = new JLabel(Lang.l().time() + ": ");
this.add(timeLabel);
this.add(timeSpinner);
}
示例2: createView
import javax.swing.SpinnerDateModel; //導入方法依賴的package包/類
private void createView() {
frame = new JFrame(title);
dateLabel = new JLabel("Data :");
entryLabel = new JLabel("Entrada :");
exitLabel = new JLabel("Saída :");
dateField = new JTextField();
// entryField = new JTextField();
// exitField = new JTextField();
okButton = new JButton("OK");
cancelButton = new JButton("Cancelar");
SpinnerDateModel modelEntry = new SpinnerDateModel();
modelEntry.setCalendarField(Calendar.MINUTE);
SpinnerDateModel modelExit = new SpinnerDateModel();
modelExit.setCalendarField(Calendar.MINUTE);
entryField = new JSpinner();
entryField.setModel(modelEntry);
entryField.setEditor(new JSpinner.DateEditor(entryField, "HH:mm:ss"));
exitField = new JSpinner();
exitField.setModel(modelExit);
exitField.setEditor(new JSpinner.DateEditor(exitField, "HH:mm:ss"));
DocumentFilter dateDocumentFilter = new DateDocumentFilter();
((AbstractDocument) dateField.getDocument()).setDocumentFilter(dateDocumentFilter);
frame.setLayout(null);
takeScreenSize();
frame.setBounds((x - 500) / 2, (y - 350) / 2, 500, 350);
dateLabel.setBounds(50, 50, 100, 30);
entryLabel.setBounds(50, 100, 100, 30);
exitLabel.setBounds(50, 150, 100, 30);
dateField.setBounds(150, 50, 150, 30);
entryField.setBounds(150, 100, 150, 30);
exitField.setBounds(150, 150, 150, 30);
okButton.setBounds(100, 250, 125, 30);
cancelButton.setBounds(250, 250, 125, 30);
dateLabel.setFont(FontFactory.getFontDefault());
entryLabel.setFont(FontFactory.getFontDefault());
exitLabel.setFont(FontFactory.getFontDefault());
dateField.setFont(FontFactory.getFontDefault());
entryField.setFont(FontFactory.getFontDefault());
exitField.setFont(FontFactory.getFontDefault());
okButton.setFont(FontFactory.getFontLarge());
cancelButton.setFont(FontFactory.getFontLarge());
dateLabel.setBackground(Color.BLACK);
entryLabel.setBackground(Color.BLACK);
exitLabel.setBackground(Color.BLACK);
dateField.setForeground(Color.BLACK);
entryField.setForeground(Color.BLACK);
exitField.setForeground(Color.BLACK);
okButton.setForeground(Color.BLACK);
cancelButton.setForeground(Color.BLACK);
frame.getContentPane().setBackground(Color.WHITE);
frame.add(dateLabel);
frame.add(entryLabel);
frame.add(exitLabel);
frame.add(dateField);
frame.add(entryField);
frame.add(exitField);
frame.add(okButton);
frame.add(cancelButton);
JContextPopupMenu contextPopupMenu = new JContextPopupMenu();
//adiciona evento aos itens do popupmenu
contextPopupMenu.addInComponet(dateField);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}