aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problem with dynamic InternalFrames. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with dynamic InternalFrames." Watch "Problem with dynamic InternalFrames." New topic
Author

Problem with dynamic InternalFrames.

Rajapragada Dharani
Greenhorn

Joined: Oct 23, 2003
Posts: 15
HI,

I'am new to swings so please excuse if my logic is not proper and please correct me asap.I'am using 3classes myFrame ,myInternalFrame1 and myInternalFrame2.

myFrame extends JFrame and
myInternalFrame1 & myInternalFrame2 extends JInternalFrames.

myFrame is my main class and shown first in the view.On an event on clicking a link I'am adding myInternalFrame1 to the jDesktopPane from myFrame.This works fine.

Now when I click a button from myInternalFrame1 I need to add myInternalFrame2 to the desktoppane through myFrame.But myInternalFrame2 is unable to apear in my desktoppane.Please follow the brief code below and suggest me how to do this.

class myFrame extends JFrame{
..............

public void actionPerformed(ActionEvent event) {
if (event.getSource().equals(someEvent)){

myInternalFrame1 iframe1 = new myInternalFrame1();
//showFrame1 method returns an internalframe.
myDesktopPane.add(iframe1.showFrame1());
}
}
..............
}

class myInternalFrame1 extends JInternalFrame {
..............
public void actionPerformed(ActionEvent event) {
if (event.getSource().equals(someEvent)){

myInternalFrame2 iframe2 = new myInternalFrame2();
//showFrame2 method returns internalframe.
myFrame.myDesktopPane.add(iframe2.showFrame2());
}
}
..............
}
class myInternalFrame2 extends JInternalFrame {
..............

..............
}


I have tried several ways to add it to the desktoppane like passing the event from myInternalFrame1 to myFrame and then adding myInternalFrame2 from the myFrame class etc but in any case i'am unable to show myInternalFrame2.I have also properly set all necesary properties for internalframes like setbounds etc.

Your suggestion will be of a great help to me.

Regards Rajarao.D
Josh Juneau
Ranch Hand

Joined: Jun 16, 2004
Posts: 86
Prior to adding your frame to the desktop you need to make it visible. Something like the following:

MyInternalFrame1 iFrame = new MyInternalFrame1();
iFrame.setVisible(true);
//obtain desktop
myDesktopPane = getDesktopPane();
//add to desktop
myDesktopPane.add(iFrame);
//move to front...if desired
iFrame.moveToFront();


Hope this helps. By the way, all of my internal frames are in separate Java classes as well if that makes any difference.


Database Administrator/Application Developer
Rajapragada Dharani
Greenhorn

Joined: Oct 23, 2003
Posts: 15
HI,
Thanks for your reply.I have worked out setting setVisible(true), but the problem still persisted...then i tried on the same grounds using setBounds and lo my internalframe was cooly showing up.
Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with dynamic InternalFrames.