Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Internal Frames  RSS feed

 
kevin comario
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a text editor that can have multiple files opened at first i wanted to achieve this by using JTabbedPane but have decided to go with JInternalFrame instead. So when someone selects New or Open in my File menu a new JInternalFrame is opened contaning A JTextArea with the contents of a file or blank depeniding on the option chosen. I have done that by having a AtionListener create a new instance of a file I call NewInternalFrame whose constructor takes a Sting filename and a String fileContents. All of it works well but I ran into a problem how do i keep track of all the JTextAreas. I want the user to be able to Save and SaveAll depending on if a file was modified(I'm pretty sure i can do this with a KeyListener) but i dont know how to keep track of all the JInternalFrames and thier JTextAreas.
Can someone give me any ideas, like should i push the file name on a stack and if i do what about the textarea?
 
Murali Nanchala
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a collection Object in your main Class to keep track of all the Internal Frames you create. Possibly, name them in some sequential order till they are actually saved on the disk; You could then possibly use the filename as the key in the collection Object.
Name the TextAreas relative to the names of their parent Internal Frames. What say?
Murali
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!