import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyDJialog extends JDialog{
public MyDJialog(JFrame ee) {
super(ee,"这行文字在哪?",true);
Container c=getContentPane();
c.setBackground(Color.green);
JLabel q=new JLabel("弹窗文字");
q.setHorizontalAlignment(SwingConstants.CENTER);
q.setFont(new Font("黑体",Font.BOLD,30));
c.add(q);
setBounds(100, 100, 200, 200);
setVisible(true);
}
public static void main(String[] args) {
JFrame j=new JFrame("这是父窗体");
j.setBounds(300, 300, 400, 400);
j.setVisible(true);
Container c=j.getContentPane();
JButton bt=new JButton("点我点我快点我");
bt.setLayout(new FlowLayout());
c.add(bt);
j.setDefaultCloseOperation(EXIT_ON_CLOSE);
bt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new MyDJialog(j);
}
});
}
}
请问这个代码写出来后,整个父窗体变成一个按钮了,问题出在哪里?