Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Using JToolBar

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guy's !!!
How can a JToolBar instance in appearance be made to look similar to "Windows" toolbar(one used in Internet Explorer,Windows Explorer,MS-Office).It appears flat on-sight but elevated on "MouseOver" and appears depressed on "Click".
Pls Suggest.
Thanks a lot.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if this would work (hasnt been tested) but you could use this initially:

You can get the button reference from the JToolBar (check the docs).
Then create a mouse listener for your button that changes the border on mouse enters/exits:

The above class is assuming that it is an inner class within your JButton class. You could do this in a few different ways, though.
Hope that helps.
- Daniel
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
The way I have done this is when I create the button, i set border painted to false like so:
mybutton.setBorderPainted(false);
Then, I use a mouseListener as Daniel suggests (I extend mouseListener on the encompassing JFrame or JToolBar class, and then define the methods mouseExited() mouseEntered().
Then, when the event source is mybutton, do this in mouseEntered()...
mybutton.setBorderPainted(true);
and this in mouseExited...
mybutton.setBorderPainted(false);

Seems to work ok when I have done this a couple of times in different apps. Haven't done the depressed look 'on click' because it doesn't seem worth the bother to me
cheers, Ben.
 
Savio Mascarenhas
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Daniel !!!
 
Savio Mascarenhas
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ben !!!
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic