• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSplitPane not appearing

 
David Houghton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, any help would be appreciated and im assuming its just something simple ive missed.

Basically im adding to panels, mainPanel and treePanel to a JSplitPane and then adding them to my instance of JFrame. Ive had no problems adding the panels by themselves but when i try and put them into a split pane, the pane is not showing. The full class is shown below. Thanks.




second class containing the problem

 
David Houghton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody help? Ive tried everything i can think of from putting the JSplitPane on its own JPanel to adding it to the JFrame using a Container aswell as trying to add it via the getContentPane emthod

Really stumped here


Thanks

Dave
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Change the following line . Add your splittpane into the contentPane of the frame.


sat
 
David Houghton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sat, thanks for the reply, but unfortunately this is one of the ways that i tried to no avail.

Any opther suggestions?

Dave
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
satishkumar janakiraman wrote:Hi,

Change the following line . Add your splittpane into the contentPane of the frame.


sat

Since Java 5.0 this is no longer necessary.

David, you forgot to call pack(). That's probably all.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your problem is the indicated line



if you want to use null, you are responsible for the size and location of the added component.
as you haven't specified any for jspMain, it will appear at 0,0 with a size of 0,0

comment out that line, recompile and rerun
 
David Houghton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael and Rob, i realised that the problem was something to do with the component state not being initialised correctly as the pack method caused the frame to resize around the JMenuBar.

I had tried using setLocation on the pane, but hadnt remembered to explicitly set the size aswell, which should have been obvoius since i carried it out when creating the panels to go into the actual SplitPane!


Thanks to all

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!