java - input help
Author |
Message |
kunal445
|
Posted: Wed Feb 15, 2012 9:03 pm Post subject: java - input help |
|
|
our teacher told us to make a java program which allows you to put in names of 3 sports teams and the sports they play in a graphical form.
this is what i have done so far but i don't know how to put the in put in the rectangle.
* we're using "Ready to Program" to create this can someone please help?
----
// The "Ass_6_3_Kunal" class.
import java.awt.*;
import hsa.Console;
public class Ass_6_3_Kunal
{
static Console c; // The output console
public static void main (String[] args)
{
c = new Console ();
String n1,n2,n3,s1,s2,s3;
c.drawRect (25,25,400,200);// whole box
c.drawRect (25,25,400,100);// cuts it in 2 horozontally
c.drawRect (25,25,100,200);// 1st cut vertically
c.drawRect (25,25,200,200);// 2nd cut vertically
c.drawRect (25,25,300,200);// 3rd cut vertically
// lines for titles
c.drawString("team",75,75);
c.drawString("sport",75,175);
// lines for team and sport strings
c.drawString("1",175,75);
c.drawString ("2",275,75);
c.drawString ("3",375,75);
c.drawString ("team 1's sport",140,175);
c.drawString ("team 2's sport",240,175);
c.drawString("team 3's sport",340,175);
// input lines
n1 = c.readLine ();
n2 = c.readLine ();
n3 = c.readLine ();
s1 = c.readLine ();
s2 = c.readLine ();
s3 = c.readLine ();
// Place your program here. 'c' is the output console
} // main method
} // Ass_6_3_Kunal class
---- |
|
|
|
|
|
Sponsor Sponsor
|
|
|
ihsh
|
Posted: Wed Feb 15, 2012 10:15 pm Post subject: Re: java - input help |
|
|
Don't you just do
Java: |
c.drawString(s3,340,175);
|
instead of
Java: |
c.drawString("Team 3's sport",340,175);
|
?
If you're worried about centering your text in those boxes, then it might actually be easier to use c.print (), since every character has the same width if you use that method. |
|
|
|
|
|
kunal445
|
Posted: Wed Feb 15, 2012 11:05 pm Post subject: Re: java - input help |
|
|
yes thx i can do that too but i was wondering if its possible to directly get the input to be placed in that spot |
|
|
|
|
|
|
|