import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyJDialog extends JDialog{
public MyJDialog(MyFrame frame){
super(frame,"第二个窗体",true);
Container c=getContentPane();
c.add(new JLabel("第二个窗体写的内容"));
setBounds(100,100,200,140);
}
}
public class MyFrame extends JFrame{
public static void main(String[] args) {
new MyFrame();
}
public MyFrame(){
JFrame jf=new JFrame();
jf.setSize(500, 400);
jf.setVisible(true);
Container c=jf.getContentPane();
c.setLayout(null);

JLabel jl=new JLabel("我这个标签到底在哪里啊!!!");
jl.setHorizontalAlignment(SwingConstants.CENTER);
JButton bl=new JButton("这是一个对话框");
bl.setBounds(100,90,100,80);
bl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
new MyJDialog(MyFrame.this).setVisible(true);
}
});
c.add(bl);
c.setBackground(Color.BLACK);
c.add(jl);
}
}