0

How do i settitle of this appletform? I am trying to add menuitems in my applet with no luck yet! and how to close the window if close menuitem is clicked? I tried dispose(); but its also not working!

public class AppletForm extends Applet implements
    DragGestureListener, // For recognizing the start of drags
    DragSourceListener, // For processing drag source events
    DropTargetListener, // For processing drop target events
    MouseListener, // For processing mouse clicks
    MouseMotionListener // For processing mouse drags
{
    private MenuBar menuBar = new MenuBar(); // first, create a MenuBar item
    private Menu file = new Menu(); // our File menu
    // what's going in File? let's see...
    private MenuItem openFile = new MenuItem();  // an open option
    private MenuItem saveFile = new MenuItem(); // a save option
    private MenuItem close = new MenuItem(); // and a close option!

    StringBuffer strBuffer;

    public void init() {
        setSize(500, 300);
    addMouseListener(this);
    strBuffer = new StringBuffer();
        addItem("initializing the apple ");

    }
}
Mitesh
  • 145
  • 1
  • 13
  • Possible duplicate of [Changing the text in the title bar](http://stackoverflow.com/questions/5424157/changing-the-text-in-the-title-bar) – Frakcool Oct 01 '15 at 19:12
  • I ckecked the link, that is given for jframe, but i need it for applet. – Mitesh Oct 01 '15 at 19:24
  • 1) Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 2) Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. Note: `JApplet` has `setJMenuBar` but there is no equivalent for `Applet`. 3) *"and how to close the window if close menuitem is clicked?"* .. – Andrew Thompson Oct 02 '15 at 18:13
  • 3) .. I can only presume you are confusing the applet viewer with an applet embedded in a web page. An applet in a web page should not be trying to 'close the window' (which would be the page or the browser) and has no option to set the title of the browser. – Andrew Thompson Oct 02 '15 at 18:15

0 Answers0