0

This feels like a really simple question, however, in every instance that I've looked for and found an "answer" it was far beyond my level of comprehension. I'm relatively new to Java, only having started back in September for my A.P. Comp Sci class. However, I am making a very simple applet to ask a (similarly nerdy) girl to prom. So basically this means that I need the applet to work just by being on the flash drive which I will give to her. I've never needed to export before and my program runs fine (at least from Eclipse's standpoint), however, every time I export it as a .jar file and try to run it, nothing happens. At all. No error, no box, nothing. I keep seeing that I need to use html's or something which seems a bit overwhelming and not within the options (as I said, considering it needs to work just by plugging the drive into any computer).

Anyway, how can I fix this and win over my potential date?

Code as follows:

package Runner;

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class mainRunner extends Applet implements ActionListener {

    public mainRunner(){
        Label Prom=new Label ("Prom?");
        JButton BYes=new JButton("Yes!");
        JButton BNo=new JButton("No!");
        JButton YYes=new JButton("Why yes?");
        JButton YNo=new JButton("Why no?");

        BYes.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent Yes){
                //code...//
            }
        }
        );

        BNo.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent No){
                //code...//
            }
        }
        );

        YYes.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent WhyYes){
            //code...//
            }
        }
        );

        YNo.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent WhyNo){
                //code...//
            }
        }
        );

        add(Prom);
        add(BYes);
        add(YYes);
        add(BNo);
        add(YNo);
    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
        // TODO Auto-generated method stub

    }
}

Thanks in advance and try to keep things pretty streamlined if possible.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1) Try opening it with [Appleteer](http://pscode.org/appleteer/), which does more checks and produces more detailed output. 2) Why code an applet? If it is due due to spec. by teacher, 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/). .. – Andrew Thompson May 11 '13 at 14:52
  • .. 3) Why AWT rather than Swing? See this answer on [Swing extras over AWT](http://stackoverflow.com/a/6255978/418556) for many good reasons to abandon using AWT components. If you need to support older AWT based APIs, see [Mixing Heavyweight and Lightweight Components](http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html). – Andrew Thompson May 11 '13 at 14:52
  • Now I've looked at & run the code (it works here): Please learn common [Java naming conventions](http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#73307) (specifically the case used for the names) for class, method & attribute names & use them consistently. *"I keep seeing that I need to use html's or something which seems a bit overwhelming and not within the options"* Tough. An applet is not going to work without HTML. You are ***really*** not at the stage where you should be developing applets. They are very tricky even for experienced developers. – Andrew Thompson May 11 '13 at 14:59

0 Answers0