Click to See Complete Forum and Search --> : How to display label


zhb11112
May 11th, 2001, 03:44 PM
Hi,
I am a kind of new to java programming.
I have a question.
when I use:

TextField userInputEdit = new TextField("Please input data here.");
userInputEdit.setBounds(80,60,350,30);
gt.add(userInputEdit);



It can display the edit box and text in my window.

But when I use:

Label userInputLabel = new Label("Input");
userInputLabel.setBounds(10,60,50,30);
gt.add(userInputLabel);



the label "Input" does not show.

What's wrong with my code?

Thanks a lot,

hass0002
May 11th, 2001, 05:17 PM
Hi, I don't know what's wrong with your code, but what kind of LayoutManager are you using? That might have something to do with your probelm. I'm not really sure. Another question, if you are new and still learning Java then why don't you start learning Java 2. If you are using an older book, you might want to invest in a new one. If you want you can check out the tutorial at the sun website, that's a good place to start.http://java.sun.com/docs/books/tutorial/?frontpage-spotlight
Ok, hope this helps

zhb11112
May 11th, 2001, 05:31 PM
hi, hass0002
I use setLayout(null);
That's a good java tutorial website.
Thank you.

hass0002
May 15th, 2001, 10:01 PM
I don't know what's wrong with your code, but maybe it could be one of the following:
1 The color of the label text is the same as the background color
2 Your frame is hiding the label, you should make it bigger

Try to use setLayout( new FlowLayout() ) and comment out the setBounds(...)
functions and see if they both show up. If they do
then you know something is wrong with the setBounds(...)
if that's the probelm you should read how that works then try again.