Java Button Implementation page jump

Source: Internet
Author: User
If there are two frame, frame1,frame2,frame1 add a button to implement the jump. Frame1 code is as follows 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 ("Jump");
        This.add (JB);
        
    Jb.addactionlistener (this);/Join Event Listener this.setvisible (TRUE); public static void Main (string[] args) {//TODO auto-generated method stub frame1 frame=new fram
           
    E1 (); @Override public void actionperformed (ActionEvent e) {//TODO auto-generated method stub if (e.g
        Etsource () ==jb) {this.dispose ()//click Button frame1 destroy, new one frame2 new Frame2 ();
}} frame2 is a simple interface import Javax.swing.JButton; Import Javax.swing.JFrame; public class Frame2 extends jframe{/** * @param args/Public frame2 () {this.se
        Tsize (300, 200);

This.setlocation (300, 400);
    This.setvisible (TRUE); public static void Main (string[] args) {//TODO auto-generated method stub frame2 frame=new frame
    2 (); }

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.