首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

JDialog解决思路

2012-02-17 
JDialogimportjavax.swing.*importjava.awt.*importjava.awt.event.*classMyDialogextendsJDialog{JLab

JDialog
import   javax.swing.*;
import   java.awt.*;
import   java.awt.event.*;

class   MyDialog   extends   JDialog{
JLabel   label;
MyDialog(JFrame   f,String   s){
super(f,s);
label=new   JLabel( "哈哈!! ");
setSize(90,90);
setModal(true);
getContentPane().setLayout(new   FlowLayout());
getContentPane().add(label);
addWindowListener(new   WindowAdapter(){
public   void   windowClosing(WindowEvent   e){
System.exit(0);
}
});
}
}

class   MyFrame   extends   JFrame   implements   ActionListener{
JButton   button;
MyDialog   dialog;
MyFrame(){
setSize(400,300);
getContentPane().setLayout(new   FlowLayout());
button=new   JButton( "确定 ");
dialog=new   MyDialog(此处, "对话框 ");
getContentPane().add(button);
button.addActionListener(this);
setVisible(true);
}
public   void   actionPerformed(ActionEvent   e){
if(e.getSource()==button){
dialog.setVisible(true);
}
}
}

public   class   Dd{
public   static   void   main(String   args[]){
new   MyFrame();
}
}


//文中 "此处 "应该如何填写?望达人指教!

[解决办法]
this

热点排行