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 7 of 7

Thread: How to make a new screen on applet.

  1. #1
    Member
    Join Date
    Sep 2011
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default How to make a new screen on applet.

    Hi, Im making an applet that has a bunch of stages. The applet has a little "next" button down in the corner, and i want it to take them to the next section, however, unlike making a regular program i cant just make the next page in a seperate class and call on it from my original one... So how would i have the applet go to the next section...?
    Thanks
    Joel


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to make a new screen on applet.

    i cant just make the next page in a seperate class and call on it from my original one..
    Are you sure?
    Have you tried it?

  3. #3
    Member
    Join Date
    Sep 2011
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a new screen on applet.

    Yes, in my main applet i call on the next screen with :
            if (e.getSource()==add){
                FindApplet findapplet = new FindApplet();
            }

    and then the FindApplet class is a new applet all together...

    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class FindApplet extends Applet implements ActionListener
    { 
        JPanel panel = new JPanel();
        JButton nextButton = new JButton("Next -->");
        JRadioButton biologyClass = new JRadioButton("Biology");
        ...more radiobuttons
        ButtonGroup classButtonGroup = new ButtonGroup();
        public void init() {
            setLayout(new GridBagLayout());
            GridBagConstraints c = new GridBagConstraints();
            //add to button group
            classButtonGroup.add(biologyClass);
            ...add them all to group
            //add to panel
            panel.add(biologyClass);
            ...add them all to panel
            //add panel to applet with constraints
            add(panel, c);
            add(nextButton, c);
     
        }
     
        public void start() { 
        }
     
        public void actionPerformed(ActionEvent e){
     
        }
     
        public void stop() {
        }
     
        public void destroy() {
        }
     
    }

    However when i click the button that should open it, nothing happens...

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to make a new screen on applet.

    when i click the button that should open it, nothing happens..
    There is nothing in your posted code to make anything happen when you click the button.

    Creating a new instance of an Applet will NOT display a new window.

    Add some println statements to the methods in your code to see where execution goes as the program is executed.

  5. #5
    Member
    Join Date
    Sep 2011
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a new screen on applet.

    I dont want it to open in a new window, i want it to clear the current screen and make the new one. I put some println and the actionlistener works fine before and after i call a new FindPage, but the printlns i put in the FindPage didnt show up...

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to make a new screen on applet.

    the printlns i put in the FindPage didnt show up...
    That means that you are not executing the println statements.
    Does your code call any of the methods in the FindPage class?
    If you create a new instance the constructor should be called. Do you have a println in the constructor?

    Have you looked at the CardLayout class? It might have features that will help you.

  7. #7
    Member
    Join Date
    Sep 2011
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a new screen on applet.

    Hey, I think that the card layout would be best for what im doing. Thank you

Similar Threads

  1. Replies: 9
    Last Post: December 31st, 2011, 01:22 AM
  2. How to get screen size in Applet
    By anm_brr in forum Java Applets
    Replies: 2
    Last Post: August 10th, 2011, 09:21 PM
  3. Trying to figure out how to make a screen saver.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 59
    Last Post: August 8th, 2011, 07:05 AM
  4. How to make a mouseclick somewhere on the screen?
    By Broodjie in forum Java Theory & Questions
    Replies: 4
    Last Post: March 22nd, 2011, 06:58 AM
  5. Unnable to make validations work for login screen
    By fierof2 in forum Web Frameworks
    Replies: 8
    Last Post: July 29th, 2010, 07:12 AM