I have a JTextField with rather big bounds, the text however does not behave like I want it to.
_________________
| |
| |
|text |
| |
|_________________|
how would i do it so my text aligns like this
_________________
|text |
| |
| |
| |
|_________________|
Edit:
Using JTextArea
fixed my problem. Thank you.
Just use the setBounds attribute. Jtextfield. setBounds(x,x,x,x);
The class JTextField is a component that allows editing of a single line of text.
JTextArea
aligns to the top.
Or use a JLabel
:
JLabel myLabel = new JLabel("my text");
and the call:
myLabel.setHorizontalAlignment(SwingConstants.LEFT);
myLabel.setVerticalAlignment(SwingConstants.TOP);
Layout managers is the another way of doing this: http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With