java - how to accept date and time from a user in a JTextField -
i have created java frame takes in info user....its kind of appointment book , want add text field accepts date , time user...
package notifyme; import java.awt.container; import java.awt.flowlayout; import java.awt.gridlayout; import java.awt.event.*; import java.util.hashtable; import java.util.vector; import javax.swing.defaultcomboboxmodel; import javax.swing.jframe; import javax.swing.jbutton; import javax.swing.jcombobox; import javax.swing.jlabel; import javax.swing.jscrollpane; import javax.swing.jtextfield; public class inputwindow extends jframe { private jlabel equipment; private jlabel location; private jlabel date; private jlabel time,type,space,space1; private jbutton enter; private jcombobox location1, equipment1,type1; private hashtable<object, object> subitems = new hashtable<object, object>(); private jtextfield time; datecombobox dcb = new datecombobox(); private static string[] lnames = {"selectone","addis ababa", "dire dawa", "mekelle", "arbaminch", "gode", "gore", "gawassa"}; private static string[] elist = { "selectone","communication","navigation","surveillance"}; private static string[] clist = { "selectcommequi","vhf121.9","vhf118.1","125.1","125.2","vsat"}; private static string[] nlist = { "selectnavequi","vor","dme","ils","dvor","gp","ab beacon","bl beacon"}; private static string[] slist = { "selectsurveillanceequi","psr","ssr","ads-b",}; public inputwindow(){ super("notification input window"); setlayout(new flowlayout()); final container pane = getcontentpane(); pane.setlayout(new gridlayout(8,8)); equipment = new jlabel("equipment"); type =new jlabel("type"); equipment1= new jcombobox(elist); selecttype st = new selecttype(); equipment1.addactionlistener(st); //equipment1.additemlistener(this); type1 = new jcombobox(); //type.additemlistener(this); string[] subitems1 = { "selectcommequi","vhf121.9","vhf118.1","125.1","125.2","vsat"}; subitems.put(elist[1], subitems1); string[] subitems2 = { "selectnavequi","vor","dme","ils","dvor","gp","ab beacon","bl beacon"}; subitems.put(elist[2], subitems2); string[] subitems3 = { "selectsurveillanceequi","psr","ssr","ads-b",}; subitems.put(elist[3], subitems3); // maincombobox.setselectedindex(1); location = new jlabel("location"); location1 = new jcombobox(lnames); date = new jlabel("date"); time = new jlabel("time"); time = new jtextfield(); space = new jlabel(); space1 = new jlabel(); enter = new jbutton("enter"); pane.add(equipment); pane.add(equipment1); pane.add(type); pane.add(type1); pane.add(location); pane.add(location1); pane.add(date); pane.add(dcb); pane.add(time); pane.add(time); pane.add(space); pane.add(space1); pane.add(enter); setdefaultcloseoperation(exit_on_close); setsize(1300,1200); setvisible(true); } class selecttype implements actionlistener { @override public void actionperformed(actionevent e) { string item = (string) equipment1.getselecteditem(); object o = subitems.get(item); if (o == null) { type1.setmodel(new defaultcomboboxmodel()); } else { type1.setmodel(new defaultcomboboxmodel((string[]) o)); } } } } i have created java frame takes in info user....its kind of appointment book , want add text field accepts date , time user...
Comments
Post a Comment