Results 1 to 8 of 8
  1. #1
    Sanders is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default White flash on loading.

    Hello. I have made a very basic GUI (just a few buttons), and have changed the look and feel using Nimrod. It works fine, but when I run the GUI, it briefly flashes white before drawing in my theme. When I say briefly, it's literally a fraction of a second. If you blink, you'll miss it. But it's noticeable. And very annoying as it looks a bit untidy.

    Does anyone have any ideas how I can stop the flash? Can I hide the JFrame until the new theme has been applied, and then show it?

    Anyway, I'm using Netbeans 7.1 if that helps and running on Windows 7.

    Here's the code
    Java Code:
    import java.awt.Color;
    import javax.swing.*;
    import com.nilo.plaf.nimrod.NimRODLookAndFeel;
    import com.nilo.plaf.nimrod.NimRODTheme;
    
    public static void main(String[] args) 
        {        
            setTheme();
            
            NewJFrame njf = new NewJFrame();
            njf.setLocationRelativeTo(null);
            njf.setTitle("My First Swing Application");
            njf.pack();        
            njf.setVisible(true);
        }
    
    static void setTheme()
        {
            NimRODTheme nt = new NimRODTheme();
            nt.setPrimary1( new Color(0,51,153));
            nt.setPrimary2( new Color(0,92,143));
            nt.setPrimary3( new Color(0,102,153));
            nt.setSecondary1( new Color(31,31,31));
            nt.setSecondary2( new Color(41,41,41));
            nt.setSecondary3( new Color(51,51,51));
            nt.setWhite( new Color(0,0,0));
            nt.setBlack( new Color(255,255,255));
            nt.setMenuOpacity(195);
            nt.setFrameOpacity(180);
            
            NimRODLookAndFeel NimRODLF = new NimRODLookAndFeel();
            NimRODLF.setCurrentTheme (nt);
            
            try
            {
                UIManager.setLookAndFeel(NimRODLF);       
            }
            catch(Exception e)
            {
                
            }
            
        }
    Thanks for any help at all.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,585
    Rep Power
    23

    Default Re: White flash on loading.

    Your use of third party classes makes it hard for anyone to test the code as posted.

  3. #3
    Sanders is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Re: White flash on loading.

    My mistake. Here it is if it helps: nimrodlf.jar

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,585
    Rep Power
    23

    Default Re: White flash on loading.

    Your posted code is not compileable. no class def

  5. #5
    Sanders is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Re: White flash on loading.

    I should have posted in full - sorry. Here it is ...in full:

    Java Code:
    package formtest;
    
    import java.awt.Color;
    import javax.swing.*;
    import com.nilo.plaf.nimrod.NimRODLookAndFeel;
    import com.nilo.plaf.nimrod.NimRODTheme;
    
    public class FormTest {
        
        public static void main(String[] args) 
        {        
            setTheme();
            
            NewJFrame njf = new NewJFrame();
            njf.setLocationRelativeTo(null);
            njf.setTitle("My First Swing Application");
            njf.pack();        
            njf.setVisible(true);  
                    
        }    
            
        static void setTheme()
        {
            NimRODTheme nt = new NimRODTheme();
            nt.setPrimary1( new Color(0,51,153));
            nt.setPrimary2( new Color(0,92,143));
            nt.setPrimary3( new Color(0,102,153));
            nt.setSecondary1( new Color(31,31,31));
            nt.setSecondary2( new Color(41,41,41));
            nt.setSecondary3( new Color(51,51,51));
            nt.setWhite( new Color(0,0,0));
            nt.setBlack( new Color(255,255,255));
            nt.setMenuOpacity(195);
            nt.setFrameOpacity(180);
            
            NimRODLookAndFeel NimRODLF = new NimRODLookAndFeel();
            NimRODLF.setCurrentTheme (nt);
            
            try
            {
                UIManager.setLookAndFeel(NimRODLF);       
            }
            catch(Exception e)
            {
                
            }
            
        }    
        
    }
    Thanks.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,585
    Rep Power
    23

    Default Re: White flash on loading.

    How would anyone not knowledgeable with the package you are using know if the white flash was a feature that is supposed to happen?

  7. #7
    Sanders is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Re: White flash on loading.

    If I make a button that changes the l&f after runtime, then I can't see any flash. Works perfectly. It only happens when it is set at runtime.

    What I think is causing the flash is that the default l&f is being loaded first and then almost instantly switching to the new one. Because the default l&f is bright, and the new one is dark, the instant change cause a flash-like effect.

    What I need to do is make sure the new l&f is set and in place before the JFrame is even visible. But nothing I try seems to get rid of that flash.

    It's not a massive deal. It's not like it's not working, or anything. But I just want to know if there's a way around it, or if anyone else is annoyed by such a thing. Any help at all will be greatly appreciated.

    Thanks.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: White flash on loading.

    Quote Originally Posted by Sanders View Post
    What I think is causing the flash is that the default l&f is being loaded first and then almost instantly switching to the new one. Because the default l&f is bright, and the new one is dark, the instant change cause a flash-like effect.

    What I need to do is make sure the new l&f is set and in place before the JFrame is even visible. But nothing I try seems to get rid of that flash.
    It certainly doesn't help that you are constructing the GUI and setting the JFrame visible in the main Thread. Swing components should be constructed, and their methods called (barring a very few that are thread-safe) only on the EDT.

    Moving this thread to the Swing forum.

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

Similar Threads

  1. Replies: 2
    Last Post: 06-29-2011, 09:08 AM
  2. Okay..I'm waiving the white flag on this
    By velvetymold in forum New To Java
    Replies: 10
    Last Post: 02-22-2011, 06:15 AM
  3. JSTL and HTML White space
    By newakdev in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 02-24-2010, 05:54 PM
  4. loading flash files in linux
    By rajeshang in forum AWT / Swing
    Replies: 0
    Last Post: 05-31-2008, 01:59 PM
  5. White Space Issue
    By sibythoma1984 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 04-22-2008, 12:05 PM

Posting Permissions

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