-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
sparc
-
solaris_2.6
Name: aaC67449 Date: 11/26/99
The bug appears if toolbar in Metal L&F has dimensions with width
larger then height and has vertical orientation. Holding the mouse button while
the cursor is over sensitive panel (bumpRect in the source code) of the toolbar
does not cause dragging of the toolbar. But the same action outside the
bumpRect (left side of the toolbar like in the horizontal orientation)
incorrectly causes dragging .
The following part of source code causes this bag:
MetalToolBarUI.java line number 357:
if ( toolBar.getSize().height <= toolBar.getSize().width ) //horizontal
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// toolBar.getOrientation() works much better
{
if( MetalUtils.isLeftToRight(toolBar) ) {
bumpRect.setBounds( 0, 0, 14,
toolBar.getSize().height );
} else {
bumpRect.setBounds( toolBar.getSize().width-14, 0,
14, toolBar.getSize().height );
}
}
else // vertical
{
bumpRect.setBounds( 0, 0, toolBar.getSize().width, 14 );
}
Here is the example demonstrating the bug:
------------------ ToolBarExample.java -----------------
// ToolBarExample.java
//
import java.awt.*;
import java.awt.event.*;
import java.awt.Window;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.metal.*;
class BasicWindowMonitor extends WindowAdapter {
public void windowClosing(WindowEvent e) {
Window w = e.getWindow();
w.setVisible(false);
w.dispose();
System.exit(0);
}
}
public class ToolBarExample extends JPanel {
public static void main(String s[]) {
JToolBar toolBar = new JToolBar();
toolBar.setOrientation(1);
toolBar.setPreferredSize(new Dimension(100,50));
JTextPane pane = new JTextPane();
pane.setPreferredSize(new Dimension(50, 95));
pane.setBorder(new BevelBorder(BevelBorder.LOWERED));
JFrame frame = new JFrame("ToolBar Example");
frame.addWindowListener(new BasicWindowMonitor());
frame.getContentPane().add(toolBar, BorderLayout.WEST);
frame.getContentPane().add(pane, BorderLayout.CENTER);
frame.setSize(new Dimension(150, 95));
frame.pack();
frame.setVisible(true);
}
}
------------------------------------------------------
======================================================================