Announcement

Collapse
No announcement yet.

Java applet help...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java applet help...

    can any1 help me i am trying to get this to run as a java applet and i am having a lot of trouble:

    Code:
    import java.awt.Graphics;       // program uses class Graphics
    import javax.swing.JApplet;     // program uses class JApplet
    import javax.swing.JOptionPane; // program uses class JOptionPane
            
    public class Converter extends JApplet 
        {
    String output;
    String degreesResult = null;
     
    public static final double PI = 3.14;
     
    public void init()
        {
    double celsius;
    double temperature = 0;
     
    for (int x=0; x < 3; x++)
    {    
        celsius = 5*(temperature - 32)/9;
        degreesResult+=output.format("%d degrees farenheit = %.2f celsius.\n", temperature, celsius);    
        temperature += 1;
    }
     
        }
     
    public void paint( Graphics g )
        {
        super.paint( g ); // call superclass version of method paint
              
        g.drawString( output , 500, 300 );
        
     
     } // end method paint
    } // end class
    2002 Mitsubishi Galant
    Progress: 90% [-▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓- ->

    Carputer Specs:
    Via M10K
    512mb Ram
    60GB HDD
    Souund Blaster Audigy2 NX
    OPUS ITX PC Case


  • #2
    I edited the program a bit but it still doesnt output any data im so confused....anybody?

    Code:
    import java.awt.Graphics;       
    import javax.swing.JApplet;     
    import javax.swing.JOptionPane; 
    		
    public class Converter extends JApplet 
    	{
    
    String outputStr;
    
    public void init()
    	{
    double celsius;
    double temperature = 0;   
    String degreeResult;          
    
    
          
    for (int x=0; x < 3; x++)
    {   
        celsius = 5.*(temperature - 32.0)/9.0;
         degreeResult =
             outputStr.format("%d degrees farenheit = %.2f celsius.\n", temperature, celsius);	
    	temperature += 1;
    }                                         
    
    outputStr = degreeResult;
    
    	}
    	
    public void paint( Graphics g )
    	{
    		
    	super.paint( g );  
    	g.drawString( outputStr , 500, 300 );
    
    
     } 
    }
    2002 Mitsubishi Galant
    Progress: 90% [-▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓- ->

    Carputer Specs:
    Via M10K
    512mb Ram
    60GB HDD
    Souund Blaster Audigy2 NX
    OPUS ITX PC Case

    Comment

    Working...
    X