微型技术博客-SWing界面跳转。
2017-06-10 15:31
239 查看
假如有两个frame,分别为frame1,frame2,frame1加个按钮实现跳转.frame1代码如下
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(); }}
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(); }}
相关文章推荐
- 完全解决快速连续多次点击button导致跳转多个界面(注:方法从他人博客中看到,稍作修改)
- 微型技术博客001-typedef和宏
- Swing界面设计工具的基本思想和技术
- MobLink网页跳转app指定界面技术简介之 URL Scheme
- 微型技术博客之匿名内部类
- 微型技术博客-探究connect()函数。
- Swing界面设计工具的基本思想和技术
- 微型技术博客004-深入探究connect函数
- 微型技术博客002-Java多线程
- 用wxWidgets做界面 - 力为的技术博客 - C++博客
- 微型技术博客——connect函数
- 微型技术博客之静态类
- 这个博客发不了.带有代码的技术文章.这怎么行啊.!!!汗,
- 使用无刷新技术,去请求该失效Session的页面,实现跳转到重新登陆页面。
- 技术博客开通
- 使用AJAX技术打造博客无刷新搜索引擎
- java技术博客今天开通了!
- 在java中创建自己的swing界面
- 你想要一个什么样的技术博客?
- 乱弹csdn博客后台界面