PDA

View Full Version : Tab Change Contents (Help!)


onl1ne
08-17-2009, 02:40 PM
Hi..

Im currently working on my project and I have a big problem with changing the layout of tabs. Basically, when I launch my GUI, it will display "No Data Available" in my view tab. In my Add tab, I have the admin panel whereby the user enters the data to be stored and display. the problem now lies when displaying. It is a juke ringtone gallery whereby when there are data being stored in the database, it will display the following in a Gridlayout;

I applied the ChangeListener to the JTabbedPane which is tp. I added tabs using tp.add. I declared this in my ChangeListener:
if(tp.getSelectedIndex() == 0)
createViewPanel();
else if(tp.getSelectedIndex()==1)
createAddPanel();

where createViewPanel() is for the View tab and createAddPanel() is for the Add tab. i also called the respective tabs using frameView = (JPanel)tp.getComponent(0); to get the layout for View tab and frameAdd = (JPanel)tp.getComponent(1); to get the layout for the Add tab.
What methods need I use so that I can display the different data in the specific GridLayout to be displayed in the View tab or what other ways can I do it or is there any advices for me so that I can change my View tab from a FloayLayout to a GridLayout once I pressed the "Add New Ringtone" button?