• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using image as button, remove border?  RSS feed

 
Alex Desjardins
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I tried a few things and I was unsuccessful at removing the border around my image button. It seemed simple enough when reading on StackOverflow but I'm still getting errors : s



Errors:

Multiple markers at this line
- Syntax error on token ";", @ expected
- Syntax error on token ".", @ expected after
this token

Multiple markers at this line
- Syntax error, insert "Identifier (" to complete
MethodHeaderName
- Syntax error, insert "SimpleName" to complete
QualifiedName
- Syntax error, insert ")" to complete MethodDeclaration

Still looking for an answer just thought I'd post here too, it has payed off so far ; ) Thank you!

Edit:

NVM, I'm using an applet it had to be in the initialize part of my program ; )

 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give your threads titles which tells us what they are about.
I don't believe the error causing those compiler messages is in the code you posted. I suspect it is somewhere earlier.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Desjardins wrote:


JLabel doesn't have a setContentAreaFilled(...) method.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will that error produce that compiler error?
 
Alex Desjardins
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright Campbell, I'll try to give better titles to my threads but "Using image as button, remove border?" to me seems short and pretty self-explanatory no? Maybe I should have added "JButton" and "how" to the title. At least I posted the thread in the right section this time ; )

"JLabel doesn't have a setContentAreaFilled(...) method."

OK, thank you Darryl.

I'm not getting errors anymore. The setBorder() method had to be added in the initialize part of my program. And no even with setContentAreaFilled() in the code it is not causing any errors.
 
Piet Souris
Rancher
Posts: 1946
66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Alex,

I'm not sure if you have solved your problem or not, but
if you have a label (or another component), then simply
'label.setBorder(someBorder/null) is all you need to set
or remove a border.

Greetz,
Piet
 
Alex Desjardins
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Piet, sorry it took so long for me to reply... Just moved into my new house and didn't have internet access plus super busy at work : s Yes, I got it working and this is the code I'm using:



I now have a working prototype of the War game (card game) and today I will start re-coding the final clean version of my project. Thank you for your help guys!
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that JButton also has a method that sets whether the border is painted.

Also, the ImageIcon constructor that takes a String parameter loads the image from a File. If you're planning to jar up your game for distribution, you might be better off using a URL instead. See Loading Images Using getResource for more.
 
Alex Desjardins
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice, thank you Darryl. The game is the final project of my first college Java course. I am not planning on distributing the game but I will definitely try with the URL instead of the string parameter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!