djmajiktc
asked on
Adding a Label
How do I specify explicitly where I can add a label?
For example, if I have an applet 300x500, how can I put it at 150, 300
For example, if I have an applet 300x500, how can I put it at 150, 300
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
public class MsgTest extends java.applet.Applet {
private String msg;
public void init()
{
msg = "This should go at 150, 300";
}
public void paint(Graphics g) {
if (msg != null && !msg.trim().equals("")) {
g.drawString(msg, 150, 300);
}
}
}
All you have to do is set msg to null or "" and call repaint() to make it go away