Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-11-2008, 06:31 PM
Moderator
 
Join Date: Nov 2007
Posts: 1,659
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Color cells and rows in SWT table
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(); } }
__________________
Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums! (closes on July 27, 2008)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to navigate a SWT table cells with arrow keys Java Tip SWT 0 07-11-2008 05:07 PM
merging selected table cells using javascript Renjini JavaServer Pages (JSP) and JSTL 2 06-17-2008 03:04 AM
Deleting All rows in the JTable surot New To Java 1 04-16-2008 12:44 PM
Fetching rows from DB Java Tip Java Tips 0 02-06-2008 11:23 AM
no of fonts and cells exceeding error in excel sheet. iimasd AWT / Swing 0 11-06-2007 08:58 AM


All times are GMT +3. The time now is 03:31 AM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org