Creating an Applet from an Application

So i'm developing my own version of the '80s Space Invader game for class, and one of the requirments is that we have to turn in an application, but also post an Applet version on a website. The game is pretty much done, but I am having trouble creating the Applet from the Application. I've done most of the stuff that i thought you were supposed to do. The thing is, it will run whenever i use the appletviewer from the dos prompt just like it does when i'm running the application. However, when Ii try to view it in an actuall explorer window, it wont load.
The way the program was designed, it had a "SpaceInvaders" class that had the main method, which only had about 4 lines. Then i had a DrawFrame class that extended JFrame, and that had the bulk of the code in it. The main method of the SpaceInvaders class had a "DrawFrame frame = new DrawFrame();" statement, and then a couple set.whatever statements. to change it to an applet, i just commented out the whole of the SpaceInvaders class, then i renamed the DrawFrame class to "public class SpaceInvaders extends JApplet" changed the consructor to the "init()" method, and commented out the setSize and setTitle statements, and also i imported java.applet.*;
when i try to run the html file in firefox, all i get is the frame with a little red 'X' in it, and at the bottom it says "Applet SpaceInvaders notinited"
any help, ideas, or tips would be greately appreciated. Thanks in advance, and if you need any more info, let me know.

i created a very simple applet:
import java.applet.*;
import java.awt.*;
* The HelloWorld class implements an applet that
* simply displays "Hello World!".
public class HelloWorld extends Applet {
    public void paint(Graphics g) {
        // Display "Hello World!"
        g.drawString("Hello world!", 50, 25);
}and it ran just fine inside of a browser. I've also ran other applets that should be very similar to mine, but still mine doesn't work.

Similar Messages

  • How can I run an applet from an application (frame)?

    I have an application (frame) that render images and save it, and then I want to create an animation with those images using Animator applet from the application itself, but I do not how to call the applet from the application, is this possible?
    Thanks in advance, Jorge

    You can simply run a JApplet in a JFrame. Just create a frame object, an object of your applet, add the applet to the frame and call the init() function of your applet. It could look like this:
    JFrame anyFrame = new JFrame("MyTitle");
    YourApplet yourApplet = new YourApplet();
    anyFrame.getContentPane().add(yourApplet, BorderLayout.CENTER);
    yourApplet.init();
    anyFrame.setSize(new Dimension(800,600));
    anyFrame.setVisible(true);
    You will not necessarily have to write the applets default constructor.

  • Unable to create PDF files from any application in any Acrobat version

    Hello, I am hoping someone can help me find a solution to a problem I am having creating PDF files.
    I have searched the Internet for a solution to this problem and can't find any information that helps me.
    I am running OSX 10.8.5 on a 2.5 GHZ Intel i5 Mac Laptop
    I cannot create PDFs from any program, Quark, Word, ect.
    When I try to print to the PDF printer, the printer pauses when it tries to open the Distiller. When I click resume, it pauses itself again.
    I have tried to save the document and create the PDF from within the distiller itself and get this error log:
    %%[ Error: undefined; OffendingCommand: MMXPR3 ]%%
    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
    %%[ Warning: PostScript error. No PDF file produced. ] %%
    I was originally using Acrobat 8, But I installed the trial version of Acrobat 11 and it has the same problem.
    The problem seems to be something to do with the distiller. I have a lot of Adobe software so I am trying to avoid a clean/re-install of Adobe software but will do it as a last resort.
    Thanks in advance for any suggestions.

    Hi,
    Besides pamma has suggested, here are similar issues, you can take a look at:
    http://unsolicitedbutoffered.blogspot.com/2014/01/quick-fix-volume-syntax-error-when.html
    http://crowdsupport.telstra.com.au/t5/T-Suite-Applications/There-was-an-error-opening-this-document-The-filename-directory/td-p/197425
    Best Regards,
    Lisa Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Lisa Chen
    TechNet Community Support

  • Best way to create SVG file from drawing application?

    I am developing a drawing application that allow the users to draw and edit static two dimensional images such as Rectangles, Ellipses and Text. I have a superclass SVGShape that contains all the common features of a shape such as x1, x2, color etc. I then have SVGRectangle as a subclass of SVGShape.
    I want to know what would be the best way to create an SVG file from this? An idea I have at the minute is to have an abstract method getSVG() in the SVGShape class, and then implement the method in the subclasses. I will then create a new class called SVGManager which iterates through the list of shapes (Btw I'm using MVC, my shapes are stored in a Collection) and uses the getSVG() mehtod in each shape to build up a SVG file.
    What do you think of this? Any better ideas?
    Thanks guys

    I used a visitor for this in a similar project, so that when the svg library is used in a applet or browser and the writing functionality isn't required, it may be omitted from the bundle.
    Pete

  • Creating Web Services from Forms Application

    I have a commercial system based on Oracle Forms 6. I would like to expose the functionality of this application as Web Services. This would permit us to integrate these applications using XML technology.
    I think the best approach would be to look for a way to communicate with forms from within a Java environment.
    Does anyone know how I can do this ?

    You can certainly use 10.1.3.x of JDev for building web services to call from forms 10.1.2. I have done this here:
    http://www.oracle.com/technology/products/forms/htdocs/10gr2/howto/webservicefromforms/ws_10_1_3_from_forms.html
    Generally the thing you have to watch is to ensure the JDK version for the web service proxy project is the same as Forms (1.4). You also need to be careful on the web service type from which you are creating the proxy. (Jax-rpc, jax-ws etc)
    It might be worth trying (but might have a few gotchas) using 10.1.3 to generate a proxy against an 11g web service - but you need to watch what version of the web services standard you are using as there have been a number of changes in this area.
    hope that helps
    Grant

  • ClassNotFound error while running applet from Web application

    hi everyone,
    I have a web application deployed in Tomcat web server. I have HTML file at the level of WEB-INF. And all class files under WEB-INF/classes. But while ruuning the application it giving following error.
    load: class com.app.AppletTest not found.
    java.lang.ClassNotFoundException: com.app.AppletTest
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    Here the HTML file applettest.html
    <html>
         <head>
              <title>Multiple Image Upload</title>
         </head>
         <body>
              <applet code="com.app.AppletTest" width="300" height="300">
              </applet>
         </body>
    </html>
    And Java applet file is
    package com.app;
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    public class AppletTest extends Applet
         public void init()
              System.out.println("Init called");
              this.setBackground(new Color(180,200,250));
         public void start()
              System.out.println("Start called");
         public void paint(Graphics g)
              g.drawString("welcome Hello World",50,50);
              System.out.println("Paint called");
         public void stop()
              System.out.println("Stop called");
         public void destroy()
              System.out.println("Destroy called");
    Thanks.

    Hi,
    if u put ur com.app.AppletTest file @ WEB-INF Directry, then this problem will solve easily.
    you have to put applet package(com.app.AppletTest) @ WEB-INF Directry. Since
    Applet is using by html, u have to keep applet with html file.
    if applet class have interaction with other classes, u have to seperate all related class to applet to seperate package and put them @ WEB-INF folder.

  • How to create an applet within an application?

    Hi. Im trying to make an applet work within a main application but I cant get it to work because then I have 2 of these and it gives me an error:
    public class java_tester extends JFrame implements MouseListener //MAIN APPLICATION
    public class MusicPlay extends JApplet //APPLET
    I cant have both if them because it is like two different programs.
    Can anyone help me with this?
    Thanks

    ProGenius wrote:
    But when I put public class MusicPlay extends JApplet it underlines it because the name of the main program is different and when I give it the same name it still underlines it. I know it probably is easy to do it but I really dont know how to make it work.
    Thanks a lot for your helpWhat is "it", what is "it" underlining, and why is this a problem? There's no such concept as "main program". If you're confused by the presence of two whole classes, don't be. Anything beyond the laughably trivial will consist of several classes.

  • What the best way to create XML files from JAVA application?

    Hi to all,
    I need to edit and to create new filex in format of xml. I know to parse, but what would be the best way to do:
    1. - Create new file, create like simle text file, or there is some clases that know to do it in more simple way
    2.a - Edit XML file, to take some data and add it to the XML in the place I want to.
    2.b - Also Edit, but not to add fields, just update some of them.
    Code examples or links to samples woul be welcomed.
    Best regards, Nick.

    I have tried working with XML directly using the Java classes but this was a pain. I then looked at DOM4J and JDOM and found JDOM easier to use.

  • How to create iCal events from other applications?

    I want to create event linked with a certain document, e.g. when I've finishes a letter in Pages or in TeXShop, I want to create an event in iCal for reminder. I know, that I can in iCal create events and add the link to the file into the URL field of an event. But I want in Pages, TeXShop, Numbers, … to click: »Create reminder in iCal on <date>.«
    Is there a way for it?

    Cody,
    Read: http://discussions.apple.com/thread.jspa?messageID=8314404&#8314404
    You can use Firewire Target Disk mode: http://support.apple.com/kb/HT1661 to transfer the appropriate iCal files.
    ;~)

