JDK-4231629 : Floating toolbar incorrectly placed in JFrame on Windows
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.6,1.2.0,1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    generic,other,solaris_2.6,windows_nt generic,other,solaris_2.6,windows_nt
  • CPU: generic,other,x86,sparc
  • Submitted: 1999-04-21
  • Updated: 2001-05-09
  • Resolved: 2001-05-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
In the Windows implementation of Swing, a floating toolbar is placed in a JFrame container complete with maximize and minimize buttons. Instead, it should be placed in a JDialog container, with only a close button. (The Solaris implementation has the proper behavior.)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
24-08-2004

SUGGESTED FIX ------- BasicToolBarUI.java ------- *** /tmp/d03GZ7d Tue Sep 5 10:51:36 2000 --- BasicToolBarUI.java Mon Sep 4 17:56:42 2000 *************** *** 48,54 **** private boolean floating; private int floatingX; private int floatingY; ! private JFrame floatingFrame; protected DragWindow dragWindow; private Container dockingSource; private int dockingSensitivity = 0; --- 48,54 ---- private boolean floating; private int floatingX; private int floatingY; ! private JDialog floatingToolBar; protected DragWindow dragWindow; private Container dockingSource; private int dockingSensitivity = 0; *************** *** 65,70 **** --- 65,72 ---- protected ContainerListener toolBarContListener; protected FocusListener toolBarFocusListener; + protected String constraintBeforeFloating = "BorderLayout.NORTH"; + // Rollover button implementation. private static String IS_ROLLOVER = "JToolBar.isRollover"; private Border rolloverBorder; *************** *** 134,140 **** dockingSensitivity = 0; floating = false; floatingX = floatingY = 0; ! floatingFrame = null; setOrientation( toolBar.getOrientation() ); c.setOpaque(true); --- 136,142 ---- dockingSensitivity = 0; floating = false; floatingX = floatingY = 0; ! floatingToolBar = null; setOrientation( toolBar.getOrientation() ); c.setOpaque(true); *************** *** 158,164 **** if (isFloating() == true) setFloating(false, null); ! floatingFrame = null; dragWindow = null; dockingSource = null; --- 160,166 ---- if (isFloating() == true) setFloating(false, null); ! floatingToolBar = null; dragWindow = null; dockingSource = null; *************** *** 414,429 **** return UIManager.getBorder("Button.border"); } ! protected JFrame createFloatingFrame(JToolBar toolbar) { ! JFrame frame = new JFrame(toolbar.getName()); ! frame.setResizable(false); WindowListener wl = createFrameListener(); ! frame.addWindowListener(wl); ! return frame; } protected DragWindow createDragWindow(JToolBar toolbar) { ! Frame frame = null; if(toolBar != null) { Container p; for(p = toolBar.getParent() ; p != null && !(p instanceof Frame) ; --- 416,432 ---- return UIManager.getBorder("Button.border"); } ! protected JDialog createFloatingFrame(JToolBar toolbar) { ! JDialog dialog = new JDialog(); ! dialog.setTitle(toolbar.getName()); ! dialog.setResizable(false); WindowListener wl = createFrameListener(); ! dialog.addWindowListener(wl); ! return dialog; } protected DragWindow createDragWindow(JToolBar toolbar) { ! Window frame = null; if(toolBar != null) { Container p; for(p = toolBar.getParent() ; p != null && !(p instanceof Frame) ; *************** *** 431,440 **** if(p != null && p instanceof Frame) frame = (Frame) p; } ! if(floatingFrame == null) { ! floatingFrame = createFloatingFrame(toolBar); } ! frame = floatingFrame; DragWindow dragWindow = new DragWindow(frame); return dragWindow; --- 434,443 ---- if(p != null && p instanceof Frame) frame = (Frame) p; } ! if(floatingToolBar == null) { ! floatingToolBar = createFloatingFrame(toolBar); } ! frame = floatingToolBar; DragWindow dragWindow = new DragWindow(frame); return dragWindow; *************** *** 581,598 **** } if ( propertyListener != null ) UIManager.addPropertyChangeListener( propertyListener ); ! if (floatingFrame == null) ! floatingFrame = createFloatingFrame(toolBar); ! floatingFrame.getContentPane().add(toolBar,BorderLayout.CENTER); setOrientation( JToolBar.HORIZONTAL ); ! floatingFrame.pack(); ! floatingFrame.setLocation(floatingX, floatingY); ! floatingFrame.show(); } else { ! if (floatingFrame == null) ! floatingFrame = createFloatingFrame(toolBar); ! floatingFrame.setVisible(false); ! floatingFrame.getContentPane().remove(toolBar); String constraint = getDockingConstraint(dockingSource, p); int orientation = mapConstraintToOrientation(constraint); --- 584,601 ---- } if ( propertyListener != null ) UIManager.addPropertyChangeListener( propertyListener ); ! if (floatingToolBar == null) ! floatingToolBar = createFloatingFrame(toolBar); ! floatingToolBar.getContentPane().add(toolBar,BorderLayout.CENTER); setOrientation( JToolBar.HORIZONTAL ); ! floatingToolBar.pack(); ! floatingToolBar.setLocation(floatingX, floatingY); ! floatingToolBar.show(); } else { ! if (floatingToolBar == null) ! floatingToolBar = createFloatingFrame(toolBar); ! floatingToolBar.setVisible(false); ! floatingToolBar.getContentPane().remove(toolBar); String constraint = getDockingConstraint(dockingSource, p); int orientation = mapConstraintToOrientation(constraint); *************** *** 703,708 **** --- 706,728 ---- protected void dragTo(Point position, Point origin) { + String s = BorderLayout.NORTH; + dockingSensitivity = (toolBar.getOrientation() == JToolBar.HORIZONTAL) ? toolBar.getSize().height : toolBar.getSize().width; + Point p = new Point(origin); + SwingUtilities.convertPointFromScreen(p,toolBar.getParent()); + if (p.y >= toolBar.getParent().getSize().height-dockingSensitivity) + s = BorderLayout.SOUTH; + else if ((p.x < dockingSensitivity) && (toolBar.getOrientation() == JToolBar.VERTICAL)) + s = BorderLayout.WEST; + else if ((p.x >= toolBar.getParent().getSize().width-dockingSensitivity) && (toolBar.getOrientation() == JToolBar.VERTICAL)) + s = BorderLayout.EAST; + else if (p.y < dockingSensitivity) + s = BorderLayout.NORTH; + constraintBeforeFloating = s; if (toolBar.isFloatable() == true) { try *************** *** 852,858 **** protected class FrameListener extends WindowAdapter { public void windowClosing(WindowEvent w) { ! setFloating(false, null); } } --- 872,899 ---- protected class FrameListener extends WindowAdapter { public void windowClosing(WindowEvent w) { ! if (toolBar.isFloatable() == true) { ! if (dragWindow != null) ! dragWindow.setVisible(false); ! floating = false; ! if (floatingToolBar == null) ! floatingToolBar = createFloatingFrame(toolBar); ! floatingToolBar.setVisible(false); ! floatingToolBar.getContentPane().remove(toolBar); ! String constraint = constraintBeforeFloating; ! int orientation = mapConstraintToOrientation(constraint); ! setOrientation(orientation); ! if (dockingSource== null) ! dockingSource = toolBar.getParent(); ! if ( propertyListener != null ) ! UIManager.removePropertyChangeListener( propertyListener ); ! dockingSource.add(constraint, toolBar); ! dockingSource.invalidate(); ! Container dockingSourceParent = dockingSource.getParent(); ! if (dockingSourceParent != null) ! dockingSourceParent.validate(); ! dockingSource.repaint(); ! } } } *************** *** 990,997 **** int orientation = toolBar.getOrientation(); Point offset; // offset of the mouse cursor inside the DragWindow ! DragWindow(Frame f) { ! super(f); } public void setOrientation(int o) { --- 1031,1038 ---- int orientation = toolBar.getOrientation(); Point offset; // offset of the mouse cursor inside the DragWindow ! DragWindow(Window w) { ! super(w); } public void setOrientation(int o) { ###@###.### 2000-09-05
05-09-2000

EVALUATION Actually, the correct implementation on Windows is not a JDialog, it is a 'mini-dialog' with ahalf-height title bar etc. georges.saab@Eng 1999-06-03
03-06-1999