Solved

JLable with Jcheckbox

Posted on 2002-05-18
2
250 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
Comment Utility
 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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

762 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

12 Experts available now in Live!

Get 1:1 Help Now