• 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

custom shaped gui components?

 
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to create custom shaped gui components . . . please specify some clue . . .
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Old example to get you started:

 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. . .

So, That means, if we want a customized component ,then we have to extend that basic API component and override related methods , to get that component as required . . . am i correct . . .?
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i actually am looking for ways to do that. because i want to mimick the buttons of firefox 3's back and next buttons (big circle left, weird shape right)

im wondering if there is a way to have a shape object created based on the image of an imageicon, then that would be quicker. but is that possible?

while the left button of firefox can be solved using a rounded button, the right button is the tricky part since it is a different shape.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The quick&dirty way:
- use BufferedImage instead of Image; this allows you to read the values for each pixel
- use java.awt.geom.Area as your Shape
- go through each pixel. If it's not transparent create a Rectangle for the pixel. Add the Rectangle to the Area
- when done the Area is a Shape with the contours of your image

I don't know if it's the most efficient way. Alternatives can be found here and here.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
great! thanks for this, will check this out and let you know

i will make sure the image is PNG so that transparency will be in effect
 
reply
    Bookmark Topic Watch Topic
  • New Topic