package zhongyu;
import javax.swing.*;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Demo extends JDialog{
public Demo() {
Container c = getContentPane();
c.add(new JLabel("博主是帅哥!!!"));
setVisible(true);
setBounds(300,300,300,300);
}
public static void main(String[] args) {
JFrame f = new JFrame("父窗体");
f.setBounds(100,100,620,620);
Container c = f.getContentPane();
JButton btn = new JButton("弹出一个秘密");
c.add(btn);
f.setVisible(true);
f.setDefaultCloseOperation(EXIT_ON_CLOSE);
c.setLayout(new FlowLayout());
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Demo();
}
});
}
}
Java创建一个及对话框
最新推荐文章于 2024-07-19 17:37:28 发布