I created a class by extending JPanel. The idea is to combine a JLabel and a JTextField and simply return a text field with a label already attached. The duo would live inside of a small JPanel. I'm having trouble settin the size of the JPanel so that it is only as large as the JLabel/JTextField combo. I know some of the layout managers override sizing. Is there one that will allow me to explicitly set the size of this little JPanel and not allow the JPanel I put it in to resize it?
FlowLayout will always use the preferred size of a component. BorderLayout will use the preferred size in the North, South, East, and West areas, but not in the center. GridBayLayout will use the preferred size, as long you set the fill property to none. BoxLayout will use either preferred height or width, depending on which alignment you set. You can find out more about layout managers at the Sun Swing tutorial.