我正在使用 lwuit 创建一个应用程序。我想在组合框中添加日历。请尽快给我一个想法..
您的意思是要在组合框值的末尾添加日历组件的选定日期还是在文本框中显示选定的日期?
如果是这样,那么下面的代码将在文本框中显示日历组件的选定日期:
Button cal = new Button("Calendar"); // button for calendar
cal.addActionListener(new ActionListener() { // define action for button
// action listener to show the calendar container
public void actionPerformed(ActionEvent ae) {
final Form calFrame = new Form();
final Calendar cal = new Calendar();
calFrame.setScrollable(true);
calFrame.setSmoothScrolling(true);
calFrame.setIsScrollVisible(true);
cal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
txtDate.setText(cal.getDate()); // textfield in which date should be set
mainForm.showBack(); // main form to show back after calender disappears
}
});
calFrame.addComponent(cal);
calFrame.show();
}
});
mainForm.addComponent(calButton); // add calendar button to main form
此代码将向您的主窗体添加一个日历按钮,并将在文本字段(此处名为 txtDate)中显示所选日期。
如果要在组合值中添加日期,可以在向量或组合组件向量列表中添加选定的日期。
如果这不是您想要的,请简要解释您实际想要做什么。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)