I am creating a JPanel and setting a layout as follows:
JPanel jpObj= new JPanel();
jpObj.setLayout(new BoxLayout(jpObj, BoxLayout.Y_AXIS));
and then adding a JTextField to my JPanel as follows:
jpObj.add(new JTextField("300000"));
I would like to specify the height of the JTextField without having to write seperate lines of code. For example,
JTextField textField = new JTextField("600000");
textField.setMaximumSize(new Dimension(1000,50) );
jpObj.add(textField);
Is there a way to specify the height of my JTextField while creating its object? The following attempt doesn't seem to work for me.
jpObj.add(new JTextField("300000").setMaximumSize(new Dimension(1000,50)));
Thanks in advance!