property change listener error with jtabbedpane

Greetings

I have a property change listener on my jtabbedpane (2 panes (index 0 of course and index 1). my problem is when i want to run my app it gives me a java null pointer exception. I believe it is b/c it is starting the app and it see the property change of the first tab at index 0 which is the first tab it sees and tries to run the method that makes the buttons visibility to true. but the buttons are already true. Basically how can I get the property change to run only after the app is visible? I made the buttons visibility false on startup to see if it can run the app but I still got the same error. I hope I am clear enough, if I am not please and I will attempt to reiterate the situation better. thanks for anyones help.

tabs =new JTabbedPane();

tabs.addChangeListener(this);

tabs.setPreferredSize(new java.awt.Dimension(800, 400));

tabs.addTab("Q", tab1.getMa());

tabs.addTab("R", tab2);

publicvoid stateChanged(ChangeEvent changeEvent){

JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();

int index = sourceTabbedPane.getSelectedIndex();

//System.out.println("Tab changed to: " + sourceTabbedPane.getTitleAt(index)+" Index: "+index);

if (index==1){

changeButtonsF();

///makes buttons false on side panel

}

elseif (index==0){

changeButtonsT();

//makes buttons true on side panel

}

}

[2053 byte] By [h2opologirly69a] at [2007-11-27 11:57:49]
# 1

> Basically how can I get the property change to run only after the app is visible?

Add the PropertyChangeListener to the tabbed pane after the JFrame is visible.

If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",

see http://homepage1.nifty.com/algafield/sscce.html,

that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

camickra at 2007-7-29 19:16:08 > top of Java-index,Desktop,Core GUI APIs...
# 2

thank you that worked, should of thought of that! silly me

h2opologirly69a at 2007-7-29 19:16:08 > top of Java-index,Desktop,Core GUI APIs...