弹窗 JDialog
public class JDialogdemo01 extends JFrame {
public JDialogdemo01() {
setVisible(true);
setSize(800,600);
this.setDefaultCloseOperation(WindowConstants
.EXIT_ON_CLOSE
);
Container container
=this.getContentPane();
container
.setLayout(null
);
JButton jButton
= new JButton("这是一个弹出窗口");
jButton
.setBounds(100,100,300,300);
container
.add(jButton
);
jButton
.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e
) {
new MyJDilog();
}
});
}
public static void main(String
[] args
) {
new JDialogdemo01();
}
}
class MyJDilog extends JDialog{
public MyJDilog() {
setVisible(true);
setBounds(100,100,400,400);
Container container
= getContentPane();
container
.setLayout(null
);
container
.add(new Label("学习java很好"));
}
}
转载请注明原文地址:https://tech.qufami.com/read-15492.html