• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Using image as button, remove border?

 
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ; )

 
Marshal
Posts: 80639
472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alex Desjardins wrote:



JLabel doesn't have a setContentAreaFilled(...) method.
 
Campbell Ritchie
Marshal
Posts: 80639
472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 5616
214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic