Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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 !!!
 
rubbery bacon. rubbery tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic