其他分享
首页 > 其他分享> > JDialog弹窗

JDialog弹窗

作者:互联网

 

 

 

public class DialogDemo  extends JFrame {
    public  DialogDemo(){
        setVisible(true);
        setBounds(300,300,400,500);
        Container container= this.getContentPane();
        container .setBackground(Color.green);
        JButton button=new JButton("点击弹窗");
        container.add(button);
        container.setLayout(null);
        button.setBounds(20,20,300,50);
        container.add(new Label("郭江龙"));
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new  MyDialog();
            }
        });
    }

    public static void main(String[] args) {
        new  DialogDemo();
    }
}
class MyDialog extends JDialog{
public  MyDialog(){
    setVisible(true);
        setBounds(200,200,200,200);
    Container container= this.getContentPane();
container.setBackground(Color.red);
container.add(new Label("你好你好"));

    }
}

 

标签:200,container,MyDialog,button,public,new,JDialog,弹窗
来源: https://www.cnblogs.com/guojianglong/p/16557627.html