Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

APLLET NOT INITIALISED

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Duplicate of https://coderanch.com/t/435301/Swing-AWT-SWT-JFace/java/APLLET-NOT-INITIALISED
Closing
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic