• Post Reply Bookmark Topic Watch Topic
  • New Topic

minor layout problem

 
Randall Twede
Ranch Hand
Posts: 4519
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am creating some custom dialogs here is what i have for the Find dialog

it looks almost right except the JTextField doesn't display correctly(it is a couple of pixels wide).
this other code displayed the JTextArea more correctly, but is not quite what i want.
what happened to the JTextField?
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it looks almost right except the JTextField doesn't display correctly(it is a couple of pixels wide).


That is the preferred size of the text field.

You need to give the text field more information so it can calculate a better preferred size:



Same with a JTextArea, you would specify the row/columns when you create an instance of the text area.



Don't use strings to specify the contstraint. All layout managers have member variables that should be used (ie. BorderLayout.WEST);

Read the Swing tutorial for the basics of using Swing.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have not defined the number of columns in the JTextField !
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Too slow again!
 
Randall Twede
Ranch Hand
Posts: 4519
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. i guess it looked right when i used the grid layout because it was told to be bigger.
Don't use strings to specify the contstraint. All layout managers have member variables that should be used (ie. BorderLayout.WEST);

copied and pasted from some really old code(kind of like color BLACK, black, Black. many ways it will work). i will change it.

it turns out that new JTextField(17) is the magic number that makes my dialog look just like Wordpad's.
i notice that when i call pack() there is no need to setSize()

well, my find and replace dialogs look good. now comes the fun part: making them work
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!