File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Add a component on the Border of JPanel? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Add a component on the Border of JPanel?" Watch "Add a component on the Border of JPanel?" New topic
Author

Add a component on the Border of JPanel?

Tran Tuan Hung
Ranch Hand

Joined: Apr 08, 2007
Posts: 59
I want to add a component (a RadioButton...) on TitleBorder of JPanel.
So i don't know how to do it.
Plesase help me to do it.
Thanks a lot.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
A border is just that - a border. It shouldn't include other components (and it's not possible to do that with the borders that are part of Swing).

You could write your own border class that extends AbstractBorder, and in its paintBorder method you should be able to put any components you like.
Tran Tuan Hung
Ranch Hand

Joined: Apr 08, 2007
Posts: 59
thanks you very much Ulf Dittmer.
But i didn't know how to use paintBorder to add a component on it.
Can you give me a small example to do it and i am sorry for my stupid.
although i have searched on google, but it not help me.
Thanks very much
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
I have no idea how to go about it; as I said, I think it's not a good idea.

The fact that you didn't find anyone else doing it, either, should tell you something. There are most likely better ways to achieve what you're trying to do, possibly involving the use of layouts.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Originally posted by Tran Tuan Hung:
I want to add a component (a RadioButton...) on TitleBorder of JPanel.


This is how you can do it.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Tran Tuan Hung
Ranch Hand

Joined: Apr 08, 2007
Posts: 59
thanks Ulf Dittmer and Maneesh Godbole very much.
I am a noob, so that's hard with me.
One again, thanks very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Add a component on the Border of JPanel?