Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes GridBagLayout GUI is not displayed, this symbol is displayed instead Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GridBagLayout GUI is not displayed, this symbol is displayed instead" Watch "GridBagLayout GUI is not displayed, this symbol is displayed instead" New topic
Author

GridBagLayout GUI is not displayed, this symbol is displayed instead

Roman Rodriguez
Greenhorn

Joined: Sep 19, 2012
Posts: 7
I have written a small application whose GUI is designed with GridBagLayout. It is, in fact, just a JTextArea into a JScrollPane. Just that.

When I execute my application in my computer, it looks ok. But after some time using it, sometimes the whole frame is empty and only shows this symbol:


Also, when I execute my application on a Windows 7 tablet (HP Slate), this happens always, just executing the application.

What does this means? Where is the problem?

My code is simple:
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1088
    
  10

Hi,
Welcome to the Ranch!

You should create and show Swing windows/components only in the Event Dispatch Thread. Check this link which shows a sample program from the Oracle tutorial: sample.
You have to wrap the calls in a SwingUtilities.invokeLater().


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Roman Rodriguez
Greenhorn

Joined: Sep 19, 2012
Posts: 7
Ok, so I understand, after reading about Initial Threads that I should create GUI elements like that, letting that work be done at the end by a thread which is going to be invoked when possible.

So, that symbol is appearing because my windows 7 tablet is single core and can't create gui then? It sounds right, but at my code I'm doing it at the beginning, so I don't understand how this problem appears in this particular case.
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Hi Roman,

You need to specify values for weightx and weighty properties of the gridbag constraints so that the component can be spanned horizontally and vertically. For example:


PM Me If You Want to get Urgent Help on Java Programming
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

The problem you are having usually happens when the window is resized so the component can't fit it so it "shrinks" (though your frame is set not to be resizeable, which confuses me now).
Try adding this:

in createGUI() method, after you set gridx/gridy of your GridBagConstraints instance.


The quieter you are, the more you are able to hear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GridBagLayout GUI is not displayed, this symbol is displayed instead