Frame和JFrame代碼比較:
**包
Frame----import java.awt.*;
JFrame----import javax.swing.*;
**JFrame多了一個對于窗體字段的定義但是沒有TextArea
**JFrame要先對窗體字段進行賦值
設置右上旋鈕的作用
**初始化方法的時候:
按鈕動作事件的處理:
/*but.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
JDialogdialog =new JDialog(thisFrame,"JDialog的對話框:");
dialog.setModalityType(JDialog.ModalityType.application_MODAL);
dialog.setLocation(thisFrame.getX() +50,thisFrame.getY()+90);
dialog.setSize(200,150);
dialog.add(new JLabel(tex.getText()+",zoa"));
dialog.setVisible(true);
}
});
*/
/*
but.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
ta.setText(tf.getText() +"愛你!");
}
});
this.addWindowListener(new WindowAdapter(){
publicvoid windowClosing(WindowEvent e){
System.exit(0);
}
});
*/
新聞熱點
疑難解答