Hello, I use a JPanel to draw all my graphics and I need to get some user input so I thought that I should add a JTextField.
I have tried to add the JTextField but it just wont show up:
//snip this.setVisible(true); this.setFocusable(true); this.setSize(800, 480); this.addMouseListener(new MouseListener()); this.addMouseMotionListener(new MouseListener()); this.addKeyListener(new KeyboardListener()); this.setLayout(new BorderLayout()); JTextField text = new JTextField(); text.setVisible(true); text.setPreferredSize(new Dimension(40, 20)); this.add(text); //snip
Also I have tried to attach it to my JFrame as well and whenever I try to resize the frame, I can see the JTextField but it fills the entire JFrame.