调试出错,这个例子该如何改?
//贴子太长了,前部分在回复里
public class DialogDemo implements ActionListener{
JFrame f=null;
public void actionPerformed(ActionEvent e){
String cmd=e.getActionCommand();
if (cmd.equals( "借用物品 ")){
new LendingSystem(f);
}else if (cmd.equals( "离开系统 ")){
System.exit(0);
}
}
public DialogDemo(){
f=new JFrame( "JDialog Example ");
Container contentPane=f.getContentPane();
JPanel buttonPanel=new JPanel();
JButton b=new JButton( "借用物品 ");
b.addActionListener(this);
buttonPanel.add(b);
b=new JButton( "离开系统 ");
b.addActionListener(this);
buttonPanel.add(b);
buttonPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue,2),
"借用物品系统 ",TitledBorder.CENTER,TitledBorder.TOP));
contentPane.add(buttonPanel,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main(String[] args){
SwingUtil.setLookAndFeel();
new DialogDemo();
}
}
class LendingSystem implements ActionListener{
JTextField staffField,objectField,borrowDateField,returnDateField,reasonField;
JDialog dialog;
public void actionPerformed(ActionEvent e){
String cmd=e.getActionCommand();
if (cmd.equals( "确定 ")){
}else if (cmd.equals( "取消 ")){
dialog.dispose();
}
}
LendingSystem(JFrame f){
dialog = new JDialog(f, "借用物品 ",true);