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 / GUI / January 2005

Tip: Looking for answers? Try searching our database.

Custom swing component and layoutmanagers

Thread view: 
Glenn Ivar Klausen - 12 Jan 2005 09:10 GMT
I've implemented a custom swing component. It extends the JComponent
class and implement paintComponent.

If I add this comonent to a panel with a BorderLayout layoutmanager, it
is show. If I use the default layoutmanager for JPanels (flowlayout),
the panel is paintet over my component. And also, if I specify
BorderLayout.NORTH when adding my componenet to the JPanel, the
component is also overpainted.

The reason I know its overpainted is because I have a System.out.println
statement int he paintComponent function, and I can see the print out
when its repaintet.

So the question is, how do I implement support for posisioning by
layoutmanagers in my component.

Glenn
Andrew Thompson - 12 Jan 2005 09:43 GMT
> I've implemented a custom swing component. It extends the JComponent
> class and implement paintComponent.
>
> If I add this comonent to a panel with a BorderLayout layoutmanager, it
> is show. If I use the default layoutmanager for JPanels (flowlayout),
> the panel is paintet over my component.

It sounds more like your component is assigned no space.

What do you return for
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#getPreferredSize()>
&
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#getMinimumSize()>
?

> So the question is, how do I implement support for posisioning by
> layoutmanagers in my component.

Generally, return reasonable values for the above and allow
the layout manager to do its job.

Failing that, post an SSCCE.
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



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



©2008 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.