当前位置:网站首页>Swing组件
Swing组件
2022-07-25 09:27:00 【看小虫子】
弹窗
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();
//绝对布局
container.setLayout(null);
//按钮
JButton button = new JButton("点击弹出一个对话框");//创建
button.setBounds(100, 100, 500, 500);
//点击按钮时弹出一个弹窗
button.addActionListener(new ActionListener() {
//监听器
@Override
public void actionPerformed(ActionEvent e) {
new MyDialog();
}
});
container.add(button);
}
}
//弹窗的窗口
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("明天的风景更美丽"));
this.add(container);
this.setVisible(true);
}
}
边栏推荐
猜你喜欢
![[RNN] analyze the RNN from rnn- (simple|lstm) to sequence generation, and then to seq2seq framework (encoder decoder, or seq2seq)](/img/6e/da80133e05b18c87d7167c023b6c93.gif)
[RNN] analyze the RNN from rnn- (simple|lstm) to sequence generation, and then to seq2seq framework (encoder decoder, or seq2seq)

小程序调起微信支付

Probability theory and mathematical statistics 4 continuous random variables and probability distributions (Part 1)

线程池的设计和原理

史上最全面的UE4 文件操作,打开,读、写,增、删、改、查

文件的上传功能

线程池的死锁事件

Detailed explanation of MySQL database

@Import, conditional and @importresource annotations

安装 oh my zsh
随机推荐
oracle 解析同名xml 问题
JS uses requestanimationframe to detect the FPS frame rate of the current animation in real time
Common methods of nodejs version upgrade or switching
Excel导入导出源码分析
CCF 201512-4 delivery
MVC三层架构理解
Introduction to Verdi Foundation
IO流中的输入流
多线程——Runnable接口,龟兔赛跑
shortest-unsorted-continuous-subarray
canal实现mysql数据同步
Yarn quick reference manual
mysql历史数据补充新数据
framework打包合并脚本
JDBC总结
腾讯云之错误[100007] this env is not enable anonymous login
复现 SSL_Anti-spoofing, 使用 wav2vec 2.0 和数据增强的自动说话人认证的欺骗攻击与深度伪造检测
广度优先遍历(图和二叉树的层序遍历相关问题)
UE4 窗口控制(最大化 最小化)
Arm preliminaries