-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
1.1.6
-
sparc
-
solaris_2.6
Consider the following java application with two frames and a dialog box associated with frame 1.
import java.awt.*;
import java.awt.event.*;
class Main
implements ActionListener
{
Frame frame1;
Frame frame2;
Dialog dialog;
public static void
main(
String[] args)
{
new Main();
}
Main()
{
// Frame 1
frame1 = new Frame();
frame1.setSize(400, 200);
frame1.setLocation(400, 400);
frame1.setTitle("Frame 1");
frame1.setVisible(true);
// Frame 2
frame2 = new Frame();
frame2.setSize(400, 200);
frame2.setLocation(350, 350);
frame2.setTitle("Frame 2");
MenuBar menuBar = new MenuBar();
frame2.setMenuBar(menuBar);
Menu file = new Menu("File");
menuBar.add(file);
MenuItem item = new MenuItem("Frame 1 To Front");
file.add(item);
item.addActionListener(this);
item = new MenuItem("De-Iconify Frame 1");
file.add(item);
item.addActionListener(this);
frame2.setVisible(true);
// Dialog on Frame 1
dialog = new Dialog(frame1);
//dialog.setModal(true);
dialog.setSize(100, 200);
dialog.setLocation(500, 500);
dialog.setTitle("Dialog");
dialog.setVisible(true);
}
public void
actionPerformed(
ActionEvent e)
{
if ("Frame 1 To Front".equals(e.getActionCommand())) {
frame1.toFront();
}
else {
frame1.setVisible(false);
frame1.setVisible(true);
}
}
}
Compile and run this java application. You should see 2 frames and 1 dialog box. Now iconify the frame 1 and from frame 2's, file menu item, select "deiconify frame 1" and you will see that the dialog box is missing and there is no way to recover the associated dialog box.
import java.awt.*;
import java.awt.event.*;
class Main
implements ActionListener
{
Frame frame1;
Frame frame2;
Dialog dialog;
public static void
main(
String[] args)
{
new Main();
}
Main()
{
// Frame 1
frame1 = new Frame();
frame1.setSize(400, 200);
frame1.setLocation(400, 400);
frame1.setTitle("Frame 1");
frame1.setVisible(true);
// Frame 2
frame2 = new Frame();
frame2.setSize(400, 200);
frame2.setLocation(350, 350);
frame2.setTitle("Frame 2");
MenuBar menuBar = new MenuBar();
frame2.setMenuBar(menuBar);
Menu file = new Menu("File");
menuBar.add(file);
MenuItem item = new MenuItem("Frame 1 To Front");
file.add(item);
item.addActionListener(this);
item = new MenuItem("De-Iconify Frame 1");
file.add(item);
item.addActionListener(this);
frame2.setVisible(true);
// Dialog on Frame 1
dialog = new Dialog(frame1);
//dialog.setModal(true);
dialog.setSize(100, 200);
dialog.setLocation(500, 500);
dialog.setTitle("Dialog");
dialog.setVisible(true);
}
public void
actionPerformed(
ActionEvent e)
{
if ("Frame 1 To Front".equals(e.getActionCommand())) {
frame1.toFront();
}
else {
frame1.setVisible(false);
frame1.setVisible(true);
}
}
}
Compile and run this java application. You should see 2 frames and 1 dialog box. Now iconify the frame 1 and from frame 2's, file menu item, select "deiconify frame 1" and you will see that the dialog box is missing and there is no way to recover the associated dialog box.