I have a Jwindow, and when I added a Jtextfield to it, the text field became unedited.
JWindow window = new JWindow(); window.setBounds(400, 100, 700,500); window.setVisible(true); window.setLayout(null); JTextField text = new JTextField(); text.setBounds(300, 300, 150, 30); text.setEditable(true); window.getContentPane().add(text);
But when I tried to use Jframe as the owner of Jwindow, the text box was now edited, but the frame appeared along with jwindow:
JFrame frame = new JFrame(); frame.setVisible(true); JWindow window = new JWindow(); window.setBounds(400, 100, 700,500); window.setVisible(true); window.setLayout(null); JTextField text = new JTextField(); text.setBounds(300, 300, 150, 30); text.setEditable(true); window.getContentPane().add(text);
So, I have 2 questions:
- Why is JTextField invalid in JWindow and how can I make it editable?
- What is the main purpose of using a JFrame as the border of a JWindow?
source share