Help me!!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Help me!!!

  1. #1
    Join Date
    Sep 2003
    Posts
    1

    Help me!!!

    I am trying to create an applet to look like the following, but I am stumped. I am new to this and not sure where to turn.

    Number Square Cube
    0 0 0
    1 1 1
    2 4 8

    This is what I have and all I get is errors:
    Code:
    // java packages
    import java.awt.Graphics;
    import javax.swing.JApplet;
    
        public class A3_3 extends JApplet {
    
              double one = 1;
    
    	 public void init()
    
    	 {
    
    
    	 public void paint( Graphics g )
    	 {
     
    	  super.paint( g );  
                
                      g.drawString( "Number","Square","Cube", 0, 25 );
    
    	  g.drawString(one, one * one, one * one* one,  0, 25 );
    
    
    	System.exit( 0 );
    	}
    }
    [Archangel added CODE tags]

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    Use JLabels - they're easier.
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Oct 2003
    Posts
    9

    Errors

    What errors? With the drawString? Unless I'm mistaken, drawString should just take one text argument, so why not try:

    g.drawString( "Number, Square, Cube", 0, 25 );
    g.drawString(one+" "+one * one+" "+one * one * one, 0, 25 );

    You'll really need a loop to do three lines, incrementing the y positon to draw each time.

    Ralpharama.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center