• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

custom shaped gui components?

 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to create custom shaped gui components . . . please specify some clue . . .
 
Rob Camick
Ranch Hand
Posts: 2565
9
  • Mark post as helpful
  • send pies
  • 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
  • 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 . . .?
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic