Link to home
Start Free TrialLog in
Avatar of djmajiktc
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
ASKER CERTIFIED SOLUTION
Avatar of mzimmer74
mzimmer74

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you don't need to add the label, you can do something like this:

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