Hello,

How can I get a bigger textfield?

What I mean is:

Let's say that I'm going to register a bunch of cars in a program I made. I want to register things like name, model, when it's made etc + description.
I can make simple JTextFields for most of them, but JTextField is too small for the description. I want to write at least 3-4 lines about the car. What do I have to create to make a field big enough for description?

I tried something called:

textFieldName.setPreferredSize(new Dimension(integer, integer));

But it's not what I want. It gives me the right size with the right values, but I'd like it to possible to press enter for a new line. How should I do this?

I hope I explained it well, english isn't my native language. If you don't understand, I'll explain it better.

Thanks in advance.

Recommended Answers

All 5 Replies

If you want multiple lines, look at using a text area instead of a text field.

Is it possible to store String values in text area?

Yes.

Thanks man.

Also, I've got one more question. It's kind of offtopic.

Right now my layout is like:

Label, textfield, label, textfield, label
textfield, label, textfield, 
label, textfield, label
textfield, button
button

What I want is it to be like:

Label textfield
Label Textfield
Label Textfield
...
Button1, Button 2

How should I do this? I've no experience about layouts, I've just used FlowLayout, very simple one, and my program was always unstructured. Now I need more structur D:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.