3

I have one JFrame(HMSDoctor) and in that i am calling one JInternalFrame(CurrentOPD) by using JDesktopPane.

//opening JInternalFrame(CurrentOPD) by using JDesktopPane in JFrame(HMSDoctor).

       JDesktopPane jdp=new JDesktopPane();
   jdp.add(new CurrentOPD);

//Above code display proper JInternalFrame.

When i close that JInternalFrame at that time i want to execute one other JInternalFrame(Follow) in JFrame(HMSDoctor).

How can i do like that?

Daxesh Prajapati
  • 151
  • 3
  • 13

3 Answers3

5

See the section from the Swing tutorial on How to Write an Internal Frame Listener. I would guess you would want to listen for the "closed" event and then do some additional processing.

camickr
  • 321,443
  • 19
  • 166
  • 288
4
 public void actionPerformed(ActionEvent e) {
    if (SHOW.equals(e.getActionCommand())) {
        ...
        if (listenedToWindow == null) {
            listenedToWindow = new JInternalFrame("Event Generator",
                                                  true,  //resizable
                                                  true,  //closable
                                                  true,  //maximizable
                                                  true); //iconifiable
            //We want to reuse the internal frame, so we need to
            //make it hide (instead of being disposed of, which is
            //the default) when the user closes it.
            listenedToWindow.setDefaultCloseOperation(
                                    WindowConstants.HIDE_ON_CLOSE);

            listenedToWindow.addInternalFrameListener(this);
            ...
        }
    } 
    ...
}
Ravi Parsania
  • 715
  • 7
  • 11
1

Yes, First you have to addInternalFramaeListener in main frame and when your JInternalFrame(CurrentOPD) closed at that time you can call JInternalFrame(Follow)

Daxesh Prajapati
  • 151
  • 3
  • 13
DNP
  • 501
  • 4
  • 9