• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Internal Frame

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am diplaying a file list and its content in a split pane. The left side is the file list and the right side is the JInternalFrame object that diplays the file content. Each time an item is chosen in the list, an internal frame is displayed. If the same items is pressed twice, two identical internal frames are displayed. How can i diplay the previously opened internal frame it is still exist and open a new internal frame only when no previously exist frame?
Thanks.
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd probably use something like a HashMap. That way whenever a file is opened you could create the Internal Frame and store it in the map with a key of the file name. Then whenever the user clicks to open a file you could search the map to see if a key of that file's name already exists, if it doesn't create the frame and store it, otherwise you could get the internal frame from the map and bring it to the front or whatever.
Jeff
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,
I thought of using HashMap too. However, there is one possibility that user can close the internal frame. How can i detect this closing event and remove the associated entry from the HashMap? For instance, Class A(File list) instantiate several Class B (Internal Frame) and display them on the right split pane. Now A has entries for b's. When one of B is closed. How can A detect this event and remove entry of b from HashMap? Add on: When i display the multiple internal frames, the new frame always appear below the old frame. If i click at the bottom of the new frame, it will not focus. I have to click at the top bar(position where the closing button located) first to make the focusing behaviour to be normal? Do you have any idea?
Thanks.
 
Jeff SmithX
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could add an InternalFrameListener, and listen for closed events and then remove the file from the HashMap when the internal frame is being closed.
Jeff
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,
Thank you for reminding me about the InternalFrameListener. I am able to get the behaviour as expected. However, when my internal frame is displayed, it appears as pop under instead of popup. When i click at the bottome of the pop under internal frame, i cannot bring it to focus. I must click at the very to bar where maximize and minimize button located to focus the frame. Do you have any thought about this phenomena?
Thanks.
 
Jeff SmithX
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried setting focus to the frame. Or calling bringToFront() (I think there's a method like that, or something similar)? Sorry I can't be of more help, but the last time I used internal frames I had problems with focus as well, so I ended up not using them.
Jeff
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a toFront() method that should bring the frame to the front.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic