*
The moose likes Swing / AWT / SWT and the fly likes APLLET NOT INITIALISED Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

APLLET NOT INITIALISED

hi friends
Greenhorn

Joined: Mar 10, 2009
Posts: 2
I am on java2 and having done ''creating menu bar" and 'dialog boxes', I am held up at my first applet.
Here is the code I have written

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
public class SampleDialog extends Dialog implements ActionListener
{
SampleDialog(Frame parent,String title)
{
super(parent,title,false);
setLayout(new FlowLayout());
setSize(300,200);
add(new Label("PRESS THIS BUTTON"));
Button b;
add(b=new Button("CANCEL"));
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
dispose();
}
public void paint(Graphics g)
{
g.drawString("THIS IS IN THE DIALOG BOX",10,70);
}
}
class MenuFrame extends Frame
{
String msg=" ";
MenuFrame(String title)
{
super(title);
MenuBar mbar=new MenuBar();
setMenuBar(mbar);
Menu file=new Menu("FILE");
MenuItem i1,i2,i3,i4,i5;
file.add(i1=new MenuItem("NEW"));
file.add(i2=new MenuItem("OPEN"));
file.add(i3=new MenuItem("CLOSE"));
file.add(i4=new MenuItem("-"));
file.add(i5=new MenuItem("QUIT"));
mbar.add(file);
Menu edit=new Menu("EDIT");
MenuItem i6,i7,i8;
edit.add(i6=new MenuItem("CUT"));
edit.add(i7=new MenuItem("COPY"));
edit.add(i8=new MenuItem("PASTE"));
mbar.add(edit);
MyMenuHandler handler=new MyMenuHandler(this);
i1.addActionListener(handler);
i2.addActionListener(handler);
i3.addActionListener(handler);
i4.addActionListener(handler);
i5.addActionListener(handler);
i6.addActionListener(handler);
i7.addActionListener(handler);
i8.addActionListener(handler);
MyWindowAdapter adapter=new MyWindowAdapter(this);
addWindowListener(adapter);
}
public void paint(Graphics g)
{
g.drawString(msg,10,200);
}
public class MyWindowAdapter extends WindowAdapter
{
MenuFrame menuFrame;
public MyWindowAdapter(MenuFrame menuFrame)
{
this.menuFrame=menuFrame;
}
public void windowClosing(WindowEvent we)
{
menuFrame.dispose();
}
}
public class MyMenuHandler implements ActionListener,ItemListener
{
MenuFrame menuFrame;
public MyMenuHandler(MenuFrame menuFrame)
{
this.menuFrame=menuFrame;
}
public void actionPerformed(ActionEvent ae)
{
String msg="YOU SELECTED";
String arg=(String)ae.getActionCommand();
if(arg.equals("NEW"))
{
msg+="New";
SampleDialog d=new SampleDialog(menuFrame,"NEW DIALOG BOX");
d.setVisible(true);
}
else if(arg.equals("OPEN"))
msg+="OPEN";
else if(arg.equals("CLOSE"))
msg+="CLOSE";
else if(arg.equals("QUIT"))
msg+="QUIT";
else if(arg.equals("CUT"))
msg+="CUT";
else if(arg.equals("COPY"))
msg+="COPY";
else if(arg.equals("PASTE"))
msg+="PASTE";
menuFrame.msg=msg;
menuFrame.repaint();
}
public void itemStateChanged(ItemEvent ie)
{
menuFrame.repaint();
}
}
public class DialogDemo extends Applet
{
MenuFrame f;
public void init()
{
f=new MenuFrame("DIALOG DEMO");
int width=Integer.parseInt(getParameter("width"));
int height=Integer.parseInt(getParameter("height"));
setSize(width,height);
f.setSize(width,height);
f.setVisible(true);
}
public void start()
{
f.setVisible(true);
}
public void stop()
{
f.setVisible(false);
}
}
}



HTML CODE:


<html>
<body>
<applet code=SampleDialog.class width=300 height=300>
</applet>
</body>
</html>



when i run the code there is no error and when i make applet viewer to run..at the bottom left corner "start:applet not initialised" is displayed.


please anyone help me to solve this !!!

thank you in advance
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8

Duplicate of http://www.coderanch.com/t/435301/Swing-AWT-SWT-JFace/java/APLLET-NOT-INITIALISED
Closing


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
jQuery in Action, 2nd edition
 
subject: APLLET NOT INITIALISED
 
Similar Threads
why does this return false?
menu problem..please help ASAP..
Creation of Ineger Wrapper Object
APLLET NOT INITIALISED
Integer unboxing and == operator question