• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

SWT Tristate Checkbox

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to bring three state checkbox(Checked/UnChecked/Intermediate) in a tableviewer...can any help me how to do this.

I tried the http://www.eclipse.org/articles/Article-Table-viewer/table_viewer.html,
But my SWT package has the heriarchy ITableLabelProvider from IBaseLabelProvider. But the above article tells as

///////////////////////////////////////////////////
These methods are called by the TableViewer whenever a table element needs to be refreshed. Our ITableLabelProvider extends org.eclipse.jface.viewers.LabelProvider. This way, we benefit from the behavior defined in the superclass. Internally, our class manages an image registry (for the checkboxes) so we had to put in place the mechanics to load and manage instances of org.eclipse.jface.resource.ImageDescriptor and org.eclipse.jface.resource.ImageRegistry. The details of this can be assessed by looking at the source code for the class. In SWT, platform resources such as images and fonts must be disposed of when the application exits. However, an ImageRegistry owns all of the image objects registered with it and automatically disposes of them when the SWT Display is disposed so we do not need to explicitly do so.
///////////////////////////////////////////////////
But my package has the ITableLableProvider extends IBaseLabelProvider.

I am bit confused..Is it due to package version difference..Or what is the approach to be done in my current version SWT-3.1.2.

Thanks
Hariharan
 
Marshal
Posts: 78679
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Can you have a checkbox with three states? I can't get your URL to work; it give a 404 error when I try it.

I looked at java.awt.CheckBox and javax.swing.JCheckBox in the API specifications, and they seem to have two states only. What have I missed?

CR
 
Hariharan Sethuraman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The URL is "http://www.eclipse.org/articles/Article-Table-viewer/table_viewer.html"

You can bring 3rd state in Swing for JCheckBox using ButtonModel.

I continued trying my problem by writing an inner class extending LabelProvider and implementing ITableLabelProvider, and override the method getImage of LabelProvider. By returning 3 type of images according to state..Is there any other method as SWT calls the native methods,where the windows has tristate checkbox..

Thanks
S.Hariharan
 
catch it before it slithers away! Oh wait, it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic