Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Need to know when the checkbox is clicked
Need to know when the checkbox is clicked [message #452548] Tue, 22 March 2005 05:09 Go to next message
Eclipse UserFriend
Originally posted by: sl.x.com

Hi,

I have created a table with 3 columns, the first column contains only
checkbox. I need to obtain the notification message in a listerner when
any of the checkboxes in any row is clicked, so I can update some
information in my dialog box. Can someone please give me some help on
this? Also, I created the table with the following code snippet, it
magically place the checkboxes in first column and that is exactly what I
want, but I don't understand it, I never specify which column to place the
checkbox. Why is that?

public void createTableAlgorithmDescripion() {
_table = new Table(_parent, SWT.FULL_SELECTION | SWT.CHECK |
SWT.BORDER);
TableColumn tableCol1CheckBox = new TableColumn(_table,
SWT.CENTER);
TableColumn tableCol2Algorithm = new TableColumn(_table, SWT.NONE);
TableColumn tableCol3Description = new TableColumn(_table,
SWT.NONE);
_table.pack();

int nTableWidth = _table.getSize().x; // = 85
int nCheckBoxColWidth = 40;
int nAlgorithmColWidth = 120;
int nDescriptionColWidth = 335;
tableCol2Algorithm.setText("Algorithm");
tableCol3Description.setText("Description");
_table.setHeaderVisible(true);
_table.setLinesVisible(true);

/////////////////////////////////////////////////
createTableRow("Row1", "Row1 Description");
createTableRow("Row2", "Row2 Description");
createTableRow("Row3", "Row3 Description");
createTableRow("Row4", "Row4 Description");
}

private TableItem createTableRow(String sAlgorithm, String
sDescription) {
TableItem tableItem = new TableItem (_table, SWT.NULL);
tableItem.setChecked(true);
tableItem.setText (0, "");
tableItem.setText (1, sAlgorithm);
tableItem.setText (2, sDescription);
return tableItem;
}

Thanks
sl
Re: Need to know when the checkbox is clicked [message #452563 is a reply to message #452548] Tue, 22 March 2005 13:30 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
-> checkboxes are always in column 0
-> to detect a CHECK event do something like the following:

table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.detail != SWT.CHECK) return;
System.out.println("item checked: " + e.item);
}
});

Grant

"SL" <sl@x.com> wrote in message
news:cf354aa6476bc191d5c16555233a39de$1@www.eclipse.org...
> Hi,
>
> I have created a table with 3 columns, the first column contains only
> checkbox. I need to obtain the notification message in a listerner when
> any of the checkboxes in any row is clicked, so I can update some
> information in my dialog box. Can someone please give me some help on
> this? Also, I created the table with the following code snippet, it
> magically place the checkboxes in first column and that is exactly what I
> want, but I don't understand it, I never specify which column to place the
> checkbox. Why is that?
>
> public void createTableAlgorithmDescripion() {
> _table = new Table(_parent, SWT.FULL_SELECTION | SWT.CHECK |
> SWT.BORDER);
> TableColumn tableCol1CheckBox = new TableColumn(_table,
> SWT.CENTER);
> TableColumn tableCol2Algorithm = new TableColumn(_table,
SWT.NONE);
> TableColumn tableCol3Description = new TableColumn(_table,
> SWT.NONE);
> _table.pack();
>
> int nTableWidth = _table.getSize().x; // = 85
> int nCheckBoxColWidth = 40;
> int nAlgorithmColWidth = 120;
> int nDescriptionColWidth = 335;
> tableCol2Algorithm.setText("Algorithm");
> tableCol3Description.setText("Description");
> _table.setHeaderVisible(true);
> _table.setLinesVisible(true);
>
> /////////////////////////////////////////////////
> createTableRow("Row1", "Row1 Description");
> createTableRow("Row2", "Row2 Description");
> createTableRow("Row3", "Row3 Description");
> createTableRow("Row4", "Row4 Description");
> }
>
> private TableItem createTableRow(String sAlgorithm, String
> sDescription) {
> TableItem tableItem = new TableItem (_table, SWT.NULL);
> tableItem.setChecked(true);
> tableItem.setText (0, "");
> tableItem.setText (1, sAlgorithm);
> tableItem.setText (2, sDescription);
> return tableItem;
> }
>
> Thanks
> sl
>
Previous Topic:Width of a String
Next Topic:Question about Customizing Combox
Goto Forum:
  


Current Time: Thu Apr 25 10:22:48 GMT 2024

Powered by FUDForum. Page generated in 0.03761 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top