Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » HIDE_SELECTION in Table
HIDE_SELECTION in Table [message #458974] Wed, 27 July 2005 18:22
Udaya K. Tejwani is currently offline Udaya K. TejwaniFriend
Messages: 13
Registered: July 2009
Junior Member
When I select a row in Table 3 in shell 2 and then click on shell 1, the
selected row is not highlighted anymore even though I have not specified
the style as HIDE_SELECTION. The code is as follows:

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class TableExample
{
public static void main (String [] args)
{
final Display display = new Display();
final Shell shell1 = new Shell (display);
shell1.setText ("Shell 1: Table Example");
shell1.open();

Table table1 = new Table (shell1, SWT.SINGLE | SWT.BORDER);
table1.setLinesVisible (true);
table1.setHeaderVisible (true);
table1.setBounds (10, 10, 285, 85);

TableColumn firstname1 = new TableColumn (table1, SWT.LEFT);
firstname1.setText ("First Name");
firstname1.setWidth (70);

TableColumn lastname1 = new TableColumn (table1, SWT.LEFT);
lastname1.setText ("Last Name");
lastname1.setWidth (70);

TableColumn age1 = new TableColumn (table1, SWT.RIGHT);
age1.setText ("Age");
age1.setWidth (40);

TableColumn foodtype1 = new TableColumn (table1, SWT.LEFT);
foodtype1.setText ("Type of Food");
foodtype1.setWidth (100);

TableItem item1 = new TableItem (table1, SWT.NONE);
item1.setText (new String [] {"Udaya", "Tejwani", "25",
"Vegetarian"});

TableItem item2 = new TableItem (table1, SWT.NONE);
item2.setText (new String [] {"Parul", "Tejwani", "20",
"Vegetarian"});

TableItem item3 = new TableItem (table1, SWT.NONE);
item3.setText (new String [] {"Bobita", "Tejwani", "4",
"Non-Vegetarian"});

TableItem item4 = new TableItem (table1, SWT.NONE);
item4.setText (new String [] {"Gugu", "Tejwani", "1",
"Non-Vegetarian"});

Table table2 = new Table (shell1, SWT.MULTI | SWT.BORDER);
table2.setLinesVisible (true);
table2.setHeaderVisible (true);
table2.setBounds (10, 100, 285, 85);

TableColumn firstname2 = new TableColumn (table2, SWT.LEFT);
firstname2.setText ("First Name");
firstname2.setWidth (70);

TableColumn lastname2 = new TableColumn (table2, SWT.LEFT);
lastname2.setText ("Last Name");
lastname2.setWidth (70);

TableColumn age2 = new TableColumn (table2, SWT.RIGHT);
age2.setText ("Age");
age2.setWidth (40);

TableColumn foodtype2 = new TableColumn (table2, SWT.LEFT);
foodtype2.setText ("Type of Food");
foodtype2.setWidth (100);

TableItem item5 = new TableItem (table2, SWT.NONE);
item5.setText (new String [] {"Udaya", "Tejwani", "25",
"Vegetarian"});

TableItem item6 = new TableItem (table2, SWT.NONE);
item6.setText (new String [] {"Parul", "Tejwani", "20",
"Vegetarian"});

TableItem item7 = new TableItem (table2, SWT.NONE);
item7.setText (new String [] {"Bobita", "Tejwani", "4",
"Non-Vegetarian"});

TableItem item8 = new TableItem (table2, SWT.NONE);
item8.setText (new String [] {"Gugu", "Tejwani", "1",
"Non-Vegetarian"});

final Shell shell2 = new Shell (display);
shell2.setText ("Shell 2: Table Example");
shell2.open();

Table table3 = new Table (shell2, SWT.FULL_SELECTION | SWT.BORDER);
table3.setLinesVisible (true);
table3.setHeaderVisible (true);
table3.setBounds (10, 10, 285, 85);

TableColumn firstname3 = new TableColumn (table3, SWT.LEFT);
firstname3.setText ("First Name");
firstname3.setWidth (70);

TableColumn lastname3 = new TableColumn (table3, SWT.LEFT);
lastname3.setText ("Last Name");
lastname3.setWidth (70);

TableColumn age3 = new TableColumn (table3, SWT.RIGHT);
age3.setText ("Age");
age3.setWidth (40);

TableColumn foodtype3 = new TableColumn (table3, SWT.LEFT);
foodtype3.setText ("Type of Food");
foodtype3.setWidth (100);

TableItem item9 = new TableItem (table3, SWT.NONE);
item9.setText (new String [] {"Udaya", "Tejwani", "25",
"Vegetarian"});

TableItem item10 = new TableItem (table3, SWT.NONE);
item10.setText (new String [] {"Parul", "Tejwani", "20",
"Vegetarian"});

TableItem item11= new TableItem (table3, SWT.NONE);
item11.setText (new String [] {"Bobita", "Tejwani", "4",
"Non-Vegetarian"});

TableItem item12 = new TableItem (table3, SWT.NONE);
item12.setText (new String [] {"Gugu", "Tejwani", "1",
"Non-Vegetarian"});

Table table4 = new Table (shell2, SWT.FULL_SELECTION |
SWT.HIDE_SELECTION | SWT.BORDER);
table4.setLinesVisible (true);
table4.setHeaderVisible (true);
table4.setBounds (10, 100, 285, 85);

TableColumn firstname4 = new TableColumn (table4, SWT.LEFT);
firstname4.setText ("First Name");
firstname4.setWidth (70);

TableColumn lastname4 = new TableColumn (table4, SWT.LEFT);
lastname4.setText ("Last Name");
lastname4.setWidth (70);

TableColumn age4 = new TableColumn (table4, SWT.RIGHT);
age4.setText ("Age");
age4.setWidth (40);

TableColumn foodtype4 = new TableColumn (table4, SWT.LEFT);
foodtype4.setText ("Type of Food");
foodtype4.setWidth (100);

TableItem item13 = new TableItem (table4, SWT.NONE);
item13.setText (new String [] {"Udaya", "Tejwani", "25",
"Vegetarian"});

TableItem item14 = new TableItem (table4, SWT.NONE);
item14.setText (new String [] {"Parul", "Tejwani", "20",
"Vegetarian"});

TableItem item15= new TableItem (table4, SWT.NONE);
item15.setText (new String [] {"Bobita", "Tejwani", "4",
"Non-Vegetarian"});

TableItem item16 = new TableItem (table4, SWT.NONE);
item16.setText (new String [] {"Gugu", "Tejwani", "1",
"Non-Vegetarian"});

while (!shell1.isDisposed())
{
if (!display.readAndDispatch ())
display.sleep();
}
display.dispose();

while (!shell2.isDisposed())
{
if (!display.readAndDispatch ())
display.sleep();
}
display.dispose();

}
}
Previous Topic:Importing images from MS Access
Next Topic:gc.setClipping
Goto Forum:
  


Current Time: Thu Oct 29 14:46:33 GMT 2020

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

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

Back to the top