您的位置:首页 >> 编程开发 >> Java >> Java基础 >> Eclipse >> 正文
RSS
 

[求助]关于eclipse下开发串口操作插件的问题

http://www.rdxx.com 05年03月07日 12:12 Blog 我要投稿

关键词: 问题 , 串口 , 插件 , Eclipse , 开发 , 操作 , IP

请教一下,我用eclipse开发一个可以读取串口信息的插件,把它单独作为应用程序可以正常运行.但以插件形式运行时点击按钮就会出现异常.不知道是什么问题?

插件窗口程序:

package com.plugin.Hello;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import com.leon.serial.*;

/**
 * This class demonstrates JFace's ErrorDialog class
 */
public class DialogSample extends ApplicationWindow {
  /**
   * ShowError constructor
   */
  public DialogSample() {
    super(null);
  }
  /**
   * Runs the application
   */
  public void run() {
    // Don't return from open() until window closes
    setBlockOnOpen(true);

    // Open the main window
    open();

    // Dispose the display
    Display.getCurrent().dispose();
  }

  /**
   * Configures the shell
   *
   * @param shell the shell
   */
  protected void configureShell(Shell shell) {
    super.configureShell(shell);

    // Set the title bar text and the size
    shell.setText("read com");
    shell.setSize(400, 400);
  }

  /**
   * Creates the main window's contents
   *
   * @param parent the main window
   * @return Control
   */
  protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    // Create a big text box to accept error text
    final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    text.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Create the button to launch the error dialog
    Button show = new Button(composite, SWT.PUSH);
    show.setText("open serial port");
    show.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SerialBean SB = new SerialBean(2);
        String Msg = "";
        SB.Initialize();
    
       Msg = SB.ReadPort(10);
       SB.ClosePort();
        text.setText(Msg);
      }
    });

    return composite;
  }
  /**
   * The application entry point
   *
   * @param args the command line arguments
   */
/*  public static void main(String[] args) {

9 7 3 1 2 4 8 :

 
 
标签: 问题 , 串口 , 插件 , Eclipse , 开发 , 操作 , IP 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站