| Author |
custom shaped gui components?
|
Sanjeev Charla
Ranch Hand
Joined: Apr 02, 2009
Posts: 90
|
|
|
how to create custom shaped gui components . . . please specify some clue . . .
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1788
|
|
Old example to get you started:
|
 |
Sanjeev Charla
Ranch Hand
Joined: Apr 02, 2009
Posts: 90
|
|
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
Joined: Aug 18, 2009
Posts: 155
|
|
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.
|
Website/Java Games: http://www.chitgoks.com
Tech Blog: http://tech.chitgoks.com
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
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.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
mark goking
Ranch Hand
Joined: Aug 18, 2009
Posts: 155
|
|
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
|
 |
 |
|
|
subject: custom shaped gui components?
|
|
|