Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

Custom JPanels inside another JPanel.

Thread view: 
pek - 31 Jul 2007 18:55 GMT
So I have this JPanel that I add a scroll pane to make it scrollable.
I created a class that is a subclass of JPanel, lets call it
CustomPanel. CustomPanel basically has some labels, buttons etc. What
I do is add a CustomPanel to the JPanel. What I want is that
CustomPanel should have the width of JPanel but it's own height. That
way JPanel ultimately is contains a list of CustomPanels. What the
problem is that I tried to use BoxLayout and GridLayout. Let's say
that JPanel's height is 4 times the CustomPanel's one. If I add one
CustomPanel, that will expand and use all of JPanels area. If I add
more that 5 the CustomPanels are correctly added with the correct
size. So, I can't figure out what Layout Manager to use.

Any help?
Thank you.
Joshua Cranmer - 31 Jul 2007 21:50 GMT
> So I have this JPanel that I add a scroll pane to make it scrollable. I
> created a class that is a subclass of JPanel, lets call it CustomPanel.
[quoted text clipped - 10 lines]
> Any help?
> Thank you.

Try a FlowLayout with a vertical direction.
pek - 01 Aug 2007 03:36 GMT
> > So I have this JPanel that I add a scroll pane to make it scrollable. I
> > created a class that is a subclass of JPanel, lets call it CustomPanel.
[quoted text clipped - 12 lines]
>
> Try a FlowLayout with a vertical direction.

Can you write me the code? Cause I cannot find where to change the
direction. The is no .setOrientation on either FlowLayout nor JPanel.
I am using java 1.6 if this helps.
Andrew Thompson - 01 Aug 2007 06:51 GMT
...
>Can you write me the code?

(shrugs) He* probably can.  How much were you offering?

* I could not understand what you posted, but Joshua
seemed to.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

pek - 01 Aug 2007 22:08 GMT
> ..
>
[quoted text clipped - 9 lines]
>
> Message posted viahttp://www.javakb.com

I looked for what he said and it seemed that it doesn't exist. I
wouldn't asked him to write anything if I didn't search first. After
all, I bet it's probably 3 lines of code that he knows and doesn't
need to search since he is so sure what I should do...
Ian Wilson - 02 Aug 2007 10:16 GMT
>>> Can you write me the code?
>>
[quoted text clipped - 6 lines]
> all, I bet it's probably 3 lines of code that he knows and doesn't
> need to search since he is so sure what I should do...

I'd create a small simple example

http://mindprod.com/jgloss/sscce.html
http://www.physci.org/codes/sscce.html

and post it here.
Andrew Thompson - 02 Aug 2007 14:51 GMT
...
>I looked for what he said and it seemed that it doesn't exist.

My bad.  After not understanding the description, I failed
to carefullly read the reply, either.

Perhaps Joshua meant a BoxLayout with a Y_AXIS constraint.
<http://java.sun.com/javase/6/docs/api/javax/swing/BoxLayout.html#Y_AXIS>

But then, see 'still do not understand the question' and
that leads me to suggest that Roedy's post might contain
the path to the solution for this challenge.  ;-)

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.