如何在lwuit TextField或comboBox中添加日历 [英] How to add calendar in lwuit TextField or comboBox

查看:162
本文介绍了如何在lwuit TextField或comboBox中添加日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用lwuit创建一个应用程序.而且我想在comboBox中添加日历.请尽快给我一个主意.

I am creating an application using lwuit. And i want to add calendar in comboBox. please give me an idea as soon as possible..

推荐答案

您是说要在组合框值的末尾添加日历组件的选定日期还是在文本框中显示选定日期? 如果是这样,则下面的代码在文本框中显示日历组件的选定日期:

Do u mean that you want to add the selected date of calendar component at the end of combobox values or to show the selected date in textbox? If so, then below code shows the selected date of calendar component in textbox:

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)中显示所选日期. 如果要在组合值中添加日期,则可以在向量或组合组件向量的列表中添加选定的日期. 如果这不是您想要的,请简要说明您实际想要做的事情.

this code will add one calendar button to your main form and will display the selected date in textfield (here named txtDate). If you want to add date in combo values, you can add the selected date in the vector or list of the combo component's vector. If this is not what you want, kindly briefly explain what you want actually to do.

这篇关于如何在lwuit TextField或comboBox中添加日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