多个继承..类需要扩展abstractHandler以及Applet
我正在尝试制作一个自动化向导,该向导将从系统中获取一些文件(通过命令处理程序)并制作其相关的小程序。
我将尝试解释我的观点。
我为新命令“newModule”制作了一个插件,该命令通过“newModuleHandler.java”处理。所以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;
}
,并且必须在其中调用小程序。 我的问题是如何调用它?
======================================= =================================================== === 我能够解决我的问题,但我在这里回复,以便也面临同样问题的人可以指导
这是我的新 "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 扩展了 applet
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 的绘制中完成。
I am trying to make an automation wizard that would take some files from system (via a command handler) and make its relevant applet.
I shall try to explain my senario.
I made a plugin for new command "newModule" which is handled via "newModuleHandler.java". so newModuleHandler extends AbstractHandler.
Now i would like to make a wizard (applet) that helps me with certain selections that i need to make in order to complete that "newModule" command. so
newModuleHandler extends Applet too.
i wrote newModuleHandler something like this.
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);
}
}
}
Now when the command will b given this method will be called
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// TODO Auto-generated method stub
return null;
}
and applet will have to be called inside it. my question is how to call it?
========================================================================================
i was able to solve my problem but m replying here so that somebody who is also facing same problem can b guided
this is my new "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;
}
}
i made a new Loader.java which extends applet
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);
}
}
Now whatever i need applet to do can b done in paint of Loader.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个小程序可以有多个对象,因此
在该小程序引用的其他某个类中扩展 AbstractHandler
。An applet can have more than one Object, so
extends AbstractHandler
in some other class that the applet has a reference to.