GridBagLayout and JTextField

M

me

I'm attempting to place a textfield, using GridBagLayout. The syntax
I'm using is

addComp(jtf, gbLayout, gbConstraints, 0, 0, 1, 4, 0, 0);

with 'jtf' being the textfield. Its my understanding that this should
create the textfield, in row 0, column 0, with a height of 1 row, and
a width of 4 columns. When run, this creates a textfield that is in
the center of row 0, but is of a massively compressed size.(The two
end lines and a sliver of white) Strangely, when the same syntax is
used to place a JLabel in the same place, it works fine, with the
label spanning the whole width that it should. I've attempted to
change the size of the JTextField when its created, but to no avail,
even when its set to a wider width than exists in the frame. Any
suggestions on why this is, or how to get around this issue??

Sorry if this double posted, the news server I'm on seems screwy
tonight.

Mark
 
I

Ike

you need to give it a starting size (in chars, of the default Font I
believe), e.g.
myJTextField = new JTextField(6);
I believe,. from your description, you are just creating a new
JTextField();

//-Ike
 
S

Sudsy

me said:
I'm attempting to place a textfield, using GridBagLayout. The syntax
I'm using is

addComp(jtf, gbLayout, gbConstraints, 0, 0, 1, 4, 0, 0);

with 'jtf' being the textfield. Its my understanding that this should
create the textfield, in row 0, column 0, with a height of 1 row, and
a width of 4 columns.

Without the source for addComp, we wouldn't know what it's supposed
to do. I don't even see where you add the component to the container.
While I applaud your effort to reduce the problem to the essentials,
we're missing a few of those essentials.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top