Solved

print a number (string) in a Frame ...

Posted on 2004-10-03
8
228 Views
Last Modified: 2010-03-31
Hi Experts,

   How do I print a number (or a string) at a certain location of a frame ? thanks !
0
Comment
Question by:meow00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 50 total points
ID: 12210793
Do it in a panel *in* a frame. Override paintComponent

public void paintComponent(Graphics g) {
    g.drawString("hello", x, y);
}
0
 
LVL 92

Expert Comment

by:objects
ID: 12210798
use a null layout and add a Lael at the required location.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12210802
(assuming Swing)
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 92

Expert Comment

by:objects
ID: 12210811

Label l = new Label("Hello");
frame.setLayout(null);
frame.add(l);
label.setBounds(x, y, w, h);
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 12210824
for swing:

JLabel l = new JLabel("Hello");
frame.setLayout(null);
frame.getContentPane().add(l);
label.setBounds(x, y, w, h);
0
 
LVL 3

Expert Comment

by:CI-Ia0s
ID: 12211243
objects: wouldn't you set the layout of the content pane to null in the swing example?

i.e.:
frame.getContentPane().setLayout(null);
0
 
LVL 92

Expert Comment

by:objects
ID: 12213830
> objects: wouldn't you set the layout of the content pane to null in the swing example?

correct, missed that when showing the swing difference.
0
 
LVL 3

Expert Comment

by:CI-Ia0s
ID: 12213859
Ok, good. I don't feel so confused any more. ;)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question