• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with dynamic InternalFrames.

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic