Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Saving as HTML?

  1. #1
    Member
    Join Date
    Sep 2012
    Posts
    98
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Saving as HTML?

    I made a program here that does random stuff with draw, I was told to send in the .java file ( done ) and the html file (wtf) I am using netBeans and I have no idea of how to save the html file. This is my code.
    import java.applet.Applet;   // Imports the Applet class
    import java.awt.Graphics;    // Imports the Graphics class, used to draw lines, circles, squares, text, etc
     
    /** 
      * The HelloWorld class implements an applet that simply displays "Hello World!". 
      */ 
     
    // Our HelloWorld class extends  the Applet class, giving it access to all the methods of Applet.
    public class HelloWorld extends Applet {         
     
        // The paint method draws anything that is in our applet on the applet screen.  
        // It takes a graphics object (g), that is used to draw
     
        public void paint(Graphics g) 
        {     
     
            double x1;
            double x2;
            double y1;
            double y2;
     
     
     
            x1 = 1;
            x2 = 1;
            y1 = 1;
            y2= 1;
     
            double dbl = distance(x1, y1, x2, y2);
     
            g.drawString("Logan Carl Crone", 50, 25); 
            g.drawString("Can You Find Me??", 250,150);
            g.drawString("" + dbl, 150, 150);
     
     
            distance (x1, y1, x2, y2);
     
        }    
    public static double distance 
                   (double x1, double y1, double x2, double y2) { 
             double dx = x2 - x1;
             double dy = y2 - y1;
             double dsquared = dx*dx + dy*dy;
             double distance = Math.sqrt (dsquared);         
             return distance; 
     
    } 
    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Saving as HTML?

    You'll want to create a small HTML program that just shows your applet. I'll bet your instructor has given you instructions on how to do this, and if so, I suggest that you review these notes. If not, there are decent tutorials that will show you how.

  3. #3
    Member
    Join Date
    Sep 2012
    Posts
    98
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Saving as HTML?

    This is what I have been given:
    If you want to run the html file, switch to the Files window (Ctrl-z), browse to the build folder.
    Right-click the HelloWorld.html file and choose View. The applet should come up in a browser window. If your browser if blocking content, change the option so that is does not block it. But Ctrl-Z Does nothing in netBeans

Similar Threads

  1. Saving and loading
    By wuppy29 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: June 21st, 2012, 10:38 AM
  2. Problem of saving
    By oluwaseun in forum Java Theory & Questions
    Replies: 2
    Last Post: December 16th, 2010, 03:27 PM
  3. need help with saving data
    By bardd in forum Java Theory & Questions
    Replies: 5
    Last Post: September 19th, 2010, 02:33 PM
  4. saving xml file
    By LOL in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 18th, 2010, 05:45 AM
  5. [SOLVED] Saving A File?
    By MysticDeath in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: August 1st, 2009, 11:56 AM