-
Bug
-
Resolution: Fixed
-
P3
-
1.2.2, 1.3.0, 1.4.0
-
beta2
-
x86, sparc
-
linux, solaris_2.6, windows_2000
Name: dsR10051 Date: 02/26/2001
If one disposes JFrame containing drugged out JToolBar then JToolBar is
not disposed with JFrame and, therefore, still remains on the screen. This
behavior is incorrect since the orphan window is useless.
Here is a minimized test:
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
public class ToolBarExample extends JPanel {
public static void main(String s[]) {
JToolBar toolBar = new JToolBar();
toolBar.setOrientation(1);
toolBar.setPreferredSize(new Dimension(100,50));
JFrame frame = new JFrame("ToolBar Example");
frame.getContentPane().add(toolBar, BorderLayout.WEST);
frame.setSize(new Dimension(150, 95));
frame.pack();
frame.setVisible(true);
System.out.println("Drag please");
try {
Thread.sleep(20000);
} catch (Exception eee) {
}
System.out.println("frame dispose");
frame.dispose();
}
}
Drug out toolBar to separate window and wait for frame is disposed.
======================================================================
Name: yyT116575 Date: 04/30/2001
java version "1.3.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)
Source code for the reproduction of this bug follows. To reproduce, do the
following:
1. Run the application.
2. Drag the toolbar so that it floats in a separate window.
3. Close the main window (not the toolbar window). The toolbar window remains open.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
*
*/
public class TestPersistentToolbar {
public static void main(String[] args) {
openWindow();
}
public static void openWindow() {
JToolBar tb = new JToolBar();
JButton b = new JButton("Open Another");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
openWindow();
}
});
tb.add(b);
JButton b2 = new JButton("Exit Application");
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
});
tb.add(b2);
JFrame f = new JFrame();
f.setSize(400, 400);
f.getContentPane().add(tb, BorderLayout.NORTH);
f.setVisible(true);
}
}
(Review ID: 123502)
======================================================================
- duplicates
-
JDK-4311462 unix: Undocked JToolBar does not check parent window state.
- Closed
- relates to
-
JDK-6328598 JToolbar wrong width when detached from left/right side
- Open
-
JDK-4231629 Floating toolbar incorrectly placed in JFrame on Windows
- Resolved