Solved

JLable with Jcheckbox

Posted on 2002-05-18
2
258 Views
Last Modified: 2010-03-31
Hi,
   I am using
JLabel(String text, Icon icon, int horizontalAlignment)

to write code for a image browser.  Right now it displays thumb nail images with
file name on top.
I want to put a checkbox next to file name for user to
select or deselct the image. How can I extend the JLable
class so it not only take a icon, a text string, but
also a checkbox?

Thanks.
shane
0
Comment
Question by:xiaoxiangz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 7018645
 Why do you need to extend JLabel? Can you not just add a check box next to the JLabel and enable/disable the thumbnail? If checkbox is enabled then call the J:Label's constructor that does not require an Icon sa parameter, if it is not enabled called the one that does.

  Hope it helps.
0
 
LVL 3

Accepted Solution

by:
randyd earned 100 total points
ID: 7024058
You could create your own class based on JPanel.

Inside this panel, put your existing label and the new checkbox.

add an event handler to the checkbox, and make the right calls into the label when things are checked.

then plug in this panel wherever you are using your label today.

hth
randy
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question