Solved

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

Posted on 2004-10-03
8
193 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

932 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now