Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计 » SWT  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 我的coolbar怎么会是这种效果呢?
levin





发贴: 43
积分: 0
于 2004-05-29 11:43 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的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);
  }
  
  
}

(缩略图,点击图片链接看原图)




致JAVA初学者+如何下手学JAVA

话题树型展开
人气 标题 作者 字数 发贴时间
6674 我的coolbar怎么会是这种效果呢? levin 4804 2004-05-29 11:43
5077 啊,图贴错了,重新来 levin 9 2004-05-29 11:45

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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