Reputation: 13
In order to develop a text editor in Java, the user is able to open several files with a object JTabbedPane
. Then, I stores such files on HashMap<String,TabManager>
. (The key of the HashMap
), should to be the name of the file. After, I have on memory the files opened within of HashMap
. Now, I need manage my tabs. For example, if the user is on tab selected by it, is evident that the user would like to change the font of the text, save file selected, copy it, and so on. For manage the tab selected by the user, I need of a class to get just the objects from tab selected, just. Such as, JTextPane
and File
. Basically, I should do:
for(Map.Entry<String, TabManager> entry: HashMap.entry)
{
String key = entry.getKey();
tabManager = entry.getValue();
if(tab.getTabSelected().equals(key))
{
// resquest objects from tab selected by the user
this.container = tabManager.getJTextPane();
this.file = tabManager.getFile();
}
}
I have on my hands the objects from tab selected by the user. Now, I going to handle it. The issue is:
How I handle this data ?
Upvotes: 1
Views: 228
Reputation: 1549
I can't see what is the name of your map... But assuming you have something like:
Map<String, TabManager> map = new HashMap<>();
where the string is the name of your tab, is unique per tab, and that you can get that name with tab.getTabSelected(), then you can do:
TabManager selectedTab = map.get(tab.getTabSelected());
to get the selected tab.
About your second question: how to handle that big data... Since you don't want to read and copy in memory the entire file every time, you want:
Upvotes: 1