GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Checkbox using Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Checkbox using Swing" Watch "Checkbox using Swing" New topic
Author

Checkbox using Swing

sahitya
Greenhorn

Joined: May 01, 2008
Posts: 14
Hi

I have few queries regarding Check Box.

1. How to make a checkbox non editable?
2. How to attach an image to the checkbox?

Please help.
ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
see checkBox constructors
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Originally posted by sahitya sahitya:

1. How to make a checkbox non editable?
2. How to attach an image to the checkbox?




Check this out.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
setEnabled(false)

JCheckBox(Icon icon);
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

setIcon(Icon) should also work.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4575
    
    5

Originally posted by Rob Prime:
setIcon(Icon) should also work.


Actually it doesn't, inasmuch as the icon will replace the default icon, which is the square with the check.

This is a partially implemented UI delegate which paints a custom icon in addition to the default one, in the text area of the JCheckBox.

A fuller implementation would also need to override setPreferredSize and get/set Size, Maximum/Minimum Size .. (maybe get/setBounds, too.. haven't really thought about it).


luck, db
There are no new questions, but there may be new answers.
 
 
subject: Checkbox using Swing