I have one tab by default (tab1)
New tabs are generated , equal to 'No of rooms'.
The dynamically generated tabs have same structure as of the default tab.
I don't know the name of textfields of newly generated tabs.
How can I find the name of jtexfields generated on tab at run time so I can use .getText()

Recommended Answers

That looks like you are adding exactly the same component (not copies) to every tab - not what you want! See previous post.

Jump to Post

All 4 Replies

Each tab should be created as an instance of a class, so each instance will have its own instance variable values for its own fields. Wherever you have the code to control the creation of new tabs, keep an ArrayList of those instances so you can reference them, and thus their methods and variables.

Sorry I forgot to add the code

int no_room = Integer.parseInt(jTextField6.getText());
for(int i = 1 ; i<no_room; i++)
{
int c = jTabbedPane5.getTabCount();
jTabbedPane5.addTab("tab "+(i+1), jTabbedPane5.getTabComponentAt(c-1));
jTabbedPane5.validate();
jTabbedPane5.repaint();
}

That looks like you are adding exactly the same component (not copies) to every tab - not what you want! See previous post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.