Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField size  RSS feed

 
Juhan Voolaid
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have GridLayout and on one cell there is a JTextField. This textfield seems to be as big as the size of the cell.

How can i make it smaller? I tried the setPreferredSize() it didn't work and the columns integer at the constructor didn't reduce the size also.
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this

 
Juhan Voolaid
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see how that is going to help me.
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do this -

JPanel jp = new JPanel(new FlowLayout());
jp.add(jtextfield1); //jtextfield1 is the JTextField Object
gridlayout.add(jp); //not jtextfield, see the diffrence.

This will give a normal sized text field.
 
Juhan Voolaid
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx ... that did the trick
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!