File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using SpringLayout with JPanel

 
Nicholas van Orton
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keeping in mind that I'm just a beginner, this one is a real head scratcher for me. Here's what I've got at the moment:



I add this JPanel to my Main class:



My dilemma is that when I add the ControlPane() object to the BorderLayout.SOUTH of the JFrame, nothing appears! Yet It works when the ControlPane() object is added to the BorderLayout.CENTER of the JFrame - which I would be doing if I didn't have anything else to add to the JFrame.

Any clues?

Thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add this line to ControlPane's constructor

setPreferredSize(new Dimension(725,50));
 
Nicholas van Orton
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried your solutions, and the JPanel is now appearing. However, the JSlider object is not appearing where its SpringLayout constraints say it should appear.

Any more clues?
[ April 14, 2006: Message edited by: Nicholas van Orton ]
 
Nicholas van Orton
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had to remove the line "super(new SpringLayout());" and replaced it with "this.setLayout(layout);" at it works.

Any explanations as to why this is would be very much appreciated.

Thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it worked OK for me, as is, with the additional setPreferredSize line
ie with the "super(new SpringLayout());"

I'm using java 1.5.0_05, on winXP Pro
 
Nicholas van Orton
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Java 1.5.0_05 on Mac OS X v10.4 - I would have thought that this shouldn't have made any difference.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic