| Author |
Adding Buttons to JFrame title bar
|
Tony Anecito
Greenhorn
Joined: Feb 19, 2003
Posts: 5
|
|
Hi All, Has anyone been able to add a button to the title bar of a JFrame or JInternalFrame instance?
|
 |
Chris Shepherd
Ranch Hand
Joined: Jun 27, 2000
Posts: 286
|
|
|
might be possible, but you might be getting into the L&F range of things or possibly having to deal with the OS in the case of JFrame. I wouldn't rule it out, but you'd have to really poke around the JFrame docs to see if you could find/get any handles on that title bar. Maybe someone else knows for sure.
|
 |
Ashish Mahajan
Ranch Hand
Joined: Feb 19, 2003
Posts: 77
|
|
Hi, About adding button to the frame's title bar. :- JFrame uses system's title bar. In 1.4 Sun has added method "setUndecorated" to parent Frame which will remove the title bar of the frame and hence programmer can add a custom title bar to the north. I don't know how to do this in 1.3 About InternalFrame :- You can get internal frame's UI by getUI() which returns abstract InternalFrameUI which u can safely type cast to BasicInternalFrameUI (i hope it is safe but u should check for instanceof also) BasicInternalFrameUI has public method "setNorthPane(JComponent)" To create custom title pane u can subclass BasicInternalFrameTitlePane in plaf's basic package and have a look at "addSubComponents()" method Subclassing specific PLAF classes like MetalInternalFrameTitlePane would be better. By detecting LAF u can set the correct version of title pane. Otherwise u will have to do all the paint routine just to add a single custom button. But the best solution in such plaf related issues which i'll suggest is to be a client instead of subclassing. Well almost everything is Container so snoop around. After getting NorthPane from BasicInternalFrameTitlePane add ur custom button anywhere u want. Hope this helps
|
The best teams have no specialists, only general contributors with special skills
|
 |
 |
|
|
subject: Adding Buttons to JFrame title bar
|
|
|