JTextField inactive in a JWindow

A

aaronfude

Hi,

In my working application, I changed from a JFrame to a JWindow and my
JTextField's have ceased to be editable.

How do I fix this?

Thanks!

Aaron Fude
 
A

Andrew Thompson

In my working application,
?

..I changed from a JFrame to a JWindow and my
JTextField's have ceased to be editable.

<sscce>
import javax.swing.*;

public class EditableTextFieldTest {
public static void main(String args[]) {
JTextField tf1 = new JTextField("Frame", 20);
JTextField tf2 = new JTextField("Owned Window", 20);
JTextField tf3 = new JTextField("Free Window", 20);

JFrame f = new JFrame(System.getProperty("java.version"));
f.getContentPane().add( tf1 );
f.pack();
f.setLocation(50,50);
f.setVisible(true);

JWindow wO = new JWindow(f);

wO.getContentPane().add( tf2 );
wO.pack();
wO.setLocation(100,100);
wO.setVisible(true);

JWindow wF = new JWindow();

wF.getContentPane().add( tf3 );
wF.pack();
wF.setLocation(150,150);
wF.setVisible(true);
}
}
</sscce>

Andrew T.
 
A

aaronfude

Thanks, that was very insightful!

It doesn't seem to work unless the JFrame is visible and my whole point
of using a JWindow is not no frame is visible and that there's nothing
on the taskbar.

How can *that* be accomplisher?

Thanks!

Aaron Fude
 
A

Andrew Thompson

Thanks, that was very insightful!

No worries..
It doesn't seem to work unless the JFrame is visible and my whole point
of using a JWindow is not no frame is visible and that there's nothing
on the taskbar.

How can *that* be accomplisher?

Well.. fussy, fussy..

<sscce>
import javax.swing.*;

public class EditableTextFieldTest {
public static void main(String args[]) {
JTextField tf1 = new JTextField("Frame", 20);
JTextField tf2 = new JTextField("Owned Window", 20);
JTextField tf3 = new JTextField("Free Window", 20);

JFrame f = new JFrame();
f.getContentPane().add( tf1 );
f.pack();
f.setLocation(-100,-100);
f.setVisible(true);

JWindow wO = new JWindow(f);

wO.getContentPane().add( tf2 );
wO.pack();
wO.setLocation(100,100);
wO.setVisible(true);

JWindow wF = new JWindow();

wF.getContentPane().add( tf3 );
wF.pack();
wF.setLocation(150,150);
wF.setVisible(true);
}
}
</sscce>

;-)

Andrew T.
 
A

aaronfude

Thanks, but this will still cause an application button to appear on
the taskbar in Windows. Is it possible to avoid that? Thanks!
 
T

Thomas Weidenfeller

Thanks, but this will still cause an application button to appear on
the taskbar in Windows. Is it possible to avoid that? Thanks!

Why didn't you specify this requirement in your original posting? We
can't read your mind. Use a JDialog and turn its decoration off.

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,218
Latest member
JolieDenha

Latest Threads

Top