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

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));

Recommended Answers

All 6 Replies


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

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 ()


Member Avatar
myTextField.setFont (myLargeFont);

Hi all

thank you for all inputs
I try which will fit my need

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.