Archie K Archie K - 13 days ago 5
Java Question

Text besides a JTextField

So I need to develop a login application where you'd have;

Username [JTextField]
Password [JTextField]
My question is; how can I put text adjacent to the JTextField? Would I use a JLabel?

What layout manager should I use? (Baring in mind I've looked at documentation and can't make my mind up).

Thank you in advance.

Answer

Maybe you should consider using JavaFx if it is available. The reason why is because there is something called SceneBuilder that lets you drag and drop different items onto the pane that you are creating.

If you wanted to use swing your best bet would be to use a JLabel, and then the JTextField next to the said JLabel. Honestly, I think javafx is much easier to use, and if you are considering using it I would watch these tutorials: https://www.youtube.com/watch?v=FLkOX4Eez6o Best of luck! :)