| 1 7 8 package javax.swing.plaf.basic; 9 10 import javax.swing.*; 11 import javax.swing.event.*; 12 import java.awt.*; 13 import java.awt.event.*; 14 15 import java.beans.*; 16 17 import java.util.Hashtable ; 18 import java.util.HashMap ; 19 20 import javax.swing.border.*; 21 import javax.swing.plaf.*; 22 import sun.swing.DefaultLookup; 23 import sun.swing.UIAction; 24 import sun.swing.BorderProvider; 25 26 27 36 public class BasicToolBarUI extends ToolBarUI implements SwingConstants 37 { 38 protected JToolBar toolBar; 39 private boolean floating; 40 private int floatingX; 41 private int floatingY; 42 private JFrame floatingFrame; 43 private RootPaneContainer floatingToolBar; 44 protected DragWindow dragWindow; 45 private Container dockingSource; 46 private int dockingSensitivity = 0; 47 protected int focusedCompIndex = -1; 48 49 protected Color dockingColor = null; 50 protected Color floatingColor = null; 51 protected Color dockingBorderColor = null; 52 protected Color floatingBorderColor = null; 53 54 protected MouseInputListener dockingListener; 55 protected PropertyChangeListener propertyListener; 56 57 protected ContainerListener toolBarContListener; 58 protected FocusListener toolBarFocusListener; 59 private Handler handler; 60 61 protected String constraintBeforeFloating = BorderLayout.NORTH; 62 63 private static String IS_ROLLOVER = "JToolBar.isRollover"; 65 private static Border rolloverBorder; 66 private static Border nonRolloverBorder; 67 private static Border nonRolloverToggleBorder; 68 private boolean rolloverBorders = false; 69 70 private HashMap borderTable = new HashMap (); 71 private Hashtable rolloverTable = new Hashtable (); 72 73 74 82 @Deprecated  83 protected KeyStroke upKey; 84 92 @Deprecated  93 protected KeyStroke downKey; 94 102 @Deprecated  103 protected KeyStroke leftKey; 104 112 @Deprecated  113 protected KeyStroke rightKey; 114 115 116 private static String FOCUSED_COMP_INDEX = "JToolBar.focusedCompIndex"; 117 118 public static ComponentUI createUI( JComponent c ) 119 { 120 return new BasicToolBarUI (); 121 } 122 123 public void installUI( JComponent c ) 124 { 125 toolBar = (JToolBar) c; 126 127 installDefaults(); 129 installComponents(); 130 installListeners(); 131 installKeyboardActions(); 132 133 dockingSensitivity = 0; 135 floating = false; 136 floatingX = floatingY = 0; 137 floatingToolBar = null; 138 139 setOrientation( toolBar.getOrientation() ); 140 LookAndFeel.installProperty(c, "opaque", Boolean.TRUE); 141 142 if ( c.getClientProperty( FOCUSED_COMP_INDEX ) != null ) 143 { 144 focusedCompIndex = ( (Integer ) ( c.getClientProperty( FOCUSED_COMP_INDEX ) ) ).intValue(); 145 } 146 } 147 148 public void uninstallUI( JComponent c ) 149 { 150 151 uninstallDefaults(); 153 uninstallComponents(); 154 uninstallListeners(); 155 uninstallKeyboardActions(); 156 157 if (isFloating() == true) 159 setFloating(false, null); 160 161 floatingToolBar = null; 162 dragWindow = null; 163 dockingSource = null; 164 165 c.putClientProperty( FOCUSED_COMP_INDEX, new Integer ( focusedCompIndex ) ); 166 } 167 168 protected void installDefaults( ) 169 { 170 LookAndFeel.installBorder(toolBar,"ToolBar.border"); 171 LookAndFeel.installColorsAndFont(toolBar, 172 "ToolBar.background", 173 "ToolBar.foreground", 174 "ToolBar.font"); 175 if ( dockingColor == null || dockingColor instanceof UIResource ) 177 dockingColor = UIManager.getColor("ToolBar.dockingBackground"); 178 if ( floatingColor == null || floatingColor instanceof UIResource ) 179 floatingColor = UIManager.getColor("ToolBar.floatingBackground"); 180 if ( dockingBorderColor == null || 181 dockingBorderColor instanceof UIResource ) 182 dockingBorderColor = UIManager.getColor("ToolBar.dockingForeground"); 183 if ( floatingBorderColor == null || 184 floatingBorderColor instanceof UIResource ) 185 floatingBorderColor = UIManager.getColor("ToolBar.floatingForeground"); 186 187 Object rolloverProp = toolBar.getClientProperty( IS_ROLLOVER ); 189 if (rolloverProp == null) { 190 rolloverProp = UIManager.get("ToolBar.isRollover"); 191 } 192 if ( rolloverProp != null ) { 193 rolloverBorders = ((Boolean )rolloverProp).booleanValue(); 194 } 195 196 if (rolloverBorder == null) { 197 rolloverBorder = createRolloverBorder(); 198 } 199 if (nonRolloverBorder == null) { 200 nonRolloverBorder = createNonRolloverBorder(); 201 } 202 if (nonRolloverToggleBorder == null) { 203 nonRolloverToggleBorder = createNonRolloverToggleBorder(); 204 } 205 206 207 setRolloverBorders( isRolloverBorders() ); 208 } 209 210 protected void uninstallDefaults( ) 211 { 212 LookAndFeel.uninstallBorder(toolBar); 213 dockingColor = null; 214 floatingColor = null; 215 dockingBorderColor = null; 216 floatingBorderColor = null; 217 218 installNormalBorders(toolBar); 219 220 rolloverBorder = null; 221 nonRolloverBorder = null; 222 nonRolloverToggleBorder = null; 223 } 224 225 protected void installComponents( ) 226 { 227 } 228 229 protected void uninstallComponents( ) 230 { 231 } 232 233 protected void installListeners( ) 234 { 235 dockingListener = createDockingListener( ); 236 237 if ( dockingListener != null ) 238 { 239 toolBar.addMouseMotionListener( dockingListener ); 240 toolBar.addMouseListener( dockingListener ); 241 } 242 243 propertyListener = createPropertyListener(); if (propertyListener != null) { 245 toolBar.addPropertyChangeListener(propertyListener); 246 } 247 248 toolBarContListener = createToolBarContListener(); 249 if ( toolBarContListener != null ) { 250 toolBar.addContainerListener( toolBarContListener ); 251 } 252 253 toolBarFocusListener = createToolBarFocusListener(); 254 255 if ( toolBarFocusListener != null ) 256 { 257 Component[] components = toolBar.getComponents(); 259 260 for ( int i = 0; i < components.length; ++i ) 261 { 262 components[ i ].addFocusListener( toolBarFocusListener ); 263 } 264 } 265 } 266 267 protected void uninstallListeners( ) 268 { 269 if ( dockingListener != null ) 270 { 271 toolBar.removeMouseMotionListener(dockingListener); 272 toolBar.removeMouseListener(dockingListener); 273 274 dockingListener = null; 275 } 276 277 if ( propertyListener != null ) 278 { 279 toolBar.removePropertyChangeListener(propertyListener); 280 propertyListener = null; } 282 283 if ( toolBarContListener != null ) 284 { 285 toolBar.removeContainerListener( toolBarContListener ); 286 toolBarContListener = null; 287 } 288 289 if ( toolBarFocusListener != null ) 290 { 291 Component[] components = toolBar.getComponents(); 293 294 for ( int i = 0; i < components.length; ++i ) 295 { 296 components[ i ].removeFocusListener( toolBarFocusListener ); 297 } 298 299 toolBarFocusListener = null; 300 } 301 handler = null; 302 } 303 304 protected void installKeyboardActions( ) 305 { 306 InputMap km = getInputMap(JComponent. 307 WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); 308 309 SwingUtilities.replaceUIInputMap(toolBar, JComponent. 310 WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, 311 km); 312 313 LazyActionMap.installLazyActionMap(toolBar, BasicToolBarUI .class, 314 "ToolBar.actionMap"); 315 } 316 317 InputMap getInputMap(int condition) { 318 if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) { 319 return (InputMap)DefaultLookup.get(toolBar, this, 320 "ToolBar.ancestorInputMap"); 321 } 322 return null; 323 } 324 325 static void loadActionMap(LazyActionMap map) { 326 map.put(new Actions(Actions.NAVIGATE_RIGHT)); 327 map.put(new Actions(Actions.NAVIGATE_LEFT)); 328 map.put(new Actions(Actions.NAVIGATE_UP)); 329 map.put(new Actions(Actions.NAVIGATE_DOWN)); 330 } 331 332 protected void uninstallKeyboardActions( ) 333 { 334 SwingUtilities.replaceUIActionMap(toolBar, null); 335 SwingUtilities.replaceUIInputMap(toolBar, JComponent. 336 WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, 337 null); 338 } 339 340 protected void navigateFocusedComp( int direction ) 341 { 342 int nComp = toolBar.getComponentCount(); 343 int j; 344 345 switch ( direction ) 346 { 347 case EAST: 348 case SOUTH: 349 350 if ( focusedCompIndex < 0 || focusedCompIndex >= nComp ) break; 351 352 j = focusedCompIndex + 1; 353 354 while ( j != focusedCompIndex ) 355 { 356 if ( j >= nComp ) j = 0; 357 Component comp = toolBar.getComponentAtIndex( j++ ); 358 359 if ( comp != null && comp.isFocusTraversable() && comp.isEnabled() ) 360 { 361 comp.requestFocus(); 362 break; 363 } 364 } 365 366 break; 367 368 case WEST: 369 case NORTH: 370 371 if ( focusedCompIndex < 0 || focusedCompIndex >= nComp ) break; 372 373 j = focusedCompIndex - 1; 374 375 while ( j != focusedCompIndex ) 376 { 377 if ( j < 0 ) j = nComp - 1; 378 Component comp = toolBar.getComponentAtIndex( j-- ); 379 380 if ( comp != null && comp.isFocusTraversable() && comp.isEnabled() ) 381 { 382 comp.requestFocus(); 383 break; 384 } 385 } 386 387 break; 388 389 default: 390 break; 391 } 392 } 393 394 403 protected Border createRolloverBorder() { 404 Object border = UIManager.get("ToolBar.rolloverBorder"); 405 if (border != null) { 406 return (Border)border; 407 } 408 UIDefaults table = UIManager.getLookAndFeelDefaults(); 409 return new CompoundBorder(new BasicBorders.RolloverButtonBorder ( 410 table.getColor("controlShadow"), 411 table.getColor("controlDkShadow"), 412 table.getColor("controlHighlight"), 413 table.getColor("controlLtHighlight")), 414 new BasicBorders.RolloverMarginBorder ()); 415 } 416 417 426 protected Border createNonRolloverBorder() { 427 Object border = UIManager.get("ToolBar.nonrolloverBorder"); 428 if (border != null) { 429 return (Border)border; 430 } 431 UIDefaults table = UIManager.getLookAndFeelDefaults(); 432 return new CompoundBorder(new BasicBorders.ButtonBorder ( 433 table.getColor("Button.shadow"), 434 table.getColor("Button.darkShadow"), 435 table.getColor("Button.light"), 436 table.getColor("Button.highlight")), 437 new BasicBorders.RolloverMarginBorder ()); 438 } 439 440 443 private Border createNonRolloverToggleBorder() { 444 UIDefaults table = UIManager.getLookAndFeelDefaults(); 445 return new CompoundBorder(new BasicBorders.RadioButtonBorder ( 446 table.getColor("ToggleButton.shadow"), 447 table.getColor("ToggleButton.darkShadow"), 448 table.getColor("ToggleButton.light"), 449 table.getColor("ToggleButton.highlight")), 450 new BasicBorders.RolloverMarginBorder ()); 451 } 452 453 457 protected JFrame createFloatingFrame(JToolBar toolbar) { 458 Window window = SwingUtilities.getWindowAncestor(toolbar); 459 JFrame frame = new JFrame(toolbar.getName(), 460 (window != null) ? window.getGraphicsConfiguration() : null) { 461 protected JRootPane createRootPane() { 464 JRootPane rootPane = new JRootPane() { 465 private boolean packing = false; 466 467 public void validate() { 468 super.validate(); 469 if (!packing) { 470 packing = true; 471 pack(); 472 packing = false; 473 } 474 } 475 }; 476 rootPane.setOpaque(true); 477 return rootPane; 478 } 479 }; 480 frame.getRootPane().setName("ToolBar.FloatingFrame"); 481 frame.setResizable(false); 482 WindowListener wl = createFrameListener(); 483 frame.addWindowListener(wl); 484 return frame; 485 } 486 487 492 protected RootPaneContainer createFloatingWindow(JToolBar toolbar) { 493 class ToolBarDialog extends JDialog { 494 public ToolBarDialog(Frame owner, String title, boolean modal) { 495 super(owner, title, modal); 496 } 497 498 public ToolBarDialog(Dialog owner, String title, boolean modal) { 499 super(owner, title, modal); 500 } 501 502 protected JRootPane createRootPane() { 505 JRootPane rootPane = new JRootPane() { 506 private boolean packing = false; 507 508 public void validate() { 509 super.validate(); 510 if (!packing) { 511 packing = true; 512 pack(); 513 packing = false; 514 } 515 } 516 }; 517 rootPane.setOpaque(true); 518 return rootPane; 519 } 520 } 521 522 JDialog dialog; 523 Window window = SwingUtilities.getWindowAncestor(toolbar); 524 if (window instanceof Frame) { 525 dialog = new ToolBarDialog((Frame)window, toolbar.getName(), false); 526 } else if (window instanceof Dialog) { 527 dialog = new ToolBarDialog((Dialog)window, toolbar.getName(), false); 528 } else { 529 dialog = new ToolBarDialog((Frame)null, toolbar.getName(), false); 530 } 531 532 dialog.getRootPane().setName("ToolBar.FloatingWindow"); 533 dialog.setTitle(toolbar.getName()); 534 dialog.setResizable(false); 535 WindowListener wl = createFrameListener(); 536 dialog.addWindowListener(wl); 537 return dialog; 538 } 539 540 protected DragWindow createDragWindow(JToolBar toolbar) { 541 Window frame = null; 542 if(toolBar != null) { 543 Container p; 544 for(p = toolBar.getParent() ; p != null && !(p instanceof Window) ; 545 p = p.getParent()); 546 if(p != null && p instanceof Window) 547 frame = (Window) p; 548 } 549 if(floatingToolBar == null) { 550 floatingToolBar = createFloatingWindow(toolBar); 551 } 552 if (floatingToolBar instanceof Window) frame = (Window) floatingToolBar; 553 DragWindow dragWindow = new DragWindow(frame); 554 return dragWindow; 555 } 556 557 565 public boolean isRolloverBorders() { 566 return rolloverBorders; 567 } 568 569 578 public void setRolloverBorders( boolean rollover ) { 579 rolloverBorders = rollover; 580 581 if ( rolloverBorders ) { 582 installRolloverBorders( toolBar ); 583 } else { 584 installNonRolloverBorders( toolBar ); 585 } 586 } 587 588 598 protected void installRolloverBorders ( JComponent c ) { 599 Component[] components = c.getComponents(); 601 602 for ( int i = 0; i < components.length; ++i ) { 603 if ( components[ i ] instanceof JComponent ) { 604 ( (JComponent)components[ i ] ).updateUI(); 605 setBorderToRollover( components[ i ] ); 606 } 607 } 608 } 609 610 622 protected void installNonRolloverBorders ( JComponent c ) { 623 Component[] components = c.getComponents(); 625 626 for ( int i = 0; i < components.length; ++i ) { 627 if ( components[ i ] instanceof JComponent ) { 628 ( (JComponent)components[ i ] ).updateUI(); 629 setBorderToNonRollover( components[ i ] ); 630 } 631 } 632 } 633 634 646 protected void installNormalBorders ( JComponent c ) { 647 Component[] components = c.getComponents(); 649 650 for ( int i = 0; i < components.length; ++i ) { 651 setBorderToNormal( components[ i ] ); 652 } 653 } 654 655 663 protected void setBorderToRollover(Component c) { 664 if (c instanceof AbstractButton) { 665 AbstractButton b = (AbstractButton)c; 666 667 Border border = (Border)borderTable.get(b); 668 if (border == null || border instanceof UIResource) { 669 borderTable.put(b, b.getBorder()); 670 } 671 672 if (b.getBorder() instanceof UIResource) { 674 b.setBorder(getRolloverBorder(b)); 675 } 676 677 rolloverTable.put(b, b.isRolloverEnabled()? 678 Boolean.TRUE: Boolean.FALSE); 679 b.setRolloverEnabled(true); 680 } 681 } 682 683 private Border getRolloverBorder(AbstractButton b) { 684 Object borderProvider = UIManager.get("ToolBar.rolloverBorderProvider"); 685 if(borderProvider == null) { 686 return rolloverBorder; 687 } 688 689 return ((BorderProvider) borderProvider).getRolloverBorder(b); 690 } 691 692 700 protected void setBorderToNonRollover(Component c) { 701 if (c instanceof AbstractButton) { 702 AbstractButton b = (AbstractButton)c; 703 704 Border border = (Border)borderTable.get(b); 705 if (border == null || border instanceof UIResource) { 706 borderTable.put(b, b.getBorder()); 707 } 708 709 if (b.getBorder() instanceof UIResource) { 711 if (b instanceof JToggleButton) { 712 ((JToggleButton)b).setBorder(nonRolloverToggleBorder); 713 } else { 714 b.setBorder(nonRolloverBorder); 715 } 716 } 717 rolloverTable.put(b, b.isRolloverEnabled()? 718 Boolean.TRUE: Boolean.FALSE); 719 b.setRolloverEnabled(false); 720 } 721 } 722 723 724 725 734 protected void setBorderToNormal(Component c) { 735 if (c instanceof AbstractButton) { 736 AbstractButton b = (AbstractButton)c; 737 738 Border border = (Border)borderTable.remove(b); 739 b.setBorder(border); 740 741 Boolean value = (Boolean )rolloverTable.remove(b); 742 if (value != null) { 743 b.setRolloverEnabled(value.booleanValue()); 744 } 745 } 746 } 747 748 public void setFloatingLocation(int x, int y) { 749 floatingX = x; 750 floatingY = y; 751 } 752 753 public boolean isFloating() { 754 return floating; 755 } 756 757 public void setFloating(boolean b, Point p) { 758 if (toolBar.isFloatable() == true) { 759 if (dragWindow != null) 760 dragWindow.setVisible(false); 761 this.floating = b; 762 if (b == true) 763 { 764 if (dockingSource == null) 765 { 766 dockingSource = toolBar.getParent(); 767 dockingSource.remove(toolBar); 768 } 769 constraintBeforeFloating = calculateConstraint(); 770 if ( propertyListener != null ) 771 UIManager.addPropertyChangeListener( propertyListener ); 772 if (floatingToolBar == null) 773 floatingToolBar = createFloatingWindow(toolBar); 774 floatingToolBar.getContentPane().add(toolBar,BorderLayout.CENTER); 775 if (floatingToolBar instanceof Window) ((Window)floatingToolBar).pack(); 776 if (floatingToolBar instanceof Window) ((Window)floatingToolBar).setLocation(floatingX, floatingY); 777 if (floatingToolBar instanceof Window) ((Window)floatingToolBar).show(); 778 } else { 779 if (floatingToolBar == null) 780 floatingToolBar = createFloatingWindow(toolBar); 781 if (floatingToolBar instanceof Window) ((Window)floatingToolBar).setVisible(false); 782 floatingToolBar.getContentPane().remove(toolBar); 783 String constraint = getDockingConstraint(dockingSource, 784 p); 785 if (constraint == null) { 786 constraint = BorderLayout.NORTH; 787 } 788 int orientation = mapConstraintToOrientation(constraint); 789 setOrientation(orientation); 790 if (dockingSource== null) 791 dockingSource = toolBar.getParent(); 792 if ( propertyListener != null ) 793 UIManager.removePropertyChangeListener( propertyListener ); 794 dockingSource.add(constraint, toolBar); 795 } 796 dockingSource.invalidate(); 797 Container dockingSourceParent = dockingSource.getParent(); 798 if (dockingSourceParent != null) 799 dockingSourceParent.validate(); 800 dockingSource.repaint(); 801 } 802 } 803 804 private int mapConstraintToOrientation(String constraint) 805 { 806 int orientation = toolBar.getOrientation(); 807 808 if ( constraint != null ) 809 { 810 if ( constraint.equals(BorderLayout.EAST) || constraint.equals(BorderLayout.WEST) ) 811 orientation = JToolBar.VERTICAL; 812 else if ( constraint.equals(BorderLayout.NORTH) || constraint.equals(BorderLayout.SOUTH) ) 813 orientation = JToolBar.HORIZONTAL; 814 } 815 816 return orientation; 817 } 818 819 public void setOrientation(int orientation) 820 { 821 toolBar.setOrientation( orientation ); 822 823 if (dragWindow !=null) 824 dragWindow.setOrientation(orientation); 825 } 826 827 830 public Color getDockingColor() { 831 return dockingColor; 832 } 833 834 837 public void setDockingColor(Color c) { 838 this.dockingColor = c; 839 } 840 841 844 public Color getFloatingColor() { 845 return floatingColor; 846 } 847 848 851 public void setFloatingColor(Color c) { 852 this.floatingColor = c; 853 } 854 855 private boolean isBlocked(Component comp, Object constraint) { 856 if (comp instanceof Container) { 857 Container cont = (Container)comp; 858 LayoutManager lm = cont.getLayout(); 859 if (lm instanceof BorderLayout) { 860 BorderLayout blm = (BorderLayout)lm; 861 Component c = blm.getLayoutComponent(cont, constraint); 862 return (c != null && c != toolBar); 863 } 864 } 865 return false; 866 } 867 868 public boolean canDock(Component c, Point p) { 869 return (p != null && getDockingConstraint(c, p) != null); 870 } 871 872 private String calculateConstraint() { 873 String constraint = null; 874 LayoutManager lm = dockingSource.getLayout(); 875 if (lm instanceof BorderLayout) { 876 constraint = (String )((BorderLayout)lm).getConstraints(toolBar); 877 } 878 return (constraint != null) ? constraint : constraintBeforeFloating; 879 } 880 881 882 883 private String getDockingConstraint(Component c, Point p) { 884 if (p == null) return constraintBeforeFloating; 885 if (c.contains(p)) { 886 dockingSensitivity = (toolBar.getOrientation() == JToolBar.HORIZONTAL) 887 ? toolBar.getSize().height 888 : toolBar.getSize().width; 889 if (p.y < dockingSensitivity && !isBlocked(c, BorderLayout.NORTH)) { 891 return BorderLayout.NORTH; 892 } 893 if (p.x >= c.getWidth() - dockingSensitivity && !isBlocked(c, BorderLayout.EAST)) { 895 return BorderLayout.EAST; 896 } 897 if (p.x < dockingSensitivity && !isBlocked(c, BorderLayout.WEST)) { 899 return BorderLayout.WEST; 900 } 901 if (p.y >= c.getHeight() - dockingSensitivity && !isBlocked(c, BorderLayout.SOUTH)) { 902 return BorderLayout.SOUTH; 903 } 904 } 905 return null; 906 } 907 908 protected void dragTo(Point position, Point origin) 909 { 910 if (toolBar.isFloatable() == true) 911 { 912 try 913 { 914 if (dragWindow == null) 915 dragWindow = createDragWindow(toolBar); 916 Point offset = dragWindow.getOffset(); 917 if (offset == null) { 918 Dimension size = toolBar.getPreferredSize(); 919 offset = new Point(size.width/2, size.height/2); 920 dragWindow.setOffset(offset); 921 } 922 Point global = new Point(origin.x+ position.x, 923 origin.y+position.y); 924 Point dragPoint = new Point(global.x- offset.x, 925 global.y- offset.y); 926 if (dockingSource == null) 927 dockingSource = toolBar.getParent(); 928 constraintBeforeFloating = calculateConstraint(); 929 Point dockingPosition = dockingSource.getLocationOnScreen(); 930 Point comparisonPoint = new Point(global.x-dockingPosition.x, 931 global.y-dockingPosition.y); 932 if (canDock(dockingSource, comparisonPoint)) { 933 dragWindow.setBackground(getDockingColor()); 934 String constraint = getDockingConstraint(dockingSource, 935 comparisonPoint); 936 int orientation = mapConstraintToOrientation(constraint); 937 dragWindow.setOrientation(orientation); 938 dragWindow.setBorderColor(dockingBorderColor); 939 } else { 940 dragWindow.setBackground(getFloatingColor()); 941 dragWindow.setBorderColor(floatingBorderColor); 942 } 943 944 dragWindow.setLocation(dragPoint.x, dragPoint.y); 945 if (dragWindow.isVisible() == false) { 946 Dimension size = toolBar.getPreferredSize(); 947 dragWindow.setSize(size.width, size.height); 948 dragWindow.show(); 949 } 950 } 951 catch ( IllegalComponentStateException e ) 952 { 953 } 954 } 955 } 956 957 protected void floatAt(Point position, Point origin) 958 { 959 if(toolBar.isFloatable() == true) 960 { 961 try 962 { 963 Point offset = dragWindow.getOffset(); 964 if (offset == null) { 965 offset = position; 966 dragWindow.setOffset(offset); 967 } 968 Point global = new Point(origin.x+ position.x, 969 origin.y+position.y); 970 setFloatingLocation(global.x-offset.x, 971 global.y-offset.y); 972 if (dockingSource != null) { 973 Point dockingPosition = dockingSource.getLocationOnScreen(); 974 Point comparisonPoint = new Point(global.x-dockingPosition.x, 975
|