• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding Buttons to JFrame title bar

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Has anyone been able to add a button to the title bar of a JFrame or JInternalFrame instance?
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Our first order of business must be this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic