JDK-6328598 : JToolbar wrong width when detached from left/right side
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2005-09-26
  • Updated: 2017-05-23
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
When you detach a VERTICAL  toolbar from left or right side, fthe resulting VERTICAL floating toolbar have an excessive  width.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run JToolbar demo linked in JToolbar API page.
2. Move the toolbar in right or left side.
3. Detach it

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The toolbar should become floating (saving VERTICAL orientation: this works!) and respect  its width (adapting to vertically disposed buttons width).

Otherwise, the toolbar should get HORIZONTAL orientation (as in JDK 1.4.2)
ACTUAL -
The toolbar's width increases a lot !

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
[JToolbar demo linked in JToolbar API page].

http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/ToolBarDemo.java
---------- END SOURCE ----------

Release Regression From : 1.4.2_08
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

Comments
EVALUATION There is one more problem: undecorated frame doesn't have a title and control buttons at the top, whereas a dialog window (used now) does. Can we change JToolbar behaviour in this way? NB: most of windows applications use titled floating toolbar (MS VC++, MS Word, etc...)
20-10-2006

EVALUATION Maybe, the solution is to use undecorated JFrame, which can be narrower than a JDialog. But there is a problem: JFrame doesn't have a parent and it isn't closed when the main frame of application is disposed (see the 4418849 bug). This problem can be solved by using of WindowListener for the parent window, which will close the toolbar frame.
29-08-2006

EVALUATION Hmm... It turned out, that the behavior of JToolBar (which it shows in the JDK 1.4) is not acceptable. In other words, if a VERTICAL toolbar is detached from left or right side, resulting floating toolabr MUST be VERTICAL too. Consequently, suggested solution is wrong. After some time I have found the cause of the bug. It is in the native restriction of Windows OS. A JDialog which is used for floating JToolBar cannot be narrower than some constant (about 112 pixels).
13-03-2006

SUGGESTED FIX Hmm... It turned out, that the behavior of JToolBar (which it shows in the JDK 1.4) is not acceptable. In other words, if a VERTICAL toolbar is detached from left or right side, resulting floating toolabr MUST be VERTICAL too. Consequently, suggested fix is wrong.
13-03-2006

SUGGESTED FIX add in the BasicToolBarUI.java the following code line at the 771 position: setOrientation( JToolBar.HORIZONTAL );
10-03-2006

EVALUATION When the toolbar is showed as floating window its layout manager must layout components as row, but not as column. I have found the necessary code line was deleted in BasicToolBarUI.java in JDK 1.5 at the setFloating() method: setOrientation( JToolBar.HORIZONTAL );
10-03-2006