File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checkbox using Swing

 
sahitya
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see checkBox constructors
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ramesh kancherla
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setEnabled(false)

JCheckBox(Icon icon);
 
Rob Spoor
Sheriff
Pie
Posts: 20380
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setIcon(Icon) should also work.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic