Solved

JLable with Jcheckbox

Posted on 2002-05-18
2
252 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Starting to learn JAVA, 7 59
Problem to start Neon 20 89
windows explorer path to command prompt 5 33
factorial example 4 35
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

861 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now