-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.1.6, 1.1.8_003, 1.2.0, 1.2.2, 1.3.0
-
generic
-
generic, solaris_2.5
The windowDeactivated() never called for java.awt.Window objects. Try the attached example.
1. compile it.
2. run it.
3. shows a frame with "Show/Hide" button, click on it.
4. Click on it.
5. A window appears. Click on it.
6. The "Frame deactivated" message on stdout.
7. No "Window Activated" message on stdout.
Now comment the lines which declare JWindow and uncomment lines which declare JDialog. Now -
1. compile it.
2. run it.
3. shows a frame with "Show/Hide" button, click on it.
4. Click on it.
5. A dialog appears. Click on it.
6. The "Frame deactivated" message on stdout.
7. The "Window Activated" message on stdout.
This proves that WINDOW_ACTIVATED and WINDOW_DEACTIVATED events are not generated for java.awt.Window objects but is generated for Frame and Dialog
subclasses. Here is the snippet from API Javadoc -
windowActivated
public abstract void windowActivated(WindowEvent e)
Invoked when a window is activated.
windowDeactivated
public abstract void windowDeactivated(WindowEvent e)
Invoked when a window is de-activated.
My java -version yields -
java version "1.1.6"
Here is the attached source -
/*
* foo.java "%I,%G"
*
* Author: Sandip Chitale (###@###.###)
*/
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
/**
*
* The class <code>foo</code>
* For example:
* <pre>
* </pre>
*
* @author Sandip Chitale (###@###.###)
* @version "%I,%G"
* @since
* @see
*
*/
public class foo extends JFrame
{
private JWindow w;
//Comment above line and uncomment the following line to try with JDialog
//private JDialog w;
/**
*
* This constructor <code>foo()</code>
*
* @param
*
* @see
*
*/
public foo()
{
super("foo");
addWindowListener(new WindowAdapter()
{
public void windowActivated(WindowEvent we)
{
System.out.println("Frame Activated");
}
public void windowDeactivated(WindowEvent we)
{
System.out.println("Frame Deactivated");
}
}
);
w = new JWindow(this);
//Comment above line and uncomment the following line to try with JDialog
//w = new JDialog(this, "Dialog", false);
Container cp = w.getContentPane();
cp.add(new JTextField("Click here"), BorderLayout.CENTER);
w.pack();
w.addWindowListener(new WindowAdapter()
{
public void windowActivated(WindowEvent we)
{
System.out.println("Window Activated");
}
public void windowDeactivated(WindowEvent we)
{
System.out.println("Window Deactivated");
}
}
);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
cp = getContentPane();
JButton b = new JButton("Show/Hide");
cp.add(b, BorderLayout.CENTER);
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
w.setVisible(!w.isVisible());
}
}
);
pack();
setVisible(true);
}
/**
* This method
*
* @return
* @param
*
* @see
*
*/
public static void main(String args[])
{
foo f = new foo();
}
}
Name: krT82822 Date: 10/09/99
the java.awt.Window object only generates windowOpened and windowClosed... but nothing else.
this is the blurb from the JavaDocs:
"Windows are capable of generating the following window events: WindowOpened, WindowClosed. "
At the very least, it should get activated and deactivated... java.awt.Window is the only component of its type that doesn't show a title bar, and so tends to become a work-horse of may applications.
(Review ID: 39818)
======================================================================
1. compile it.
2. run it.
3. shows a frame with "Show/Hide" button, click on it.
4. Click on it.
5. A window appears. Click on it.
6. The "Frame deactivated" message on stdout.
7. No "Window Activated" message on stdout.
Now comment the lines which declare JWindow and uncomment lines which declare JDialog. Now -
1. compile it.
2. run it.
3. shows a frame with "Show/Hide" button, click on it.
4. Click on it.
5. A dialog appears. Click on it.
6. The "Frame deactivated" message on stdout.
7. The "Window Activated" message on stdout.
This proves that WINDOW_ACTIVATED and WINDOW_DEACTIVATED events are not generated for java.awt.Window objects but is generated for Frame and Dialog
subclasses. Here is the snippet from API Javadoc -
windowActivated
public abstract void windowActivated(WindowEvent e)
Invoked when a window is activated.
windowDeactivated
public abstract void windowDeactivated(WindowEvent e)
Invoked when a window is de-activated.
My java -version yields -
java version "1.1.6"
Here is the attached source -
/*
* foo.java "%I,%G"
*
* Author: Sandip Chitale (###@###.###)
*/
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
/**
*
* The class <code>foo</code>
* For example:
* <pre>
* </pre>
*
* @author Sandip Chitale (###@###.###)
* @version "%I,%G"
* @since
* @see
*
*/
public class foo extends JFrame
{
private JWindow w;
//Comment above line and uncomment the following line to try with JDialog
//private JDialog w;
/**
*
* This constructor <code>foo()</code>
*
* @param
*
* @see
*
*/
public foo()
{
super("foo");
addWindowListener(new WindowAdapter()
{
public void windowActivated(WindowEvent we)
{
System.out.println("Frame Activated");
}
public void windowDeactivated(WindowEvent we)
{
System.out.println("Frame Deactivated");
}
}
);
w = new JWindow(this);
//Comment above line and uncomment the following line to try with JDialog
//w = new JDialog(this, "Dialog", false);
Container cp = w.getContentPane();
cp.add(new JTextField("Click here"), BorderLayout.CENTER);
w.pack();
w.addWindowListener(new WindowAdapter()
{
public void windowActivated(WindowEvent we)
{
System.out.println("Window Activated");
}
public void windowDeactivated(WindowEvent we)
{
System.out.println("Window Deactivated");
}
}
);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
cp = getContentPane();
JButton b = new JButton("Show/Hide");
cp.add(b, BorderLayout.CENTER);
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
w.setVisible(!w.isVisible());
}
}
);
pack();
setVisible(true);
}
/**
* This method
*
* @return
* @param
*
* @see
*
*/
public static void main(String args[])
{
foo f = new foo();
}
}
Name: krT82822 Date: 10/09/99
the java.awt.Window object only generates windowOpened and windowClosed... but nothing else.
this is the blurb from the JavaDocs:
"Windows are capable of generating the following window events: WindowOpened, WindowClosed. "
At the very least, it should get activated and deactivated... java.awt.Window is the only component of its type that doesn't show a title bar, and so tends to become a work-horse of may applications.
(Review ID: 39818)
======================================================================