Solved

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

Posted on 2004-10-03
8
212 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
  • 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

830 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