2
我正在使用lwuit创建应用程序。我想在组合框中添加日历。请尽快给我一个想法..如何在lwuit TextField或组合框中添加日历
我正在使用lwuit创建应用程序。我想在组合框中添加日历。请尽快给我一个想法..如何在lwuit TextField或组合框中添加日历
您是否意味着您要在组合框的值末尾添加日历组件的选定日期或在文本框中显示所选日期? 如果是的话,那么下面的代码显示日历组件的文本框中选定的日期:
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)。 如果要在组合值中添加日期,可以将选定日期添加到向量或组合组件向量的列表中。 如果这不是你想要的,请简要说明你想要做什么。