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

Thread: how to avoid flickering when calling another swing from

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to avoid flickering when calling another swing from

    Hi,

    I am trying to call another swing frame from my current frame. And after calling second frame i dispose the current frame.
    But while second frame comming on the screen, current frame gets dispose and second frame takes some seconds to appear on screen.
    So its creating a bad flickering effect on screen and its not suitable for my application.

    i want that first frame will call sencond frame and it will not look like second frame is called. I just want to cancel flickering effect.

    Here is my source code.
    1st Frame:

    public class Welcome extends JFrame
    {
    JFrame f;
    JTextArea nameField,nameField1;
    JLabel lable;


    public Welcome() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, InterruptedException
    {
    f=new JFrame();
    lable.setLayout(null );

    /*****heading text WELCOME*****/
    nameField = new JTextArea("Welcome");

    nameField.setBounds(320,370,650,150);
    nameField.setForeground(new Color(6,42,120));
    nameField.setFont(new Font("Caladea", Font.BOLD, 55 ));
    nameField.setOpaque(false);
    nameField.setEditable(false);

    nameField1 = new JTextArea("Here");
    nameField1.setBounds(170,470,750,150);
    nameField1.setForeground(new Color(6,42,120));
    nameField1.setFont(new Font("Caladea", Font.BOLD, 55 ));
    nameField1.setOpaque(false);
    nameField1.setEditable(false);

    lable.add(nameField);
    lable.add(nameField1);

    f.add(lable);
    f.setResizable(false);
    f.setUndecorated(true);
    f.validate();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().setFullScreenWindow(f);
    f.setVisible(true);

    Thread.sleep(3000);
    PBEnter pe = new PBEnter();
    }
    public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, InterruptedException
    {
    new Welcome();
    }
    }



    2nd Frame:

    public class PBEnter {

    JFrame f;
    JTextArea nameField1,nameField2,nameField3;
    JLabel lable;

    public PBEnter() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException, InterruptedException
    {

    f=new JFrame();

    nameField1 = new JTextArea("Enter Ur Name");
    nameField1.setBounds(200,350,650,150);
    nameField1.setForeground(new Color(6,42,120));
    nameField1.setFont(new Font("Caladea", Font.BOLD, 50));
    nameField1.setOpaque(false);
    nameField1.setEditable(false);

    nameField2 = new JTextArea("Middle Name");
    nameField2.setBounds(230,450,650,150);
    nameField2.setForeground(new Color(6,42,120));
    nameField2.setFont(new Font("Caladea", Font.BOLD, 50));
    nameField2.setOpaque(false);
    nameField2.setEditable(false);

    nameField3 = new JTextArea("Sirname");
    nameField3.setBounds(400,550,650,150);
    nameField3.setForeground(new Color(6,42,120));
    nameField3.setFont(new Font("Caladea", Font.BOLD, 50));
    nameField3.setOpaque(false);
    nameField3.setEditable(false);

    lable.setLayout(null );

    lable.add(nameField1);
    lable.add(nameField2);
    lable.add(nameField3);

    f.add(lable);
    f.setResizable(false);
    f.setUndecorated(true);
    f.validate();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().setFullScreenWindow(f);
    f.setVisible(true);

    Thread.sleep(3000);

    Registration r = new Registration();
    f.dispose();
    }

    public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, InterruptedException
    {

    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: how to avoid flickering when calling another swing from

    Please post your code correctly per the instructions that were given you in response to your first post.

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to avoid flickering when calling another swing from

    when second screen is called it comes up like a pop up on the screen. But i want Smooth navigation within my pages.
    I am using Linux Puppy as OS. And JRE 1.7 version.

  4. #4
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: how to avoid flickering when calling another swing from

    The delay is the time it takes to actually create the frame. Your computer is too slow to make it smoother.
    There are 2 things you can do:
    1) Have the first frame wait until the second one is displayed, possibly with busy-waiting. This is not nice and I would not recommend it, but its easy to do.

    2) Dont create a second frame. Instead, clear your first frame and fill it up with new components. This will probably need some refactoring to clean up references.

Similar Threads

  1. Animation keeps flickering
    By Pin Head in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 4th, 2013, 07:56 AM
  2. my Button is flickering
    By poldz123 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 20th, 2013, 03:30 PM
  3. JPanel flickering
    By Ghosth in forum AWT / Java Swing
    Replies: 1
    Last Post: April 30th, 2011, 10:52 AM
  4. Java swing buttons are flickering in windows 7 environment
    By javasam in forum Member Introductions
    Replies: 1
    Last Post: February 17th, 2011, 09:51 AM
  5. Java swing buttons are flickering in windows 7 environment
    By javasam in forum AWT / Java Swing
    Replies: 1
    Last Post: February 14th, 2011, 12:13 PM

Tags for this Thread