Field.java
import java.awt.Color;
import java.awt.Graphics;
public class Field
{
private int x,y,width, height;
public Field(int x, int y, int width, int height){
this.x=x;
this.y=y;
this.width=width;
this.height=height;
}
public void draw(Graphics g){
g.setColor(Color.GREEN);
g.fillRect(x, y, width, height);
}
}
FieldTester
import java.applet.Applet;
import java.awt.Graphics;
import javax.swing.JOptionPane;
public class FieldTester extends Applet {
private String name;
public void init()
{
name = JOptionPane.showInputDialog("Team Name? ");
}
public void paint(Graphics g)
{
g.drawString(name,20, 20);
Field f=new Field(50,50, 300, 200);
f.draw(g);
}
}