当前位置:网站首页>Swing component
Swing component
2022-07-25 10:16:00 【Look at the bugs】
Popup
package Swing;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
public class Dialog01 extends JFrame {
public static void main(String[] args) {
new Dialog01();
}
public Dialog01() {
this.setVisible(true);
this.setBounds(100, 100, 200, 200);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Container container = this.getContentPane();
// Absolute layout
container.setLayout(null);
// Button
JButton button = new JButton(" Click to pop up a dialog box ");// establish
button.setBounds(100, 100, 500, 500);
// A pop-up window pops up when you click the button
button.addActionListener(new ActionListener() {
// Monitor
@Override
public void actionPerformed(ActionEvent e) {
new MyDialog();
}
});
container.add(button);
}
}
// Pop up window
class MyDialog extends JDialog{
public MyDialog() {
this.setBounds(100,100,100,100);
// this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Container container =new Container();
container.setLayout(null);
container.add(new Label(" Tomorrow's scenery is more beautiful "));
this.add(container);
this.setVisible(true);
}
}
边栏推荐
猜你喜欢
随机推荐
动态规划,购物单问题
一.初始MySQL,MySQL安装、配置环境、初始化
nodejs链接mysql报错:ER_NOT_SUPPORTED_AUTH_MODEError: ER_NOT_SUPPORTED_AUTH_MODE
[deployment of deep learning model] deploy the deep learning model using tensorflow serving + tornado
Leetcode 560 前缀和+哈希表
记录一些JS工具函数
UE4 外部打开exe文件
小程序企业发放红包功能
OSPF协议的配置(以华为eNSP为例)
Swing组件之单选与多选按钮
vant问题记录
拷贝过来老的项目变成web项目
JDBC操作数据库详解
CCF 201512-3 drawing
多数相合问题总结
Selenium 等待元素出现与等待操作可以执行的条件
Pow(x,n)
An ASP code that can return to the previous page and automatically refresh the page
贪吃蛇小游戏
CCF 201509-3 template generation system









