Question

I have the following JTextField where I would like to change the cursor position from the middle to the TOP of the JTextField:

How do I accomplish that?

Was it helpful?

Solution

There is no such thing as a multi-line JTextField. What you posted is a regular, single-line JTextField which is simply stretched out.

If you need mutli-line text components, consider using a JTextArea or JTextPane in which you can perfectly set the cursor (caret) at the first line

Edit

Just read your comment. An editable textfield for output is just confusing to the user. At least make it non-editable, or opt for a JLabel with a Border

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top