importjava.awt.*;
importjavax.swing.*;
importjava.awt.event.*;
classMyJDialogextendsJDialog{
publicMyJDialog(MyFrameframe){
super(frame,"第一个JDialog窗体",true);
Containercontainer=getContentPane();
JLabeljl=newJLabel("这是一个对话框");
container.add(jl);
setBounds(120,120,100,100);
}
}
publicclassMyFrameextendsJFrame{
publicstaticvoidmain(Stringargs[]){
newMyFrame();
}
publicMyFrame(){
Containercontainer=getContentPane();
container.setLayout(null);
JLabeljl=newJLabel("这是一个jlframe窗体");
jl.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jl);
JButtonbl=newJButton("弹出对话框");
bl.setBounds(10,10,100,21);
bl.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
newMyJDialog(MyFrame.this).setVisible(true);
}
}
);
container.add(bl);
}
}
分 -->
|