微型技术博客-SWing界面跳转。
来源:互联网 发布:mac流程图软件 编辑:程序博客网 时间:2024/05/23 15:48
import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;public class frame1 extends JFrame implements ActionListener{ /** * @param args */ private JButton jb; public frame1() { this.setSize(300, 200); this.setLocation(300, 400); jb=new JButton("跳转"); this.add(jb); jb.addActionListener(this);//加入事件监听 this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub frame1 frame=new frame1(); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if(e.getSource()==jb) { this.dispose();//点击按钮时frame1销毁,new一个frame2 new frame2(); } }}frame2是个单纯的界面import javax.swing.JButton;import javax.swing.JFrame;public class frame2 extends JFrame{ /** * @param args */ public frame2() { this.setSize(300, 200); this.setLocation(300, 400);this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub frame2 frame=new frame2(); }}假如有两个frame,分别为frame1,frame2,frame1加个按钮实现跳转.frame1代码如下
阅读全文
0 0
- 微型技术博客-SWing界面跳转。
- 微型技术博客-Qt实现简单界面.
- Swing 技术博客
- 微型技术博客001-typedef和宏
- 微型技术博客——connect函数
- 微型技术博客002-Java多线程
- 微型技术博客003-Java工厂模式
- 微型技术博客-探究connect()函数。
- 微型技术博客之匿名内部类
- 微型技术博客之静态类
- java swing 登陆界面+跳转界面
- 微型技术博客004-深入探究connect函数
- 微型技术博客—javaswing的简单用法
- 关于微型投影技术
- 用Photoshop制作微型界面
- 微型技术报告(4)
- 微型技术报告(1)
- 微型技术报告(2)
- JAVA生成Word文档
- Java 多线程中关于 ExecutorService 和 CompletionService的讨论
- [es6] let & const
- 51NOD1433:0和5(数论)
- H5自测题5
- 微型技术博客-SWing界面跳转。
- 中位数
- 使用IntelliJ IDEA 配置Maven
- 编译openblas报错:no such instruction: vpermpd
- BZOJ 1143: [CTSC2008]祭祀river 二分图最大点独立集
- 阿里大于短信验证码简单使用
- Angular中支持SCSS
- 获取HTML元素4个方法
- H5自测6