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.
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...
Sorry, but I really don't see how adding and removing components from a container can be easier than using CardLayout.
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.
Joined: Jan 23, 2012
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