简体   繁体   中英

Java Gui L&F Round Button

I am currently developing the front end of an app,using WindowsBuilder plugin on eclipse, in which i have a "toolbar" on the top of the frame with different butttons a user can interact with. I want the buttons to be circles, with a custom icon that i will add.When "mouse enters" i want the hovered over button to enlarge and when "mouse exits" i want the button to go back to normal. The problems I have encountered so far are the following:

  1. Cannot make circular button.
  2. How to enlarge/reduce them(apart from set.width() + something , setHeight() + somethingElse

I want something like this:

绘画功底欠佳。我很抱歉

I have already tried the jtattoo L&F for circle button but the 1.3 version throws error and the 1.6 does not throw one but does not change the button shape.

Note:The reason i ask these 2 questiong together is that they can be solved(i think) with a single L&F theme if someone has developed/knows one.

Some time ago I wrote an OvalButton class that can handle oval, circular and capsule-like shaped JButtons.

You can extend this class and override getBackgroundImage() method to return the image you want to set it as the background of the button. Then add listeners and text as usually. Only a click on the oval/circular area triggers the action.

When you get this ready I believe you should be able to import a new component.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM