Results 1 to 1 of 1
-
How to create tool bar (wrap on resize)
Java Code:import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; 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.ToolBar; import org.eclipse.swt.widgets.ToolItem; public class Snippet49 { public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); final ToolBar toolBar = new ToolBar(shell, SWT.WRAP); for (int i = 0; i < 12; i++) { ToolItem item = new ToolItem(toolBar, SWT.PUSH); item.setText("Item " + i); } shell.addListener(SWT.Resize, new Listener() { public void handleEvent(Event e) { Rectangle rect = shell.getClientArea(); Point size = toolBar.computeSize(rect.width, SWT.DEFAULT); toolBar.setSize(size); } }); toolBar.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
-
What tool to create Install / Setup packages
By mwildam in forum New To JavaReplies: 12Last Post: 11-21-2007, 09:25 AM -
tool to create shape frame
By boy22 in forum AWT / SwingReplies: 1Last Post: 08-05-2007, 04:10 AM -
resize tabs in jtabbedpane
By osval in forum New To JavaReplies: 1Last Post: 08-02-2007, 03:02 AM -
Resize frame
By lenny in forum AWT / SwingReplies: 1Last Post: 07-29-2007, 11:18 PM -
Help with JTextArea, resize windows
By paul in forum AWT / SwingReplies: 1Last Post: 07-16-2007, 04:11 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks