hello all

I create a Jpanel ,with TextField For name and password.
My question is how to increase My TextField Height,is is veri short ,I need to increase to 300 % of it's now 's height

I include partial code below
thanks
denny

JLabel lblnama=new JLabel("NAME");
	  JLabel lblpassword=new JLabel("PASSWORD");
	  JTextField tfnama=new JTextField(20);
	  JPasswordField tpwf=new JPasswordField(20);
	  
	  JPanel lbltextpanel = new JPanel();
      lbltextpanel.setLayout(new GridLayout(2,2,4,4));
	  
      lbltextpanel.add(lblnama);
	  
	  lbltextpanel.add(tfnama);
	  lbltextpanel.add(lblpassword);
	  lbltextpanel.add(tpwf);
textfield.setBounds(x,y,width,height);

where
x - new x-coordinate
y - new y-coordinate
width- width of textfield
height- Your desired height

Edited 5 Years Ago by harinath_2007: explanation..

The irritating part if we use setbounds is that we need to spend time to make it look how we want it to be by applying trial-error method

Yes, setBounds is useless when you are using a layout manager. You can use setPreferredSize, setMinimumSize, setMaximumSize and, depending on your layout manager and how all the components are defined, the layout manager will do its best to comply

all of Swing JComponents can returns PreferredSize by default, or you can help them by usingfor example

JTextField myTextField =  new JTextField(15)
JTextArea myTextArea = new JTextArea (20, 5)
JComboBox myComboBox  = new JComboBox ()
myComboBox.setPrototypeDisplayValue("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

;

This question has already been answered. Start a new discussion instead.