This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Swing GUI Updates in Eclipse but Not in Exported JAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing GUI Updates in Eclipse but Not in Exported JAR" Watch "Swing GUI Updates in Eclipse but Not in Exported JAR" New topic
Author

Swing GUI Updates in Eclipse but Not in Exported JAR

Jack Roberts
Greenhorn

Joined: Jan 23, 2012
Posts: 3
Hi everyone,

I'm new here and pretty new to java and GUIs so please bear with me! I have a GUI that works fine when I run it from Eclipse but when I export the JAR and try to run it elsewhere there are a couple of minor things that are different/don't work - a font isn't applied and, more importantly, an aspect of the GUI doesn't work correctly (I'll focus on this as for now I'm not too worried about the font).

Basically I have a small 'popup' window that appears from a button that's clicked in the main program. On this window are two radio buttons and depending on which is selected a different JPanel should appear to allow the user to either enter a constant value for a parameter or to use multiple values from a file. The code I'm using is as follows:



This works fine in eclipse but in the exported JAR the displayed JPanel only changes if the window is resized. I have also tried putting repaint() statements in there but that doesn't seem to make a difference. It could be due to differences in java versions but I really need it to work across different platforms/versions anyway.

If anyone has any ideas I'd love to hear them!

Thanks,
Jack
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

depending on which is selected a different JPanel should appear

In a word: CardLayout.

About your present problem: it's usually necessary to call repaint() after revalidate(). But don't go that way, CardLayout was designed for your need.


luck, db
There are no new questions, but there may be new answers.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

And welcome to the Ranch!
Jack Roberts
Greenhorn

Joined: Jan 23, 2012
Posts: 3
Thanks, I guess I can go down that route. I'm using Card layouts elsewhere in the GUI but I was hoping to use something a bit simpler here and to make it more obvious that only one of the two options can be used. It is strange that it works in Eclipse and not elsewhere though...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Sorry, but I really don't see how adding and removing components from a container can be easier than using CardLayout.

About this:
Basically I have a small 'popup' window that appears from a button that's clicked in the main program. On this window are two radio buttons

Have you considered using a JMenu with two JRadioButtonMenuItems (or maybe just one JCheckBoxMenuItem) instead? Popup dialogs can get annoying.

a different JPanel should appear to allow the user to either enter a constant value for a parameter or to use multiple values from a file.

Sounds like something that could be done with an editable JComboBox, obviating the need for either a popup or a menu. The 'values from a file' would populate the combo's model, and a custom value could be entered in the editor.
Jack Roberts
Greenhorn

Joined: Jan 23, 2012
Posts: 3
Sorry about my reply earlier, for some reason when you said CardLayout I thought you meant a JTabbedPane... I have now switched to using a CardLayout and it's working, thanks

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing GUI Updates in Eclipse but Not in Exported JAR
 
Similar Threads
Card layout...
Trouble executing(actionlistener) the swing applet properly in html
Exporting to jar file in eclipse
Gui Problem from Netbeans
JoGL 2.0