Results 1 to 7 of 7
Like Tree2Likes
  • 2 Post By Tolls

Thread: how to avoid flickering when calling another swing from

  1. #1
    pradeep24 is offline Member
    Join Date
    Jul 2014
    Posts
    5
    Rep Power
    0

    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
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,098
    Rep Power
    6

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

    I find it amazing that it works at all, since both frames are set to exit the application when they are closed.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

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

    Don't use Thread.sleep().

  4. #4
    pradeep24 is offline Member
    Join Date
    Jul 2014
    Posts
    5
    Rep Power
    0

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

    Yes i have tried that by removing thread. But its not working. '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.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

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

    If you don't want it to look like the second frame is called then don't use a second frame.
    Use the first frame and change the JPanel displayed.

    Most apps should have only the single frame, changing what's displayed in that frame.
    gimbal2 and DarrylBurke like this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

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

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,098
    Rep Power
    6

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

    Wow look, DarrylBurke is alive!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 4
    Last Post: 07-28-2012, 11:13 PM
  2. Replies: 3
    Last Post: 02-29-2012, 09:38 PM
  3. Screen Flickering
    By dewitrydan in forum New To Java
    Replies: 2
    Last Post: 08-17-2010, 07:45 PM
  4. Calling a crystal report from swing form
    By sams in forum AWT / Swing
    Replies: 2
    Last Post: 05-14-2010, 05:59 AM
  5. Java Swing GUI Windows XP Flickering Probelm
    By hemanthjava in forum AWT / Swing
    Replies: 1
    Last Post: 12-12-2008, 02:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •