Solved

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

Posted on 2004-10-03
8
185 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unable to open debugger port in Intellij idea 6 88
groupSum6 challenge 6 45
topping2 challenge 13 61
topping3 challenge 14 51
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

762 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

20 Experts available now in Live!

Get 1:1 Help Now