Joe Rud
asked on
Newbie Java Applet help
Good day Experts.
So I just started taking a Java class (no pun intended).
Instructor gave us an assignment to write an applet based on Hello World program (see attached code). Need to output information like Name, college, age - each on their own line.
Question is, if g.drawString puts everything on one line, what's the command to go to the next line?
So I just started taking a Java class (no pun intended).
Instructor gave us an assignment to write an applet based on Hello World program (see attached code). Need to output information like Name, college, age - each on their own line.
Question is, if g.drawString puts everything on one line, what's the command to go to the next line?
/* FILE: Applet1.java */
/* A Java applet. */
import java.awt.Graphics;
import java.applet.Applet;
public class Applet1 extends Applet {
public void paint( Graphics g )
{
g.drawString("Hello World!", 25, 25);
}
}
<!-- FILE: Applet1.html -->
<html>
<applet code="Applet1.class" width=275 height=125>
</applet>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In comparison to say
System.out.println(String) command
with darwString you have much more flexibility - you can even print
one on top of another or with minimal itervals, etc, etc
On the other hand you should take care of all formatting in your code
System.out.println(String)
with darwString you have much more flexibility - you can even print
one on top of another or with minimal itervals, etc, etc
On the other hand you should take care of all formatting in your code
value x is number of pixels counted horizontally form the left border of your
component where you are drawing
value y is counted vertically from the top borde
so ig you have
g.drawString("Name", 25, 50)
g.darwString("Address",25,
you'll see Address start just below the plcae where "Name" starts
so next string
g.drawSring("Phone", 25, 90);
will be one line lowere