This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Ok let me first state that I can make buttons with pictures in them..The button that i make usually is rectangular or square and within it contains the picture. My question is the following .. thanks in advance : I want to make a button that takes the shape of my gif picture. For example if my picture is the Nike logo i want my button to be shaped like the Nike logo. I do not want my button to be rectangular and contain the nike logo.. The button itself must be shaped exactly like the Nike logo. Example : the following line of code will NOT work : button= new JButton("", new ImageIcon("nike.gif")); because this just creates a buttons enclosing the nike picture.. and the button is still rectangular. I want to make it look like the nike pictue. And I also want to position this button at (50, 60) Thanks again
This question should really go in the SWING/JFC Forum, but until someone moves it, I will start to answer your question. I'm sure that if you override the paint method by extending JButton/Button you could change the shape of your Button. However, there is no way to make a Button just "take the shape of" your Gif Image. So here is what I would suggest.... First, try and make the Button as small as you can while still fitting the GIF image on it. Then, Button.setBorderPainted(false). That will remove the raised border from the button, so now it will appear that you just have a GIF image on the screen. Next, it would be a good idea to create two GIF images of your NIKE logo. Possibly make one look raised above the other. Then you can set either a pressedIcon and/or a mouseoever Icon that changes the NIKE logo to make it appear that it is actually the Button. These methods are fairly simple and really look nice if you take some time with your GIF Images. Hope that helps. ------------------ Happy Coding, Gregg Bolinger