Hi all, I've been having major problems with getting internal frames working when used over multiple classes in different files. Basically, I have a control program which has options when clicked should open a new internal frame in the desktop pane. At the moment I'm having trouble opening a new internal frame when the code is in a separate file. file J1 opens an internal frame in a desktop pane and file J2 should open another Internal frame but it displays nothing. I don't know why, I've tried everything I can think of but it won't work. Has anyone got internal frames to work over multiple classes ? The code: ---------------------------- file J1: import java.awt.*; import java.awt.event.*; import javax.swing.*; import J2;
Hi, what I did was, I created a Class that is my DesktopPane(). And I used that class to fire my multiple internalframes. So every other Internalframe I have is in it's on Class file. So here is some Psuedo to maybe help.
Now here is the Class for the InternalFrame
I hope that is enough to get you started. Remeber, quite a few variables will have to be GLOBAL so that all classes can see them so static is a good thing to do in most cases. At least that's what I have found. Good Luck!!
Thanks for replying I tried to use your code which looked good but I keep getting a nullpointer exception when running the app. If I take out a refrence to execute method IFrame1() it brings up the desktoppane and nothing else and no error. but as soon as I try to execute the IFrame1 method I get a null pointer exception. I'm beginning to think its impossible to use internalframes for any kind of app. Maybe I'll try to update my copy of the JFC swing or the JDk (I currently have version 1.2.1). It seems like it should be easy but its not. Any further ideas ??? Suhail Sarwar
I'm not sure why you are getting a null pointer. My code was rough, and should not have been coppied and pasted and used. I was just outlining the methods for you. Internal Frames CAN be used for Apps. That is all I use for my Apps that I create. I have had no problem. It just took me some time to get the feel of them. Could you post some of your code so that I can take a look? Also, put them in the CODE tags so that it looks better. Good Luck.
------------------ Happy Coding, Gregg Bolinger
Joined: Nov 22, 2008
The code I am using for the 2 files is:
The second file is......
I hope you can spot where the problem is. Thanks for your help. Suhail