I have a Jwindow, and when I added a Jtextfield to it, the textfield became uneditable.
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 Jwindow’s owner, the textfield was now editable, but the frame showed up together with the 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 JTextField is uneditable in JWindow and how could I make it editable?
- What is the main purpose of using JFrame as JWindow’s border?
EDIT,
contents of
JWindowis accesible only if its parent is displayed on the screenfor editable and accesible contents use un_decorated
JDialoginstead ofJWindow, jDialog doesn’t caused non_accesible contents,reason why …, I can’t explain, not undestand why, no way in this moment, the API says me nothing about caused accesible, editable …
.
.
.
really don’t know
EDIT
by default JWindow required JFrame for correct workaround
nobody tell that this JFrame must be visible (valid for GUI), then remove these code lines from
frame.setDefaultClose…. includingframe.setVisible(true);from my examplein this form current JVM instance never gone from RAM, untill your PC restarted or swith off, you have to add separated exit
JButtonwith code lineSystem.exit(0)insideActionListener