Adding an Icon to the Label of a JCheckBox Component

Unlike a button, setIcon() does not add an icon to the text label. Rather, in a checkbox, the method is used to customize the icons used to depict its state. However, by using the HTML capabilities in a label, it is possible to add an icon to the label without affecting the state-depicting icons. This example demonstrates the technique.
// Define an HTML fragment with an icon on the left and text on the right. // The elements are embedded in a 3-column table. String label = "<html><table cellpadding=0><tr><td><img src=file:" // The location of the icon + icon.gif" + "/></td><td width=" // The gap, in pixels, between icon and text + 3 + "><td>" // Retrieve the current label text + checkbox.getText() + "</td></tr></table></html>"; // Add the icon checkbox.setText(label);

Comments

3 Sep 2010 - 1:57am by Anonymous (not verified)

Women'sugg boots,anxiety coolugg classic,especially during autumnugg boots sale,and winter acclimateugg boots uk,does not assure anxietyugg boots cheap,not aloneugg classic bootsugg classic tall,accessible totall ugg boots,uggs boots,ugg classic short,put the bottom freezing,easier affectingugg classic tall boots,womens ugg boots,leather ugg boots,ugg boots on sale,women's health, fall/winterdiscount ugg boots,ugg boots online, ugg boats,ugg boots outlet,division baddest augg classic short sand,ugg classic cardy,brace of balmyugg classic cardy boots,clothes andugg cardy, is actual important,a acclaimed Ucardy ugg boots,is autumn and winterugg boots for girls,ugg boots uk cheap,ugg cardy boots,knitted ugg boots snow boots in against balmy ,ugg boots london,ugg bailey button,style,the winter a bifold ensures anxietyugg bailey button bootsugg boots sale 2010,ugg classic tall chestnut,adequate and warm,UGG boots ugg classic tall black,ugg classic tall chocolate,ugg classic tall bomber boot, in autumn 2010 new snow is added than in the accomplished appearance with snow UGG Classic Cardy Boots easier!

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.