problems with JSplitPane

Hi friends,

I've got problems with a JSplitPane I'm using in my application. The left component has a JTree that is used as a menu, each time a node is selected, the right component of the splitpane must change.

Here's how I handle tree selections:

publicvoid valueChanged(TreeSelectionEvent e){

// check params

if( e ==null )return;

DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) this.menuTree.getLastSelectedPathComponent();

Object userObject = selectedNode.getUserObject();

if( userObjectinstanceof String ){

String command = (String) userObject;

if( command.equals(LEVEL2AA_STRING) ){

// display the skill panel.

this.rightPanel =new SkillPanel();

}

else

if( command.equals(LEVEL2BB_STRING) ){

// panel for editing cities

this.rightPanel =new ProvincePanel();

}

// display the panel

this.splitter.setRightComponent(new JScrollPane(this.rightPanel) );

It works, but I've got annoying problem of refreshing. In particular, whena voice is selected, I have to change size to the frame that contains the splitpane to see the right part of the panel. It seems as the right part of the window is not shown (i debugged the application and the right component is correctly created and placed).

How can I solve this problem?

Thanks,

Luca

[2118 byte] By [cat4hirea] at [2007-10-3 8:24:35]
# 1
Normally you use revalidate() on the parent component to make sure the component is repainted.
camickra at 2007-7-15 3:30:44 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks for the suggestion, the use of revalidate has partially fixed my problem. Now when the first right component is shown and I change it with another I can see the other one immediatly. However, the first component to be shown is still not shown untill I manually resize the window (forcing a repaint). Any idea?

Luca

cat4hirea at 2007-7-15 3:30:44 > top of Java-index,Desktop,Core GUI APIs...
# 3

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.

camickra at 2007-7-15 3:30:44 > top of Java-index,Desktop,Core GUI APIs...