I want to add a JTextfield
to my JPanel
. I am overriding the paint method and doing some drawing, because its a game.
If I am adding the JTextField
it is not visible. If I know the position, I can click on it and I can even add some text, but the JTextField
is flickering.
Is there any solution, that I can add a JTextField
to my JPanel
over the paint layer, so that is every time visible?
EDIT:
If you override paintComponent instead of paint, everything is working and you can simply add an JTextField
. Thanks to trashgod.
Click anywhere on this AnimationTest
to add a text field. Note the use of invokeLater()
and the call to super.paintComponent(g)
. Resize the frame to see how the default layout works.