This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with dynamic InternalFrames.

 
Rajapragada Dharani
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajapragada Dharani
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic