Results 1 to 1 of 1
-
Color cells and rows in SWT table
Java Code:import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; public class Snippet129 { public static void main(String[] args) { Display display = new Display(); Color red = display.getSystemColor(SWT.COLOR_RED); Color blue = display.getSystemColor(SWT.COLOR_BLUE); Color white = display.getSystemColor(SWT.COLOR_WHITE); Color gray = display.getSystemColor(SWT.COLOR_GRAY); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER); table.setBackground(gray); TableColumn column1 = new TableColumn(table, SWT.NONE); TableColumn column2 = new TableColumn(table, SWT.NONE); TableColumn column3 = new TableColumn(table, SWT.NONE); TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] { "entire", "row", "red foreground" }); item.setForeground(red); item = new TableItem(table, SWT.NONE); item.setText(new String[] { "entire", "row", "red background" }); item.setBackground(red); item = new TableItem(table, SWT.NONE); item.setText(new String[] { "entire", "row", "white fore/red back" }); item.setForeground(white); item.setBackground(red); item = new TableItem(table, SWT.NONE); item.setText(new String[] { "normal", "blue foreground", "red foreground" }); item.setForeground(1, blue); item.setForeground(2, red); item = new TableItem(table, SWT.NONE); item.setText(new String[] { "normal", "blue background", "red background" }); item.setBackground(1, blue); item.setBackground(2, red); item = new TableItem(table, SWT.NONE); item.setText(new String[] { "white fore/blue back", "normal", "white fore/red back" }); item.setForeground(0, white); item.setBackground(0, blue); item.setForeground(2, white); item.setBackground(2, red); column1.pack(); column2.pack(); column3.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
How to navigate a SWT table cells with arrow keys
By Java Tip in forum SWTReplies: 0Last Post: 07-11-2008, 03:07 PM -
merging selected table cells using javascript
By Renjini in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 06-17-2008, 01:04 AM -
Deleting All rows in the JTable
By surot in forum New To JavaReplies: 1Last Post: 04-16-2008, 10:44 AM -
Fetching rows from DB
By Java Tip in forum Java TipReplies: 0Last Post: 02-06-2008, 09:23 AM -
no of fonts and cells exceeding error in excel sheet.
By iimasd in forum AWT / SwingReplies: 0Last Post: 11-06-2007, 06:58 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks