Results 1 to 2 of 2
  1. #1
    RaefWolfe is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default Converting an Application to an Applet in NetBeans

    I apologize if this has been asked or answered before, but I didn't find anything in the searches I performed, and the NetBeans website hasn't got this answer up to date for its latest release that I've seen.

    I've got a code I wrote in NetBeans that takes 5 numbers from the user, takes another 5 numbers from the user, and finds the ratio between the two groups of five. I'll include the code below, but it's probably not necessary.

    My question is, how can I take my NetBeans application and turn it into an applet? None of the instructions online make any sense to me, being new to Java, and the NetBeans website has the tutorial for NetBeans 4.0, but not 6.5 or any equivalent (which I am running).

    Can anyone point me in the right direction either regarding how to do this in NetBeans or an *easy* instruction on how to convert my code over?

    Alternatively, if there is a way to put it online without making it without making it an applet, let me know. I'm all ears! :)

    Java Code:
    package capratio;
    
    /**
     *
     * @author Jennifer
     * Made for Green Iguana Society: greenigsociety.org
     * Calculates Calcium to Phosphorous ratios in food for proper diet and feeding
     *
     */
    
    import java.util.Scanner;
    
    public class Main {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            Scanner inputScanner = new Scanner(System.in);
            double canum;
            double canum2;
            double canum3;
            double canum4;
            double canum5;
            double pnum;
            double pnum2;
            double pnum3;
            double pnum4;
            double pnum5;
    
            System.out.println("You may enter up to 5 separate calcium and phosphorus amounts. If you wish to enter less than 5, then type in 0 as the amount.");
    
            System.out.println("Please enter a Calcium amount: ");
            canum = inputScanner.nextDouble();
            System.out.println("Please enter a Calcium amount: ");
            canum2 = inputScanner.nextDouble();
            System.out.println("Please enter a Calcium amount: ");
            canum3 = inputScanner.nextDouble();
            System.out.println("Please enter a Calcium amount: ");
            canum4 = inputScanner.nextDouble();
            System.out.println("Please enter a Calcium amount: ");
            canum5 = inputScanner.nextDouble();
    
            double canswer = canum + canum2 + canum3 + canum4 + canum5;
            System.out.println("You have this much Calcium: " + canswer);
    
            System.out.println("Please enter a Phosphorus amount: ");
            pnum = inputScanner.nextDouble();
            System.out.println("Please enter a Phosphorus amount: ");
            pnum2 = inputScanner.nextDouble();
            System.out.println("Please enter a Phosphorus amount: ");
            pnum3 = inputScanner.nextDouble();
            System.out.println("Please enter a Phosphorus amount: ");
            pnum4 = inputScanner.nextDouble();
            System.out.println("Please enter a Phosphorus amount: ");
            pnum5 = inputScanner.nextDouble();
    
            double panswer = pnum + pnum2 + pnum3 + pnum4 + pnum5;
            System.out.println("You have this much Phosphorous: " + panswer);
    
            double tanswer = canswer / panswer;
            System.out.println("You have this much more Calcium than Phosphorous: " + tanswer);
            System.out.println("This is the 'Ca' part of your 'Ca:P' ratio. Adjust your Ca and P as needed to get it to exactly 2.");
    
    
        }
    
    }

  2. #2
    markdc is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default

    Applets don't really work with console input as they are in a web browser.

    You will need to create a user interface.

    I suggest creating a class that extends JPanel and then create a textfield and command button on that panel. Then create a class that extends JApplet and call your JPanel instance from there.

Similar Threads

  1. connecting a java application to a DB in netbeans
    By kulangotski in forum Advanced Java
    Replies: 4
    Last Post: 03-22-2009, 09:58 AM
  2. Converting an App to Applet
    By josephdcoleman in forum New To Java
    Replies: 1
    Last Post: 02-21-2009, 07:07 AM
  3. Converting netbeans app to applet
    By paulious in forum New To Java
    Replies: 3
    Last Post: 10-23-2008, 11:25 AM
  4. Replies: 0
    Last Post: 07-30-2007, 11:13 PM
  5. Replies: 1
    Last Post: 07-06-2007, 05:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •