Results 1 to 14 of 14
- 05-16-2011, 06:38 PM #1
Member
- Join Date
- May 2011
- Posts
- 11
- Rep Power
- 0
Hide a button but keep the image?
Hi again... Yeah... I want to be able to do as the title says - or in other words, to use a icon as a button. Because I am making my own (Simple plain-text) Text editor, I want to use icons for the popular things (Bold, italics...) But I don't want the outline of the buttons (Eg I want it to look like a picture not a button with a picture on it...)
If anybody knows how, I searched on Google but I couldn't think of how to phrase it...
- 05-16-2011, 06:56 PM #2
Can't you just set the border of the JButton to whatever you want? Or override whichever paint method paints the border (I'm too lazy to look it up.. paintBorder?). Or call setBorderPainted(false).
All of these are in the JButton API.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 05-16-2011, 07:04 PM #3
Member
- Join Date
- May 2011
- Posts
- 11
- Rep Power
- 0
Setborderpainted(false) makes the border go away, but the button is still there, and I don't know what you mean by override whichever paint method paints the border...
:confused:
- 05-16-2011, 07:25 PM #4
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
And that is what your question asked for. If you can't see the Border, then it just looks like a picture.Setborderpainted(false) makes the border go away, but the button is still there,
Or you can always use a JLabel which doesn't have a Border by default
- 05-16-2011, 07:27 PM #5
Member
- Join Date
- May 2011
- Posts
- 11
- Rep Power
- 0
Yes, But what I Meant was to make the button disapear.
And can JLabels get user input (Clicking) Because I diddn't think so...
- 05-16-2011, 07:32 PM #6
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
If the button disappears, then the Icon disappears as well, so I don't understand what you are asking.
A button is easier to use than a label because you can use an ActionListener. With a JLabel you need to add you own custom MouseListener to handle mouse events.
- 05-16-2011, 07:34 PM #7
Are you trying to get the background color of the JButton (surrounding the image) to disappear as well?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 05-16-2011, 07:43 PM #8
Member
- Join Date
- May 2011
- Posts
- 11
- Rep Power
- 0
I couldn't think how to explain, so I made this image: Dropbox - Photos - Simplify your life
- 05-16-2011, 07:45 PM #9
Many firewalls, including the one I'm behind right now, block sites like that. You could provide an SSCCE that demonstrates the problem.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 05-16-2011, 07:48 PM #10
Member
- Join Date
- May 2011
- Posts
- 11
- Rep Power
- 0
Nah, No matter on second thoughts what I want to do seems rather pointless...
:)
- 05-16-2011, 08:11 PM #11
Read the API. The methods you want to use are inherited from AbstractButton. Look for methods like set...Painted(boolean)
db
- 05-31-2011, 09:15 PM #12
Member
- Join Date
- May 2011
- Posts
- 56
- Rep Power
- 0
Hey I think i have your answer, i faced same problem in my project.
What to do is to make a png icon with white or transparent background (if you have something about Corel and Adobe Illustrator), set the size of your button exactly or little less than your icon to make it fit in the button boundary than set the color of button and parent contaner same as your icon background..............
Much of your problem will be sort out......
- 06-02-2011, 01:36 PM #13
Member
- Join Date
- May 2011
- Posts
- 11
- Rep Power
- 0
Ah, Thank you, Just what I wanted!
- 06-05-2011, 05:05 PM #14
Member
- Join Date
- May 2011
- Posts
- 56
- Rep Power
- 0
Similar Threads
-
Make a button class that uses your button image.
By eLancaster in forum New To JavaReplies: 1Last Post: 04-26-2011, 11:32 AM -
button displays image
By hopelessnoob in forum AWT / SwingReplies: 2Last Post: 03-12-2011, 03:44 PM -
AWT button image
By timkd127 in forum AWT / SwingReplies: 2Last Post: 03-01-2010, 04:41 AM -
Set focus on image button in swt
By diva_garg in forum New To JavaReplies: 3Last Post: 08-18-2008, 12:27 PM -
Get Focus on Image button
By diva_garg in forum SWT / JFaceReplies: 0Last Post: 08-08-2008, 11:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks