Solved

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

Posted on 2004-10-03
8
222 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
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!

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Title # Comments Views Activity
eclipse buid path vs tomcat lib path 10 49
difference between sorce folder and folder in eclipise 3 65
Java Eclipse Loop 3 50
Setup GlassFish 4 57
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…
Suggested Courses

710 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