public class GridExample3 {
public static void main(String... args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Grid grid = new Grid(shell, SWT.BORDER |
SWT.V_SCROLL | SWT.H_SCROLL);
grid.setHeaderVisible(true);
Car car1 = new Car(133, "2007","Chevy",
"Cobalt",Car.CarType.COUPE, 4321, "Yellow", true);
|-------10--------20--------30--------40--------50--------60--------70--------80--------9|
|-------- XML error: The previous line is longer than the max of 90 characters ---------|
Car car2 = new Car(134, "2007","Chevy",
"Cobalt",Car.CarType.COUPE, 4321, "Yellow", true);
|-------10--------20--------30--------40--------50--------60--------70--------80--------9|
|-------- XML error: The previous line is longer than the max of 90 characters ---------|
Car car3 = new Car(135, "2006","Ford",
"Focus",Car.CarType.COUPE, 15343, "Red", true);
|-------10--------20--------30--------40--------50--------60--------70--------80--------9|
|-------- XML error: The previous line is longer than the max of 90 characters ---------|
Car car4 = new Car(136, "2006","Chrysler",
"Sebring",Car.CarType.SEDAN, 12932, "Black", false);
|-------10--------20--------30--------40--------50--------60--------70--------80--------9|
|-------- XML error: The previous line is longer than the max of 90 characters ---------|
Car car5 = new Car(137, "2002","Ford",
"Mustang",Car.CarType.COUPE,4342, "Red", true);
|-------10--------20--------30--------40--------50--------60--------70--------80--------9|
|-------- XML error: The previous line is longer than the max of 90 characters ---------|
GridColumn rentalTypeColumn = new GridColumn(grid, SWT.NONE);
rentalTypeColumn.setText("Rental Grade");
rentalTypeColumn.setWidth(100);
rentalTypeColumn.setTree(true);
GridColumn idColumn = new GridColumn(grid, SWT.NONE);
idColumn.setText("Car Number");
idColumn.setWidth(100);
GridColumn yearColumn = new GridColumn(grid, SWT.NONE);
yearColumn.setText("Year");
yearColumn.setWidth(50);
GridColumn makeColumn = new GridColumn(grid, SWT.NONE);
makeColumn.setText("Make");
makeColumn.setWidth(100);
GridColumn modelColumn = new GridColumn(grid, SWT.NONE);
modelColumn.setText("Model");
modelColumn.setWidth(100);
GridColumn typeColumn = new GridColumn(grid, SWT.NONE);
typeColumn.setText("Type");
typeColumn.setWidth(100);
GridColumn availableColumn = new GridColumn(grid,
SWT.CHECK | SWT.CENTER);
availableColumn.setText("Available");
availableColumn.setWidth(75);
GridItem compactItem = new GridItem(grid, SWT.CENTER);
compactItem.setText(0, "Compact");
compactItem.setFont(new Font(null,
"Arial", 18, SWT.BOLD | SWT.ITALIC));
compactItem.setColumnSpan(0, 6);
compactItem.setBackground(0, new Color(null, 0,255,0));
GridItem item1 = new GridItem(compactItem, SWT.NONE);
item1.setText(1, String.valueOf(car1.getCarNumber()));
item1.setText(2,car1.getYear());
item1.setText(3, car1.getMake());
item1.setText(4, car1.getModel());
item1.setText(5, car1.getCarType().toString());
item1.setChecked(6, car1.isAvailable());
GridItem item2 = new GridItem(compactItem, SWT.NONE);
item2.setText(1, String.valueOf(car2.getCarNumber()));
item2.setText(2,car2.getYear());
item2.setText(3, car2.getMake());
item2.setText(4, car2.getModel());
item2.setText(5, car2.getCarType().toString());
item2.setChecked(6, car2.isAvailable());
GridItem item3 = new GridItem(compactItem, SWT.NONE);
item3.setText(1, String.valueOf(car3.getCarNumber()));
item3.setText(2, car3.getYear());
item3.setText(3, car3.getMake());
item3.setText(4, car3.getModel());
item3.setText(5, car3.getCarType().toString());
item3.setChecked(6, car3.isAvailable());
GridItem midSizedItem = new GridItem(grid, SWT.NONE);
midSizedItem.setText(0, "Mid-Sized");
midSizedItem.setFont(new Font(null,
"Arial", 18, SWT.BOLD | SWT.ITALIC));
midSizedItem.setColumnSpan(0,6);
midSizedItem.setBackground(0, new Color(null, 0, 255, 255));
GridItem item4 = new GridItem(midSizedItem, SWT.NONE);
item4.setText(1, String.valueOf(car4.getCarNumber()));
item4.setText(2,car4.getYear());
item4.setText(3, car4.getMake());
item4.setText(4, car4.getModel());
item4.setText(5, car4.getCarType().toString());
item4.setChecked(6, car4.isAvailable());
GridItem item5 = new GridItem(midSizedItem, SWT.NONE);
item5.setText(1, String.valueOf(car5.getCarNumber()));
item5.setText(2,car5.getYear());
item5.setText(3, car5.getMake());
item5.setText(4, car5.getModel());
item5.setText(5, car5.getCarType().toString());
item5.setChecked(6, car5.isAvailable());
shell.setSize(700, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
} |