Java SWT Table Examples

一个SWT Table的例子。这个地址有很多table的例子。

http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/ColorcellsandrowsinSWTtable.htm

 

Color cells and rows in SWT table
Color cells and rows in SWT table



/*
  * Table example snippet: color cells and rows in table
  *
  * For a list of all SWT example snippets see
  * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
  */
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 () ;
   }
}

           
       
Related examples in the same category
1. How to order 1000 elements in a swt column table with O(n log(n)) complexity! using Comparator and Array.sort() implemented in a TableColumn Listener Factory How to order 1000 elements in a swt column table with O(n log(n)) complexity! using Comparator and Array.sort() implemented in a TableColumn Listener Factory
2. Print KTable (SWT Table)Example Print KTable (SWT Table)Example
3. The source of a custom table class for Java SWT applications The source of a custom table class for Java SWT applications
4. SWT Table Editor
5. Simple File Browser in SWT Table Simple File Browser in SWT Table
6. Bug Tracker JFace Bug Tracker JFace
7. Bug Tracker Bug Tracker
8. File Browser Demo File Browser Demo
9. TableEditor example TableEditor example
10. File Browser Sample File Browser Sample
11. File Browser JFace
12. Bug Report Bug Report
13. Displays ASCII Codes Displays ASCII Codes
14. Demonstrates the SWT.VIRTUAL style Demonstrates the SWT.VIRTUAL style
15. Displays a table Displays a table
16. A table of baseball players and allows sorting A table of baseball players and allows sorting
17. Demonstrates TableCursor Demonstrates TableCursor
18. Demonstrates TableTree Demonstrates TableTree
19. Demonstrates TableEditor Demonstrates TableEditor
20. Shows the extensions on the system and their associated programs Shows the extensions on the system and their associated programs
21. Table Example 3 Table Example 3
22. Table Example 2 Table Example 2
23. Table Example Table Example
24. Demonstrates TableViewers Demonstrates TableViewers
25. Demonstrates CheckboxTableViewer Demonstrates CheckboxTableViewer
26. Demonstrates CellEditors Demonstrates CellEditors
27. SWT Table Simple Demo SWT Table Simple Demo
28. Create fake tooltips for items in a SWT table Create fake tooltips for items in a SWT table
29. Place a progress bar in a SWT table Place a progress bar in a SWT table
30. edit a cell in a SWT table (in place, fancy) edit a cell in a SWT table (in place, fancy)
31. edit the text of a SWT table item (in place) edit the text of a SWT table item (in place)
32. navigate a SWT table cells with arrow keys navigate a SWT table cells with arrow keys
33. Update SWT table item text Update SWT table item text
34. Sort a SWT table by column Sort a SWT table by column
35. Select an index (select and scroll) in a SWT table Select an index (select and scroll) in a SWT table
36. Scroll a SWT table (set the top index) Scroll a SWT table (set the top index)
37. Resize columns as SWT table resizes Resize columns as SWT table resizes
38. Remove selected items in a SWT table Remove selected items in a SWT table
39. Print selected items in a SWT table Print selected items in a SWT table
40. Place arbitrary controls in a SWT table Place arbitrary controls in a SWT table
41. Reorder columns and reorder columns programmatically Reorder columns and reorder columns programmatically
42. Insert a SWT table column (at an index) Insert a SWT table column (at an index)
43. Insert a SWT table item (at an index) Insert a SWT table item (at an index)
44. Find a SWT table cell from mouse down (works for any table style) Find a SWT table cell from mouse down (works for any table style)
45. Find a table cell from mouse down (SWT.FULL_SELECTION) Find a table cell from mouse down (SWT.FULL_SELECTION)
46. Detect a selection or check event in a table (SWT.CHECK) Detect a selection or check event in a table (SWT.CHECK)
47. Create a SWT table with 1,000,000 items Create a SWT table with 1,000,000 items
48. Create a SWT table (columns, headers, lines) Create a SWT table (columns, headers, lines)
49. Create a SWT table (no columns, no headers) Create a SWT table (no columns, no headers)
50. Create a virtual SWT table and add 1000 entries to it every 500 ms Create a virtual SWT table and add 1000 entries to it every 500 ms
51. Dropped data type depends on target item in table Dropped data type depends on target item in table
52. Create a table (lazy) Create a table (lazy)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值