【问题标题】:multiple Inheritance .. class need to extend abstractHandler as well as Applet多个继承..类需要扩展abstractHandler以及Applet
【发布时间】:2011-10-27 00:20:20
【问题描述】:

我正在尝试制作一个自动化向导,该向导将从系统中获取一些文件(通过命令处理程序)并制作其相关的小程序。

我将尝试解释我的情景。

我为通过“newModuleHandler.java”处理的新命令“newModule”制作了一个插件。所以 newModuleHandler 扩展了 AbstractHandler。

现在我想制作一个向导(小程序),它可以帮助我完成某些选择,以便完成“newModule”命令。所以 newModuleHandler 也扩展了 Applet。

我写了 newModuleHandler 类似的东西。

    package archetypedcomponent.commands;

    import org.eclipse.core.commands.AbstractHandler;
    import org.eclipse.core.commands.ExecutionEvent;
    import org.eclipse.core.commands.ExecutionException;
    import java.applet.*;// required when you create an applet 
    import java.awt.Graphics;


    public class newModuleHandler extends AbstractHandler {

    @Override
public boolean isEnabled() {
    // TODO Auto-generated method stub
    return true;
}

@Override
public boolean isHandled() {
    // TODO Auto-generated method stub
    return true;
}

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // TODO Auto-generated method stub

    return null;
}

public class HelloWorld extends Applet 
{
    // The method that will be automatically called  when the applet is started 
     public void init() 
     { 
         // It is required but does not need anything. 
         System.out.println("Applet initiated");
     } 


    // This method gets called when the applet is terminated 
    // That's when the user goes to another page or exits the browser. 
     public void stop() 
     { 
         //     no actions needed here now.
         System.out.println("Applet Stopped");
     } 


    // The standard method that you have to use to paint things on screen 
    // This overrides the empty Applet method, you can't called it "display" for example.

     public void paint(Graphics g) 
     { 
         //method to draw text on screen 
         // String first, then x and y coordinate. 
         System.out.println("Applet in paint");
          g.drawString("Hey hey hey",20,20); 
          g.drawString("Hellooow World",20,40);

     }
}

}

现在当给定的命令将被调用时,这个方法将被调用

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // TODO Auto-generated method stub

    return null;
}

并且必须在其中调用applet。 我的问题是怎么称呼它?

================================================ ========================================== 我能够解决我的问题,但我在这里回复,以便也面临同样问题的人可以得到指导

这是我的新“newModuleHandler.java”

    package archetypedcomponent.commands;

    import org.eclipse.core.commands.AbstractHandler;
   import org.eclipse.core.commands.ExecutionEvent;
  import org.eclipse.core.commands.ExecutionException;
    import java.applet.*;// required when you create an applet 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JFrame;


public class newModuleHandler extends AbstractHandler {

    @Override
public boolean isEnabled() {
    // TODO Auto-generated method stub
    return true;
}

@Override
public boolean isHandled() {
    // TODO Auto-generated method stub
    return true;
}

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // TODO Auto-generated method stub
//  call applet here
     JFrame jp1 = new JFrame();
        Loader a=new Loader ();
        jp1.getContentPane().add(a, BorderLayout.CENTER);
        jp1.setSize(new Dimension(500,500));
        jp1.setVisible(true);

    return null;
}

}

我制作了一个新的 Loader.java,它扩展了小程序

    package archetypedcomponent.commands;

    import java.applet.Applet;
    import java.awt.Graphics;

    public class Loader extends Applet 
    {
// The method that will be automatically called  when the applet is started 
 public void init() 
 { 
     // It is required but does not need anything. 
     System.out.println("Applet initiated");
//   Graphics g=new ;

 } 


// This method gets called when the applet is terminated 
// That's when the user goes to another page or exits the browser. 
 public void stop() 
 { 
     //     no actions needed here now.
     System.out.println("Applet Stopped");
 } 


// The standard method that you have to use to paint things on screen 
// This overrides the empty Applet method, you can't called it "display" for example.

 public void paint(Graphics g) 
 { 
     //method to draw text on screen 
     // String first, then x and y coordinate. 
     System.out.println("Applet in paint");
      g.drawString("Hey hey hey",20,20); 
      g.drawString("Hellooow World",20,40);

 }

}

现在我需要applet 做的任何事情都可以在Loader 中完成。

【问题讨论】:

    标签: eclipse-plugin applet command multiple-inheritance abstract-syntax-tree


    【解决方案1】:

    一个applet 可以有多个Object,所以extends AbstractHandler 在applet 引用的某个其他类中。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多