This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JLabel , image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JLabel , image" Watch "JLabel , image" New topic

JLabel , image

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I have a picture, then I slice into four small pictures, save them into four image file. then I put each image into a JLabel, the four JLabel with image put into JPanel and show up.

But, the result is, the GUI is not exactly as the picture. I don't know why ? My goal is , to get action listener on each image area.

Pat Hays
Ranch Hand

Joined: Aug 20, 2004
Posts: 138
It seems your code is generated by JFrameBuilder.
Try this way, using multiple Panel and BoxLayout instead.

Download Java GUI Builder, <a href="" target="_blank" rel="nofollow"></a>
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Your solution works. But I don't know why we need so many panels. Or we just use NULLLayout.

I am trying the JFramBuilder from I like its light weight, esay-use. I hope it has more swing component supports and nicer event handling. All in all, it is a good product.

I agree. Here's the link:
subject: JLabel , image
Similar Threads
SwingSet2 popup menu items are wrong when Look & Feel is changed
where r menuitems of popupmenu are defined when InternalFrames are minimized.
trouble with layouts
Moving a picture down a bit
problem with actionevent