Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: connecting jframe

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default connecting jframe

    Actually I am new to java so I want to know how we link these to files. After pressing Next Button it should change to Welcome Frame.

    Enter.java
     import java.awt.FlowLayout;
     
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
     
    public class Enter extends JFrame {
     
        public Enter() {
            // TODO Auto-generated constructor stub
     
            setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
     
            add(new JLabel("Name"));
            add(new JTextField(8));
            add(new JLabel("Address"));
            add(new JTextField(15));
            add(new JLabel("Surname"));
            add(new JTextField(8));
            add(new JLabel("Phone"));
            add(new JTextField(8));
            add(new JButton("Next"));
        }
     
     
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
        	Enter myProg = new Enter();
            myProg.setTitle("Ceng 344 - Lab 7");
            myProg.setSize(450, 400);
            myProg.setLocationRelativeTo(null);
            myProg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myProg.setVisible(true);
        }
     
    }
    Welcome.java
     import java.awt.FlowLayout;
     
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
     
    public class welcome extends JFrame {
     
        public welcome() {
            // TODO Auto-generated constructor stub
     
            setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
     
            add(new JLabel("Welcome"));
            }
     
     
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            welcome myProg = new welcome();
            myProg.setTitle("Ceng 344 - Lab 7");
            myProg.setSize(450, 400);
            myProg.setLocationRelativeTo(null);
            myProg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myProg.setVisible(true);
        }
     
    }
    Last edited by helloworld922; March 4th, 2013 at 12:20 PM. Reason: please use [code] tags


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: connecting jframe

    After pressing Next Button it should change to Welcome Frame.
    Look at using an ActionListener with the button. See the tutorial:
    How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. problem with my JFrame; JFrame not closing and stay in background
    By golominator in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 6th, 2012, 08:20 AM
  2. Connecting to VPN
    By raviteja84 in forum Java Networking
    Replies: 0
    Last Post: October 18th, 2011, 05:53 PM
  3. connecting jframe to another jframe
    By ajtambalo in forum Member Introductions
    Replies: 2
    Last Post: May 11th, 2011, 11:24 AM
  4. Connecting events
    By Olufemi in forum AWT / Java Swing
    Replies: 0
    Last Post: April 21st, 2010, 04:58 AM
  5. Connecting to a database
    By fwashington in forum JDBC & Databases
    Replies: 5
    Last Post: March 15th, 2010, 01:37 PM

Tags for this Thread