  • Create package with prompt from other application

    Hi Experts!
    I need to create a package in the planning application. In the screen selection I need some dimensions of my planning cube and one dimension of the Ownership application. I don't have any problem with the current application dimension, but I need to retrieve the members of INTCO dimension from Ownership because the user should make the selection. Is it possible to create a prompt from other application?
    Thanks!!

    I create the package in Planning application: 
    PROMPT
    (SELECTINPUT,,,"Selction members","%ENTITY_DIM%,%CATEGORY_DIM%,%TIME_DIM%,%CURRENCY_DIM%,INTCO")
    When i try to select one member of INTCO dimension it appear the following message: "Dimension INTCO is not found". BPC is not finding this dimension because it pertain to another application.

  • How to call webservice from Java application

    Hi XI gurus
    Pls let me know how to call a webservice from Java application.
    I wanted to build synchronous interface from Java Application to SAP using SAP XI
    For example, i need to create Material master from Java application and the return message from SAP, should be seen in Java application
    Regards
    MD

    Hi,
    If your  JAVA Application is Web based application, you can expose it as Webservice.
    JAVA People will pick the data from Dbase using their application and will send the data to XI by using our XI Details like Message Interface and Data type structure and all.
    So we can Use SOAP Adapter or HTTP in XI..
    If you use HTTP for sending the data to XI means there is no need of Adapter also. why because HTTP sits on ABAP Stack and can directly communicate with the XI Integration Server Directly
    If you are dealing with the Webservice and SAP Applications means check this
    Walkthrough - SOAP  XI  RFC/BAPI
    REgards
    Seshagiri

  • Calendar appointments from BSP application

    Do you anyone have an idea on how to create Calender appointments from BSP applications?
    Any inputs would be helpfull.
    Srinivas

    Hello,
    calendar items are specially formatted mail items. They do not have textual body, only an attachment with extension
    .ics
    Here is an example how it should look like:
    BEGIN:VCALENDAR
    PRODID:-//COMPANY//R/3-640//D
    VERSION:2.0
    METHOD:REQUEST
    BEGIN:VEVENT
    ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;ROLE=CHAIR;CN="aaa.bb@ccc.
    com":MAILTO:[email protected]
    ATTENDEE;PARTSTAT=ACCEPTED;RSVP=TRUE;ROLE=CHAIR;CN=""Sender, aaa"":MAILTO:sender.
    [email protected]
    ORGANIZER:MAILTO:[email protected]
    DTSTART:20060308T090000Z
    DTEND:20060308T093000Z
    LOCATION:
    UID:[email protected]
    STATUS:CONFIRMED
    DTSTAMP:20060310T122435Z
    SUMMARY:test4
    CATEGORIES:Keine Terminart ausgewählt
    CREATED:20060310T122435Z
    SEQUENCE:0
    TRANSP:OPAQUE
    PRIORITY:5
    CLASS:PUBLIC
    DESCRIPTION:test 4
    END:VEVENT
    END:VCALENDAR
    I hope it helps you to create your own calendar items.
    Regards,
    Dezso

