import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
public class IE extends Applet{
TopPanel MainTopPanel;
MainWindow IEMainWindow;
TopButtonArea MainTopButtonArea;
private Color AppletBackColor;
public void init(){
AppletBackColor=new Color(206,206,255);
setSize(600,480);
setLayout(new BorderLayout());
setBackground(AppletBackColor);
MainTopPanel=new TopPanel();
MainTopPanel.setVisible(true);
add("North",MainTopPanel);
IEMainWindow=new MainWindow();
IEMainWindow.setVisible(true);
MainTopButtonArea=new TopButtonArea();
MainTopButtonArea.setVisible(true);
IEMainWindow.add("North",MainTopButtonArea);
}
public void destroy(){
IEMainWindow.close();
}
}class TopPanel extends Panel{
private Label TitleLabel;
private Font TitleFont;
public TopPanel(){
setLayout(new BorderLayout());
TitleFont=new Font("TimesRoman", Font.BOLD+Font.ITALIC, 20);
TitleLabel=new Label("Industry Engineering ALPHA1.0 Demo");
TitleLabel.setFont(TitleFont);
add("North",TitleLabel);
}
}class MainWindow extends Frame {
private MenuBar FileMenuBar;
private Menu ConnectMenu;
private Menu HelpMenu;
private Menu JavaZoneMenu;
private Menu IEMenu;
private Color BackgroundColor;
public MainWindow(){
setTitle("Demo Show");
BackgroundColor=new Color(149,149,255);
setSize(640,480);
setLayout(new BorderLayout());
setBackground(BackgroundColor);
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
FileMenuBar=new MenuBar();
ConnectMenu=new Menu("Connect");
HelpMenu=new Menu("Help");
JavaZoneMenu=new Menu("JAVA Zone");
IEMenu=new Menu("Industry Engineering Zone");
MenuItem EditHostItem=new MenuItem("Edit Host");
MenuItem ConnectHostItem=new MenuItem("Connect Host");
MenuItem AboutIEItem=new MenuItem("About IE Software");
MenuItem AboutAuthorItem=new MenuItem("About Author");
MenuItem AccessGNUItem=new MenuItem("Access GNU");
MenuItem Java01=new MenuItem("java.sun.com");
ConnectMenu.add(EditHostItem);
ConnectMenu.addSeparator();
ConnectMenu.add(ConnectHostItem);
HelpMenu.add(AboutIEItem);
HelpMenu.addSeparator();
HelpMenu.add(AboutAuthorItem);
HelpMenu.addSeparator();
HelpMenu.add(AccessGNUItem);
JavaZoneMenu.add(Java01);
FileMenuBar.add(ConnectMenu);
FileMenuBar.add(JavaZoneMenu);
FileMenuBar.add(IEMenu);
FileMenuBar.add(HelpMenu);
FileMenuBar.setHelpMenu(HelpMenu);
setMenuBar(FileMenuBar);
}
public void close(){
this.dispose();
this.setVisible(false);
}
}class TopButtonArea extends Panel implements ActionListener{
private Label IndexLabel;
private Font Font01;
private Color ButtonColor;
Block2D Block2DFrame;
public TopButtonArea(){
ButtonColor=new Color(176,176,255);
Font01=new Font("TimesRoman", Font.BOLD, 16);
IndexLabel=new Label("Click The Left Button");
IndexLabel.setFont(Font01);
Button GantBT;
Button CookieBT;
Button Cookie3DBT;
Button BlockBT;
Button Block3DBT;
Button LineBT;
GantBT=new Button(" GANT ");
GantBT.addActionListener(this);
GantBT.setBackground(ButtonColor);
add(GantBT);
CookieBT=new Button(" Cookie ");
CookieBT.addActionListener(this);
CookieBT.setBackground(ButtonColor);
add(CookieBT);
Cookie3DBT=new Button("Cookie3D");
Cookie3DBT.addActionListener(this);
Cookie3DBT.setBackground(ButtonColor);
add(Cookie3DBT);
BlockBT=new Button(" Block ");
BlockBT.addActionListener(this);
BlockBT.setBackground(ButtonColor);
add(BlockBT);
Block3DBT=new Button(" Block3D ");
Block3DBT.addActionListener(this);
Block3DBT.setBackground(ButtonColor);
add(Block3DBT);
LineBT=new Button(" Line ");
LineBT.addActionListener(this);
LineBT.setBackground(ButtonColor);
add(LineBT);
add(IndexLabel);
}
public void actionPerformed (ActionEvent e){
String BLabel=e.getActionCommand();
if(BLabel.equals(" Block ")){
Block2DFrame=new Block2D();
Block2DFrame.setTitle("Block2D");
Block2DFrame.setSize(480,320);
Block2DFrame.setVisible(true);
}
}
}class Block2DCanvas extends Canvas{
public Block2DCanvas(){
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.draw3DRect(0, 0, 469, 319, true);
g.draw3DRect(3, 3, 463, 313, false);
}
}
class Block2D extends Frame{
Color CanvasBackColor;
Block2DCanvas BlockCanvas;
public void Block2D(){
setLayout(new BorderLayout());
BlockCanvas=new Block2DCanvas();
CanvasBackColor=new Color(230,230,255);
BlockCanvas.setBackground(CanvasBackColor);
BlockCanvas.setSize(480,320);
this.add("Center",BlockCanvas);
BlockCanvas.setVisible(true);
}
}代码都在这里,大家可以运行一下
import java.applet.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
public class IE extends Applet{
TopPanel MainTopPanel;
MainWindow IEMainWindow;
TopButtonArea MainTopButtonArea;
private Color AppletBackColor;
public void init(){
AppletBackColor=new Color(206,206,255);
setSize(600,480);
setLayout(new BorderLayout());
setBackground(AppletBackColor);
MainTopPanel=new TopPanel();
MainTopPanel.setVisible(true);
add("North",MainTopPanel);
IEMainWindow=new MainWindow();
IEMainWindow.setVisible(true);
MainTopButtonArea=new TopButtonArea();
MainTopButtonArea.setVisible(true);
IEMainWindow.add("North",MainTopButtonArea);
}
public void destroy(){
IEMainWindow.close();
}
}class TopPanel extends Panel{
private Label TitleLabel;
private Font TitleFont;
public TopPanel(){
setLayout(new BorderLayout());
TitleFont=new Font("TimesRoman", Font.BOLD+Font.ITALIC, 20);
TitleLabel=new Label("Industry Engineering ALPHA1.0 Demo");
TitleLabel.setFont(TitleFont);
add("North",TitleLabel);
}
}class MainWindow extends Frame {
private MenuBar FileMenuBar;
private Menu ConnectMenu;
private Menu HelpMenu;
private Menu JavaZoneMenu;
private Menu IEMenu;
private Color BackgroundColor;
public MainWindow(){
setTitle("Demo Show");
BackgroundColor=new Color(149,149,255);
setSize(640,480);
setLayout(new BorderLayout());
setBackground(BackgroundColor);
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
FileMenuBar=new MenuBar();
ConnectMenu=new Menu("Connect");
HelpMenu=new Menu("Help");
JavaZoneMenu=new Menu("JAVA Zone");
IEMenu=new Menu("Industry Engineering Zone");
MenuItem EditHostItem=new MenuItem("Edit Host");
MenuItem ConnectHostItem=new MenuItem("Connect Host");
MenuItem AboutIEItem=new MenuItem("About IE Software");
MenuItem AboutAuthorItem=new MenuItem("About Author");
MenuItem AccessGNUItem=new MenuItem("Access GNU");
MenuItem Java01=new MenuItem("java.sun.com");
ConnectMenu.add(EditHostItem);
ConnectMenu.addSeparator();
ConnectMenu.add(ConnectHostItem);
HelpMenu.add(AboutIEItem);
HelpMenu.addSeparator();
HelpMenu.add(AboutAuthorItem);
HelpMenu.addSeparator();
HelpMenu.add(AccessGNUItem);
JavaZoneMenu.add(Java01);
FileMenuBar.add(ConnectMenu);
FileMenuBar.add(JavaZoneMenu);
FileMenuBar.add(IEMenu);
FileMenuBar.add(HelpMenu);
FileMenuBar.setHelpMenu(HelpMenu);
setMenuBar(FileMenuBar);
}
public void close(){
this.dispose();
this.setVisible(false);
}
}class TopButtonArea extends Panel implements ActionListener{
private Label IndexLabel;
private Font Font01;
private Color ButtonColor;
Block2D Block2DFrame;
public TopButtonArea(){
ButtonColor=new Color(176,176,255);
Font01=new Font("TimesRoman", Font.BOLD, 16);
IndexLabel=new Label("Click The Left Button");
IndexLabel.setFont(Font01);
Button GantBT;
Button CookieBT;
Button Cookie3DBT;
Button BlockBT;
Button Block3DBT;
Button LineBT;
GantBT=new Button(" GANT ");
GantBT.addActionListener(this);
GantBT.setBackground(ButtonColor);
add(GantBT);
CookieBT=new Button(" Cookie ");
CookieBT.addActionListener(this);
CookieBT.setBackground(ButtonColor);
add(CookieBT);
Cookie3DBT=new Button("Cookie3D");
Cookie3DBT.addActionListener(this);
Cookie3DBT.setBackground(ButtonColor);
add(Cookie3DBT);
BlockBT=new Button(" Block ");
BlockBT.addActionListener(this);
BlockBT.setBackground(ButtonColor);
add(BlockBT);
Block3DBT=new Button(" Block3D ");
Block3DBT.addActionListener(this);
Block3DBT.setBackground(ButtonColor);
add(Block3DBT);
LineBT=new Button(" Line ");
LineBT.addActionListener(this);
LineBT.setBackground(ButtonColor);
add(LineBT);
add(IndexLabel);
}
public void actionPerformed (ActionEvent e){
String BLabel=e.getActionCommand();
if(BLabel.equals(" Block ")){
Block2DFrame=new Block2D();
Block2DFrame.setTitle("Block2D");
Block2DFrame.setSize(480,320);
Block2DFrame.setVisible(true);
}
}
}class Block2DCanvas extends Canvas{
public Block2DCanvas(){
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.draw3DRect(0, 0, 469, 319, true);
g.draw3DRect(3, 3, 463, 313, false);
}
}
class Block2D extends Frame{
Color CanvasBackColor;
Block2DCanvas BlockCanvas;
public void Block2D(){
setLayout(new BorderLayout());
BlockCanvas=new Block2DCanvas();
CanvasBackColor=new Color(230,230,255);
BlockCanvas.setBackground(CanvasBackColor);
BlockCanvas.setSize(480,320);
this.add("Center",BlockCanvas);
BlockCanvas.setVisible(true);
}
}代码都在这里,大家可以运行一下
不是plug-in的问题,因为你没有什么swing组件,而且我用applet标签试了一下,也可以运行,且一切正常(在IE和appletviewer)都一样。不知你那是什么情况?
import java.applet.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;public class IE extends Applet
{
TopPanel MainTopPanel;
MainWindow IEMainWindow;
TopButtonArea MainTopButtonArea;
private Color AppletBackColor;
public void init()
{
AppletBackColor=new Color(206,206,255);
// setSize(600,480);
setLayout(new BorderLayout());
setBackground(AppletBackColor);
TopPanel MainTopPanel=new TopPanel();
add("North",MainTopPanel);
IEMainWindow=new MainWindow();
IEMainWindow.setVisible(true);
// MainTopButtonArea=new TopButtonArea();
// MainTopButtonArea.setVisible(true);
// IEMainWindow.add("North",MainTopButtonArea);
}
public void destroy()
{
IEMainWindow.close();
}
}class TopPanel extends Panel
{
private Label TitleLabel;
private Font TitleFont;
public TopPanel()
{
setLayout(new BorderLayout());
TitleFont=new Font("TimesRoman", Font.BOLD+Font.ITALIC, 20);
TitleLabel=new Label("Industry Engineering ALPHA1.0 Demo");
TitleLabel.setFont(TitleFont);
add("North",TitleLabel);
}
}class MainWindow extends Frame
{
private MenuBar FileMenuBar;
private Menu ConnectMenu;
private Menu HelpMenu;
private Menu JavaZoneMenu;
private Menu IEMenu;
private Color BackgroundColor;
public MainWindow()
{
this.addWindowListener (new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
setTitle("Demo Show");
BackgroundColor=new Color(149,149,255);
setLayout(new BorderLayout());
setBackground(BackgroundColor);
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
FileMenuBar=new MenuBar();
ConnectMenu=new Menu("Connect");
HelpMenu=new Menu("Help");
JavaZoneMenu=new Menu("JAVA Zone");
IEMenu=new Menu("Industry Engineering Zone");
MenuItem EditHostItem=new MenuItem("Edit Host");
MenuItem ConnectHostItem=new MenuItem("Connect Host");
MenuItem AboutIEItem=new MenuItem("About IE Software");
MenuItem AboutAuthorItem=new MenuItem("About Author");
MenuItem AccessGNUItem=new MenuItem("Access GNU");
MenuItem Java01=new MenuItem("java.sun.com");
ConnectMenu.add(EditHostItem);
ConnectMenu.addSeparator();
ConnectMenu.add(ConnectHostItem);
HelpMenu.add(AboutIEItem);
HelpMenu.addSeparator();
HelpMenu.add(AboutAuthorItem);
HelpMenu.addSeparator();
HelpMenu.add(AccessGNUItem);
JavaZoneMenu.add(Java01);
FileMenuBar.add(ConnectMenu);
FileMenuBar.add(JavaZoneMenu);
FileMenuBar.add(IEMenu);
FileMenuBar.add(HelpMenu);
FileMenuBar.setHelpMenu(HelpMenu);
setMenuBar(FileMenuBar);
TopButtonArea tba = new TopButtonArea();
add(tba,BorderLayout.CENTER);
setSize(640,480);
}
public void close(){
this.dispose();
this.setVisible(false);
}
}class TopButtonArea extends Panel implements ActionListener
{
private Label IndexLabel;
private Font Font01;
private Color ButtonColor;
Block2D Block2DFrame;
public TopButtonArea()
{
ButtonColor=new Color(176,176,255);
Font01=new Font("TimesRoman", Font.BOLD, 16);
IndexLabel=new Label("Click The Left Button");
IndexLabel.setFont(Font01);
Button GantBT;
Button CookieBT;
Button Cookie3DBT;
Button BlockBT;
Button Block3DBT;
Button LineBT;
GantBT=new Button(" GANT ");
GantBT.addActionListener(this);
GantBT.setBackground(ButtonColor);
add(GantBT);
CookieBT=new Button(" Cookie ");
CookieBT.addActionListener(this);
CookieBT.setBackground(ButtonColor);
add(CookieBT);
Cookie3DBT=new Button("Cookie3D");
Cookie3DBT.addActionListener(this);
Cookie3DBT.setBackground(ButtonColor);
add(Cookie3DBT);
BlockBT=new Button(" Block ");
BlockBT.addActionListener(this);
BlockBT.setBackground(ButtonColor);
add(BlockBT);
Block3DBT=new Button(" Block3D ");
Block3DBT.addActionListener(this);
Block3DBT.setBackground(ButtonColor);
add(Block3DBT);
LineBT=new Button(" Line ");
LineBT.addActionListener(this);
LineBT.setBackground(ButtonColor);
add(LineBT);
add(IndexLabel);
}
public void actionPerformed (ActionEvent e)
{
String BLabel=e.getActionCommand();
if(BLabel.equals(" Block "))
{
Block2DFrame=new Block2D();
Block2DFrame.setTitle("Block2D");
Block2DFrame.setSize(480,320);
Block2DFrame.setVisible(true);
}
}
}class Block2DCanvas extends Canvas
{
public Block2DCanvas()
{
}
public void paint(Graphics g)
{
g.setColor(Color.blue);
g.draw3DRect(0, 0, 469, 319, true);
g.draw3DRect(3, 3, 463, 313, false);
}
}
class Block2D extends Frame
{
Color CanvasBackColor;
Block2DCanvas BlockCanvas;
public void Block2D(){
setLayout(new BorderLayout());
BlockCanvas=new Block2DCanvas();
CanvasBackColor=new Color(230,230,255);
BlockCanvas.setBackground(CanvasBackColor);
BlockCanvas.setSize(480,320);
this.add("Center",BlockCanvas);
BlockCanvas.setVisible(true);
}
}
<HTML>
<HEAD>
<TITLE>MyAppwww Example1</TITLE>
</HEAD>
<BODY>
<H1>MyAppwww</H1>
<HR>
<P>
<APPLET CODE="IE.class" WIDTH="300" HEIGHT="300">
</APPLET>
</P>
<HR>
</BODY>
</HTML>
示例:
1.test.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<BODY>
<APPLET CODE = "MultiListener.class" WIDTH = 400 HEIGHT = 50>
</APPLET>
</BODY>
</HTML>
2.MultiListener.class源码:
//MultiListener.java
import java.awt.*;
import java.awt.event.*;
public class MultiListener implements MouseMotionListener,MouseListener,WindowListener
{
private Frame f;
private TextField tf; public static void main(String[] args)
{
MultiListener three=new MultiListener();
three.doit();
} public void doit(){
f=new Frame("Multiple Listener Example");
f.add("North",new Label("Click and drag the mouse"));
tf=new TextField(30);
f.add("South",tf);
f.addMouseMotionListener(this);
f.addMouseListener(this);
f.addWindowListener(this);
f.setSize(300,200);
f.setVisible(true);
} public void mouseDragged(MouseEvent e){
String s="Mouse dragging:X="+e.getX()+"Y="+e.getY();
tf.setText(s);
} public void mouseMoved(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){
String S="the mouse entered";
tf.setText(S);
} public void mouseExited(MouseEvent e){
String s="the mouse has left the text";
tf.setText(s);
} public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
} public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowFirst(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowLast(WindowEvent e){}
public void windowOpened(WindowEvent e){}
}
3.运行test.html
现在在ie下运行test.html是不行的。需要进行用工具进行转换
a.假设htmlconv1_3.zip解压后路径为:C:\htmlconv
在命令行下进入目录:C:\htmlconv\converter\classes
执行:HTMLConverter.bat test.html
b.然后再在ie下执行test.html,就可以正常运行了。试试看!