Results 1 to 1 of 1
-
How to print selected items in a SWT table
Java Code:import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; public class Snippet64 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); for (int i = 0; i < 16; i++) { TableItem item = new TableItem(table, 0); item.setText("Item " + i); } table.setBounds(0, 0, 100, 100); table.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { String string = ""; TableItem[] selection = table.getSelection(); for (int i = 0; i < selection.length; i++) string += selection[i] + " "; System.out.println("Selection={" + string + "}"); } }); table.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { String string = ""; TableItem[] selection = table.getSelection(); for (int i = 0; i < selection.length; i++) string += selection[i] + " "; System.out.println("DefaultSelection={" + string + "}"); } }); 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 remove selected items in a SWT table
By Java Tip in forum SWTReplies: 0Last Post: 07-11-2008, 04:29 PM -
How to print selected items in a SWT tree
By Java Tip in forum SWTReplies: 0Last Post: 07-07-2008, 04:55 PM -
Print the text file and print preview them
By Java Tip in forum java.awtReplies: 0Last Post: 06-22-2008, 11:04 PM -
merging selected table cells using javascript
By Renjini in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 06-17-2008, 01:04 AM -
Using Enumeration to get items out of the session
By Java Tip in forum Java TipReplies: 0Last Post: 01-04-2008, 09:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks