0

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);
5
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by dennysimon
0
textfield.setBounds(x,y,width,height);

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

Edited by harinath_2007: explanation..

0

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

0

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

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.