Index: org/openide/awt/Toolbar.java =================================================================== RCS file: /cvs/openide/src/org/openide/awt/Toolbar.java,v retrieving revision 1.69 diff -c -r1.69 Toolbar.java *** org/openide/awt/Toolbar.java 29 Jul 2002 10:11:29 -0000 1.69 --- org/openide/awt/Toolbar.java 6 Aug 2002 14:12:31 -0000 *************** *** 167,177 **** /** * When Toolbar is floatable, ToolbarBump is added as Grip as first toolbar component ! */ void addGrip () { if (floatable) { ! ToolbarBump dragarea = new ToolbarBump(); ! if (mouseListener == null) mouseListener = new ToolbarMouseListener (); --- 167,179 ---- /** * When Toolbar is floatable, ToolbarBump is added as Grip as first toolbar component ! * modified by Michael Wever, to use l&f's grip/bump. */ void addGrip () { if (floatable) { ! /** Uses L&F's grip **/ ! String lAndF = UIManager.getLookAndFeel().getName(); ! JPanel dragarea = lAndF.equals("Windows") ? ! (JPanel)new ToolbarGrip() : (JPanel)new ToolbarBump(); if (mouseListener == null) mouseListener = new ToolbarMouseListener (); *************** *** 471,477 **** } // end of inner class Folder /** Bumps for floatable toolbar */ ! private class ToolbarBump extends JPanel { /** Top gap. */ static final int TOPGAP = 2; /** Bottom gap. */ --- 473,479 ---- } // end of inner class Folder /** Bumps for floatable toolbar */ ! private final class ToolbarBump extends JPanel { /** Top gap. */ static final int TOPGAP = 2; /** Bottom gap. */ *************** *** 530,535 **** --- 532,604 ---- } } // end of inner class ToolbarBump + /** Grip for floatable toolbar, used for Windows L&F */ + private final class ToolbarGrip extends JPanel { + /** Horizontal gaps. */ + static final int HGAP = 1; + /** Vertical gaps. */ + static final int VGAP = 1; + /** Step between two grip elements. */ + static final int STEP = 1; + /** Width of grip element. */ + static final int WIDTH = 2; + + /** Number of grip elements. */ + int columns; + /** Minimum size. */ + Dimension dim; + /** Maximum size. */ + Dimension max; + + static final long serialVersionUID =-8819972936203315276L; + + /** Create new ToolbarGrip for default number of grip elements. */ + public ToolbarGrip () { + this (2); + } + + /** Create new ToolbarGrip for specific number of grip elements. + * @param col number of grip elements + */ + public ToolbarGrip (int col) { + super (); + columns = col; + int width = (col - 1) * STEP + col * WIDTH + 2 * HGAP; + dim = new Dimension (width, width); + max = new Dimension (width, Integer.MAX_VALUE); + this.setBorder (new EmptyBorder (VGAP, HGAP, VGAP, HGAP)); + this.setToolTipText (Toolbar.this.getName()); + } + + /** Paint grip to specific Graphics. */ + public void paint (Graphics g) { + Dimension size = this.getSize(); + int top = VGAP; + int bottom = size.height - 1 - VGAP; + int height = bottom - top; + g.setColor ( this.getBackground() ); + + for (int i = 0, x = HGAP; i < columns; i++, x += WIDTH + STEP) { + g.draw3DRect (x, top, WIDTH, height, true); // grip element is 3D rectangle now + } + + } + + /** @return minimum size */ + public Dimension getMinimumSize () { + return dim; + } + + /** @return preferred size */ + public Dimension getPreferredSize () { + return this.getMinimumSize(); + } + + public Dimension getMaximumSize () { + return max; + } + + } // end of inner class ToolbarGrip /** DnDListener is Drag and Drop listener for Toolbar motion events. */ public interface DnDListener extends java.util.EventListener {