我创建了一个java框架,它从用户那里获取信息....它是一种预约书,我想添加一个接受用户日期和时间的文本字段......
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));
}
}
}
}
我创建了一个java框架,它从用户那里获取信息....它是一种预约书,我想添加一个接受用户日期和时间的文本字段......