Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Text in certain location in Swing

Status
Not open for further replies.

whodaman

Programmer
May 23, 2001
60
CA
Hi, i've done this before but have spent the last 2 hours trying to find it again. What I am trying to do is display a string in any location (x,y). I am using a Swing applet.

Thank you in advance.
 
To do this you need a panel or frame with no layout manager associated with it. Use setLayoutManager(null) to do this. Then you can just use setLocation(x,y) on each component to place them. "When you have eliminated the impossible, whatever remains, however
improbable, must be the truth." ~ Arthur Conan Doyle
 
For example an JLabel...

Code:
    jLabel1.setBounds(new Rectangle(0, 0, 94, 15));
    jLabel1.setLocation(10,10);
    jPanel1.add(jLabel1, null);
    .
    .
    .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top