  • Help creating an applet

    I need to create an applet from a standalone chat client.
    Can someone please help me, or suggest some good tutorials about writing applets?
    TIA,
    Richie.
    ------------------------BEGIN---------------------------
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class Client
    extends JPanel {
    public static void main(String[] args) throws IOException {
    String name = args[0];
    String host = args[1];
    int port = Integer.parseInt(args[2]);
    final Socket s = new Socket(host, port);
    final Client c = new Client(name, s);
    JFrame f = new JFrame("Client : " + name);
    f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    c.shutDown();
    System.exit(0);
    f.setSize(300, 300);
    f.setLocation(100, 100);
    f.setContentPane(c);
    f.setVisible(true);
    private String mName;
    private JTextArea mOutputArea;
    private JTextField mInputField;
    private PrintWriter mOut;
    public Client(final String name, Socket s)
    throws IOException {
    mName = name;
    createUI();
    wireNetwork(s);
    wireEvents();
    public void shutDown() {
    mOut.println("");
    mOut.close();
    protected void createUI() {
    setLayout(new BorderLayout());
    mOutputArea = new JTextArea();
    mOutputArea.setLineWrap(true);
    mOutputArea.setEditable(false);
    add(new JScrollPane(mOutputArea), BorderLayout.CENTER);
    mInputField = new JTextField(20);
    JPanel controls = new JPanel();
    controls.add(mInputField);
    add(controls, BorderLayout.SOUTH);
    mInputField.requestFocus();
    protected void wireNetwork(Socket s) throws IOException {
    mOut = new PrintWriter(s.getOutputStream(), true);
    final String eol = System.getProperty("line.separator");
    new Listener(s.getInputStream()) {
    public void processLine(String line) {
    mOutputArea.append(line + eol);
    mOutputArea.setCaretPosition(
    mOutputArea.getDocument().getLength());
    protected void wireEvents() {
    mInputField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    String line = mInputField.getText();
    if (line.length() == 0) return;
    mOut.println(mName + " : " + line);
    mInputField.setText("");
    ------------------------------END------------------------------

    Thank you, that was very helpful info. I am new to java, so I find this exercise really touch. Here is what I have so far:
    -------------------------BEGIN-------------------------
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.applet.*;
    import javax.swing.*;
    public class Client extends Applet implements ActionListener {
         String name;
         String host;
         int port;
         final Socket s;
         final Client c;
         Button sendButton;
         TextField txtField;
         TextArea txtArea;
    public void init() {
              setLayout(new FlowLayout());
              name = "Richard";
              host = InetAddress.getLocalHost();
              port = 8000;
              Socket s = new Socket(host, port);
              Client c = new Client(name, s);
              txtField = new TextField();
              sendButton = new Button("Send");
              txtArea = new TextArea("Chat with " + name + " on " + host " : " + port);
              add(txtArea);
              add(txtField);
              add(sendButton);
         sendButton.addActionListener(this);
    public void paint(Graphics g) {
         g.setColor(Color.red);
         g.drawString("<" + name + "> " + txtField.getText(),20,250);
    public void actionPerformed(ActionEvent evt) {
    if (evt.getSource() == sendButton)
              repaint();
              txtArea.setText(txtField.getText());
    private String mName;
    private TextArea mOutputArea;
    private TextField mInputField;
    private PrintWriter mOut;
    public Client(final String name, Socket s)
    throws IOException {
    mName = name;
    createUI();
    wireNetwork(s);
    wireEvents();
    public void shutDown() {
    mOut.println("");
    mOut.close();
    protected void createUI() {
    setLayout(new BorderLayout());
    mOutputArea = new TextArea();
    mOutputArea.setLineWrap(true);
    mOutputArea.setEditable(false);
    add(new JScrollPane(mOutputArea), BorderLayout.CENTER);
    mInputField = new TextField(20);
    JPanel controls = new JPanel();
    controls.add(mInputField);
    add(controls, BorderLayout.SOUTH);
    mInputField.requestFocus();
    protected void wireNetwork(Socket s) throws IOException {
    mOut = new PrintWriter(s.getOutputStream(), true);
    final String eol = System.getProperty("line.separator");
    new Listener(s.getInputStream()) {
    public void processLine(String line) {
    mOutputArea.append(line + eol);
    mOutputArea.setCaretPosition(
    mOutputArea.getDocument().getLength());
    protected void wireEvents() {
    mInputField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    String line = mInputField.getText();
    if (line.length() == 0) return;
    mOut.println(mName + " : " + line);
    mInputField.setText("");

  • How do I create a window from an applet?

    I am trying to create a window application from an applet. The window that I need should meet the following criteria:
    1. The window application will be created when I click on one of the buttons in the applet.
    2. If I close the applet from the browser, the window application should not be affected.
    3. I should be able to close the window by clicking the X icon on the upper right corner.
    4. The window application works by itself. It does not need to interact with the applet any more.
    Is there any example similar to what I am looking for available?

    1. Easy.
    Button myButton = new Button( "a button" ) ;
    myButton.addActionListener( new ActionListener()
    public void actionPerformed( ActionEvent e )
    Frame myFrame = new Frame( "a frame" ) ;
    myFrame.show() ;
    add( myButton ) ;2. Short answer, can't be done. Long answer, I think it can be done with something called "Java WebReady", but I don't how. (needs JDK 1.4, I think)
    3. Easy. You just have to add a window listener to the frame.
    class closeWindowListener extends WindowAdapter
         private Frame myFrame ;
         closeWindowListener( Frame myFrame )
              this.myFrame = myFrame ;
         public void windowClosing( WindowEvent e )
              myFrame.dispose() ;
    myFrame.addWindowListener( new closeWindowListener( myFrame ) ) ;
    myFrame.show() ;4. Fine with me, but keep in mind the difficulty of #2.

  • How can I create a Report from a SWT-Application?

    Post Author: mkoch
    CA Forum: JAVA
    I'm a Developer and new to Crystal Reports and I have the job to create a Report from a SWT-Application.The report-files ( *.rpt) were created with Crystal Reports 10 or 11.> I'm not sure but I have access to a machine where Crystal Reports 10 Developer an Crystal Reports 11 Runtime are installed.Can anybody describe in detail how I can start the creation of a report from my Java-Application?> What libraries are needed, where can I get them and so on.I saw in the CR10-Setup that there is a Java-feature - but unfortunately this is not installed on my test-machine.--> Is it necessary to install this feature or can I get this files on businessobjects.com?Is it possible to start the report-creation from command-line?I saw a Java-example on the internet which uses Report.exe - but I haven't found this on my machine.I hope, that somebody can help me.GreetingsMarkus

    Inv. #
    Item
    Sale Price
    Lisa
    Oct Sold 12
    Oct Sold 12-2
    Oct Sold 12-3
    149
    Vase Lidded
    25
    201
    Bird
    7
    7
    202
    Bird
    7
    203
    Bird
    7
    204
    Bird
    7
    7
    205
    Bird
    7
    7
    206
    Bird
    7
    7
    207
    Bird
    7
    207
    Bird
    7
    7
    208
    Bird
    7
    7
    209
    Bird
    7
    7
    This is my very simple inventory.  On previous program I could sort by those items that did not have any figure in the row across.  Then I could print a report of open inventory.  Such as 149 Lidded Vase has not sales amount in the four colums across, thus it is open inventory.  How can I capture all those items in one report?

Maybe you are looking for