File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JLabel appears as a JButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JLabel appears as a JButton" Watch "JLabel appears as a JButton" New topic
Author

JLabel appears as a JButton

Gregory Ball
Greenhorn

Joined: Apr 23, 2009
Posts: 3
What ever I try the Jlabel want appeear. Instead it comes up as one of the JButtons.
The code is a little messy, sos.
Any Help would be great
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

Please Use Code Tags.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
I think that most of your problems will be solved if you avoid using the "null" layout and learn to use the layout managers.

for instance:
Gregory Ball
Greenhorn

Joined: Apr 23, 2009
Posts: 3
Sorry for not having my code in quotes. first time on this website.

Cheers for the reply.

I have used layout managers before and they have worked quite well, but time consuming.

I'm still wondering whats wrong with the code. Or does Java hate doing things without a layout scheme?
Should I just forget about it and go a head with what is suggested?

Cheers Greg
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Gregory Ball wrote:I have used layout managers before and they have worked quite well, but time consuming.

What's more time consuming, trying to set things using absolute positioning, getting it wrong, and having to re-work the code multiple times to get it right, or using nested layouts and just letting the layout managers do the hard work for you? For me the question is a no-brainer.

I'm still wondering whats wrong with the code. Or does Java hate doing things without a layout scheme?

Java neither hates nor loves, but only does what you tell it to do. Your positionings are incorrect. Simple as that.

Should I just forget about it and go a head with what is suggested?

Your call.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JLabel appears as a JButton
 
Similar Threads
Problem Updating a JButton
running a class a particular number of times
Center a JPanel in JScrollPane and add a JToolBar
TicTacToe - Computer's move
how to add background image to japplet