This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 120
see checkBox constructors
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

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: 120
setEnabled(false)

JCheckBox(Icon icon);
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

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: 4522
    
    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
 
Similar Threads
Tooltips lost when saving object
Dynamic checkbox JTree
check box
how to enable a checkbox through javascript
How to insert selectd checkbox record from jsp in table?