Topic: 我的coolbar怎么会是这种效果呢? |
Print this page |
1.我的coolbar怎么会是这种效果呢? | Copy to clipboard |
Posted by: levin Posted on: 2004-05-29 11:43 我的coolbar设计时候如图所示: 但在运行时候却看不到coolbaritem,请高手指点. 代码了贴出来. /* * Created on 2004-5-29 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package com.yt; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.CoolBar; import org.eclipse.swt.widgets.CoolItem; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; import swing2swt.layout.BorderLayout; import org.eclipse.swt.widgets.Group; import org.eclipse.jface.action.Action; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.graphics.*; /** * @author Administrator * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class AfterSellMainApp extends ApplicationWindow { private Action action_2; private Action action_1; private Action action; CoolBar coolBar; Display display = new Display(); public AfterSellMainApp() { super(null); createActions(); addToolBar(SWT.NONE); addMenuBar(); } protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NO_RADIO_GROUP); container.setBounds(0, 0, 0, 0); container.setLayout(new FormLayout()); { coolBar = new CoolBar(container, SWT.NONE); final FormData formData = new FormData(); formData.bottom = new FormAttachment(0, 30); formData.top = new FormAttachment(0, 0); formData.right = new FormAttachment(100, 0); formData.left = new FormAttachment(0, 0); coolBar.setLayoutData(formData); { final CoolItem coolItem = new CoolItem(coolBar, SWT.PUSH); coolItem.setText("New item"); coolItem.computeSize(100,20); { final ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT); coolItem.setControl(toolBar); { final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); toolItem.setText("New item"); } { final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); toolItem.setText("New item"); } } } { final CoolItem coolItem = new CoolItem(coolBar, SWT.PUSH); coolItem.setText("New item"); } { final CoolItem coolItem = new CoolItem(coolBar, SWT.PUSH); coolItem.setText("New item"); } } // return container; } private void createActions() { { action = new Action() { public void run() { } }; action.setText("Action"); } { action_1 = new Action() { public void run() { } }; action_1.setText("Action"); } { action_2 = new Action() { public void run() { } }; action_2.setText("Action"); } } protected MenuManager createMenuManager() { MenuManager result = new MenuManager("menu"); { final MenuManager menuManager = new MenuManager("File"); result.add(menuManager); { menuManager.add(action); } { menuManager.add(action_1); } { menuManager.add(action_2); } } return result; } protected ToolBarManager createToolBarManager(int arg) { ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.WRAP); //toolBarManager. //toolBarManager.createControl(this.coolBar); return toolBarManager; } public void run() { open(); Display display = Display.getCurrent(); Shell shell = getShell(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } public static void main(String args[]) { AfterSellMainApp window = new AfterSellMainApp(); window.run(); } protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("测试程序"); } protected void addMenuBar() { super.addMenuBar(); //Menu men = new Menu(this.getShell(),SWT.NONE); } } (缩略图,点击图片链接看原图) |
2.啊,图贴错了,重新来 [Re: levin] | Copy to clipboard |
Posted by: levin Posted on: 2004-05-29 11:45 图贴错了,重新发这 (缩略图,点击图片链接看原图) |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |