1 7 8 package javax.swing.plaf.basic; 9 10 import java.awt.*; 11 import java.awt.event.*; 12 import java.awt.peer.LightweightPeer; 13 14 import javax.swing.*; 15 import javax.swing.border.*; 16 import javax.swing.plaf.*; 17 import javax.swing.event.*; 18 19 import java.beans.*; 20 import java.io.Serializable ; 21 22 import sun.swing.DefaultLookup; 23 import sun.swing.UIAction; 24 25 32 public class BasicInternalFrameUI extends InternalFrameUI 33 { 34 35 protected JInternalFrame frame; 36 37 private Handler handler; 38 protected MouseInputAdapter borderListener; 39 protected PropertyChangeListener propertyChangeListener; 40 protected LayoutManager internalFrameLayout; 41 protected ComponentListener componentListener; 42 protected MouseInputListener glassPaneDispatcher; 43 private InternalFrameListener internalFrameListener; 44 45 protected JComponent northPane; 46 protected JComponent southPane; 47 protected JComponent westPane; 48 protected JComponent eastPane; 49 50 protected BasicInternalFrameTitlePane titlePane; 52 private static DesktopManager sharedDesktopManager; 53 private boolean componentListenerAdded = false; 54 55 private Rectangle parentBounds; 56 57 private boolean dragging = false; 58 private boolean resizing = false; 59 60 68 @Deprecated 69 protected KeyStroke openMenuKey; 70 71 private boolean keyBindingRegistered = false; 72 private boolean keyBindingActive = false; 73 74 public static ComponentUI createUI(JComponent b) { 78 return new BasicInternalFrameUI ((JInternalFrame)b); 79 } 80 81 public BasicInternalFrameUI(JInternalFrame b) { 82 } 83 84 public void installUI(JComponent c) { 85 86 frame = (JInternalFrame)c; 87 88 installDefaults(); 89 installListeners(); 90 installComponents(); 91 installKeyboardActions(); 92 93 LookAndFeel.installProperty(frame, "opaque", Boolean.TRUE); 94 } 95 96 public void uninstallUI(JComponent c) { 97 if(c != frame) 98 throw new IllegalComponentStateException( 99 this + " was asked to deinstall() " 100 + c + " when it only knows about " 101 + frame + "."); 102 103 uninstallKeyboardActions(); 104 uninstallComponents(); 105 uninstallListeners(); 106 uninstallDefaults(); 107 frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 108 handler = null; 109 frame = null; 110 } 111 112 protected void installDefaults(){ 113 Icon frameIcon = frame.getFrameIcon(); 114 if (frameIcon == null || frameIcon instanceof UIResource) { 115 frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon")); 116 } 117 118 JComponent contentPane = (JComponent) frame.getContentPane(); 121 if (contentPane != null) { 122 Color bg = contentPane.getBackground(); 123 if (bg instanceof UIResource) 124 contentPane.setBackground(null); 125 } 126 frame.setLayout(internalFrameLayout = createLayoutManager()); 127 frame.setBackground(UIManager.getLookAndFeelDefaults().getColor("control")); 128 129 LookAndFeel.installBorder(frame, "InternalFrame.border"); 130 131 } 132 protected void installKeyboardActions(){ 133 createInternalFrameListener(); 134 if (internalFrameListener != null) { 135 frame.addInternalFrameListener(internalFrameListener); 136 } 137 138 LazyActionMap.installLazyActionMap(frame, BasicInternalFrameUI .class, 139 "InternalFrame.actionMap"); 140 } 141 142 static void loadActionMap(LazyActionMap map) { 143 map.put(new UIAction("showSystemMenu") { 144 public void actionPerformed(ActionEvent evt) { 145 JInternalFrame iFrame = (JInternalFrame)evt.getSource(); 146 if (iFrame.getUI() instanceof BasicInternalFrameUI ) { 147 JComponent comp = ((BasicInternalFrameUI ) 148 iFrame.getUI()).getNorthPane(); 149 if (comp instanceof BasicInternalFrameTitlePane ) { 150 ((BasicInternalFrameTitlePane )comp). 151 showSystemMenu(); 152 } 153 } 154 } 155 156 public boolean isEnabled(Object sender){ 157 if (sender instanceof JInternalFrame) { 158 JInternalFrame iFrame = (JInternalFrame)sender; 159 if (iFrame.getUI() instanceof BasicInternalFrameUI ) { 160 return ((BasicInternalFrameUI )iFrame.getUI()). 161 isKeyBindingActive(); 162 } 163 } 164 return false; 165 } 166 }); 167 168 BasicLookAndFeel.installAudioActionMap(map); 170 } 171 172 protected void installComponents(){ 173 setNorthPane(createNorthPane(frame)); 174 setSouthPane(createSouthPane(frame)); 175 setEastPane(createEastPane(frame)); 176 setWestPane(createWestPane(frame)); 177 } 178 179 182 protected void installListeners() { 183 borderListener = createBorderListener(frame); 184 propertyChangeListener = createPropertyChangeListener(); 185 frame.addPropertyChangeListener(propertyChangeListener); 186 installMouseHandlers(frame); 187 glassPaneDispatcher = createGlassPaneDispatcher(); 188 frame.getGlassPane().addMouseListener(glassPaneDispatcher); 189 frame.getGlassPane().addMouseMotionListener(glassPaneDispatcher); 190 componentListener = createComponentListener(); 191 if (frame.getParent() != null) { 192 parentBounds = frame.getParent().getBounds(); 193 } 194 if ((frame.getParent() != null) && !componentListenerAdded) { 195 frame.getParent().addComponentListener(componentListener); 196 componentListenerAdded = true; 197 } 198 } 199 200 private WindowFocusListener getWindowFocusListener(){ 201 return getHandler(); 202 } 203 204 private void cancelResize() { 205 if (resizing) { 206 if (borderListener instanceof BorderListener) { 207 ((BorderListener)borderListener).finishMouseReleased(); 208 } 209 } 210 } 211 212 private Handler getHandler() { 213 if (handler == null) { 214 handler = new Handler(); 215 } 216 return handler; 217 } 218 219 InputMap getInputMap(int condition) { 220 if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) { 221 return createInputMap(condition); 222 } 223 return null; 224 } 225 226 InputMap createInputMap(int condition) { 227 if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) { 228 Object [] bindings = (Object [])DefaultLookup.get( 229 frame, this, "InternalFrame.windowBindings"); 230 231 if (bindings != null) { 232 return LookAndFeel.makeComponentInputMap(frame, bindings); 233 } 234 } 235 return null; 236 } 237 238 protected void uninstallDefaults() { 239 Icon frameIcon = frame.getFrameIcon(); 240 if (frameIcon instanceof UIResource) { 241 frame.setFrameIcon(null); 242 } 243 internalFrameLayout = null; 244 frame.setLayout(null); 245 LookAndFeel.uninstallBorder(frame); 246 } 247 248 protected void uninstallComponents(){ 249 setNorthPane(null); 250 setSouthPane(null); 251 setEastPane(null); 252 setWestPane(null); 253 if(titlePane != null) { 254 titlePane.uninstallDefaults(); 255 } 256 titlePane = null; 257 } 258 259 262 protected void uninstallListeners() { 263 if ((frame.getParent() != null) && componentListenerAdded) { 264 frame.getParent().removeComponentListener(componentListener); 265 componentListenerAdded = false; 266 } 267 componentListener = null; 268 frame.getGlassPane().removeMouseListener(glassPaneDispatcher); 269 frame.getGlassPane().removeMouseMotionListener(glassPaneDispatcher); 270 glassPaneDispatcher = null; 271 deinstallMouseHandlers(frame); 272 frame.removePropertyChangeListener(propertyChangeListener); 273 propertyChangeListener = null; 274 borderListener = null; 275 } 276 277 protected void uninstallKeyboardActions(){ 278 if (internalFrameListener != null) { 279 frame.removeInternalFrameListener(internalFrameListener); 280 } 281 internalFrameListener = null; 282 283 SwingUtilities.replaceUIInputMap(frame, JComponent. 284 WHEN_IN_FOCUSED_WINDOW, null); 285 SwingUtilities.replaceUIActionMap(frame, null); 286 287 } 288 289 protected LayoutManager createLayoutManager(){ 290 return getHandler(); 291 } 292 293 protected PropertyChangeListener createPropertyChangeListener(){ 294 return getHandler(); 295 } 296 297 298 299 public Dimension getPreferredSize(JComponent x) { 300 if((JComponent)frame == x) 301 return frame.getLayout().preferredLayoutSize(x); 302 return new Dimension(100, 100); 303 } 304 305 public Dimension getMinimumSize(JComponent x) { 306 if((JComponent)frame == x) { 307 return frame.getLayout().minimumLayoutSize(x); 308 } 309 return new Dimension(0, 0); 310 } 311 312 public Dimension getMaximumSize(JComponent x) { 313 return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); 314 } 315 316 317 318 323 protected void replacePane(JComponent currentPane, JComponent newPane) { 324 if(currentPane != null) { 325 deinstallMouseHandlers(currentPane); 326 frame.remove(currentPane); 327 } 328 if(newPane != null) { 329 frame.add(newPane); 330 installMouseHandlers(newPane); 331 } 332 } 333 334 protected void deinstallMouseHandlers(JComponent c) { 335 c.removeMouseListener(borderListener); 336 c.removeMouseMotionListener(borderListener); 337 } 338 339 protected void installMouseHandlers(JComponent c) { 340 c.addMouseListener(borderListener); 341 c.addMouseMotionListener(borderListener); 342 } 343 344 protected JComponent createNorthPane(JInternalFrame w) { 345 titlePane = new BasicInternalFrameTitlePane (w); 346 return titlePane; 347 } 348 349 350 protected JComponent createSouthPane(JInternalFrame w) { 351 return null; 352 } 353 354 protected JComponent createWestPane(JInternalFrame w) { 355 return null; 356 } 357 358 protected JComponent createEastPane(JInternalFrame w) { 359 return null; 360 } 361 362 363 protected MouseInputAdapter createBorderListener(JInternalFrame w) { 364 return new BorderListener(); 365 } 366 367 protected void createInternalFrameListener(){ 368 internalFrameListener = getHandler(); 369 } 370 371 protected final boolean isKeyBindingRegistered(){ 372 return keyBindingRegistered; 373 } 374 375 protected final void setKeyBindingRegistered(boolean b){ 376 keyBindingRegistered = b; 377 } 378 379 public final boolean isKeyBindingActive(){ 380 return keyBindingActive; 381 } 382 383 protected final void setKeyBindingActive(boolean b){ 384 keyBindingActive = b; 385 } 386 387 388 protected void setupMenuOpenKey(){ 389 InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); 394 SwingUtilities.replaceUIInputMap(frame, 395 JComponent.WHEN_IN_FOCUSED_WINDOW, map); 396 } 399 400 protected void setupMenuCloseKey(){ 401 } 402 403 public JComponent getNorthPane() { 404 return northPane; 405 } 406 407 public void setNorthPane(JComponent c) { 408 if (northPane != null && 409 northPane instanceof BasicInternalFrameTitlePane ) { 410 ((BasicInternalFrameTitlePane )northPane).uninstallListeners(); 411 } 412 replacePane(northPane, c); 413 northPane = c; 414 } 415 416 public JComponent getSouthPane() { 417 return southPane; 418 } 419 420 public void setSouthPane(JComponent c) { 421 southPane = c; 422 } 423 424 public JComponent getWestPane() { 425 return westPane; 426 } 427 428 public void setWestPane(JComponent c) { 429 westPane = c; 430 } 431 432 public JComponent getEastPane() { 433 return eastPane; 434 } 435 436 public void setEastPane(JComponent c) { 437 eastPane = c; 438 } 439 440 public class InternalFramePropertyChangeListener implements 441 PropertyChangeListener { 442 450 public void propertyChange(PropertyChangeEvent evt) { 451 getHandler().propertyChange(evt); 452 } 453 } 454 455 public class InternalFrameLayout implements LayoutManager { 456 public void addLayoutComponent(String name, Component c) { 461 getHandler().addLayoutComponent(name, c); 462 } 463 464 public void removeLayoutComponent(Component c) { 465 getHandler().removeLayoutComponent(c); 466 } 467 468 public Dimension preferredLayoutSize(Container c) { 469 return getHandler().preferredLayoutSize(c); 470 } 471 472 public Dimension minimumLayoutSize(Container c) { 473 return getHandler().minimumLayoutSize(c); 474 } 475 476 public void layoutContainer(Container c) { 477 getHandler().layoutContainer(c); 478 } 479 } 480 481 487 protected DesktopManager getDesktopManager() { 488 if(frame.getDesktopPane() != null 489 && frame.getDesktopPane().getDesktopManager() != null) 490 return frame.getDesktopPane().getDesktopManager(); 491 if(sharedDesktopManager == null) 492 sharedDesktopManager = createDesktopManager(); 493 return sharedDesktopManager; 494 } 495 496 protected DesktopManager createDesktopManager(){ 497 return new DefaultDesktopManager(); 498 } 499 500 505 protected void closeFrame(JInternalFrame f) { 506 BasicLookAndFeel.playSound(frame,"InternalFrame.closeSound"); 508 getDesktopManager().closeFrame(f); 510 } 511 512 517 protected void maximizeFrame(JInternalFrame f) { 518 BasicLookAndFeel.playSound(frame,"InternalFrame.maximizeSound"); 520 getDesktopManager().maximizeFrame(f); 522 } 523 524 529 protected void minimizeFrame(JInternalFrame f) { 530 if ( ! f.isIcon() ) { 532 BasicLookAndFeel.playSound(frame,"InternalFrame.restoreDownSound"); 535 } 536 getDesktopManager().minimizeFrame(f); 538 } 539 540 545 protected void iconifyFrame(JInternalFrame f) { 546 BasicLookAndFeel.playSound(frame, "InternalFrame.minimizeSound"); 548 getDesktopManager().iconifyFrame(f); 550 } 551 552 557 protected void deiconifyFrame(JInternalFrame f) { 558 if ( ! f.isMaximum() ) { 560 BasicLookAndFeel.playSound(frame, "InternalFrame.restoreUpSound"); 563 } 564 getDesktopManager().deiconifyFrame(f); 566 } 567 568 571 protected void activateFrame(JInternalFrame f) { 572 getDesktopManager().activateFrame(f); 573 } 574 577 protected void deactivateFrame(JInternalFrame f) { 578 getDesktopManager().deactivateFrame(f); 579 } 580 581 587 protected class BorderListener extends MouseInputAdapter implements SwingConstants 588 { 589 int _x, _y; 591 int __x, __y; 593 Rectangle startingBounds; 594 int resizeDir; 595 596 597 protected final int RESIZE_NONE = 0; 598 private boolean discardRelease = false; 599 600 int resizeCornerSize = 16; 601 602 public void mouseClicked(MouseEvent e) { 603 if(e.getClickCount() > 1 && e.getSource() == getNorthPane()) { 604 if(frame.isIconifiable() && frame.isIcon()) { 605 try { frame.setIcon(false); } catch (PropertyVetoException e2) { } 606 } else if(frame.isMaximizable()) { 607 if(!frame.isMaximum()) 608 try { frame.setMaximum(true); } catch (PropertyVetoException e2) { } 609 else 610 try { frame.setMaximum(false); } catch (PropertyVetoException e3) { } 611 } 612 } 613 } 614 615 void finishMouseReleased() { 616 if (discardRelease) { 617 discardRelease = false; 618 return; 619 } 620 if (resizeDir == RESIZE_NONE) { 621 getDesktopManager().endDraggingFrame(frame); 622 dragging = false; 623 } else { 624 Window windowAncestor = 625 SwingUtilities.getWindowAncestor(frame); 626 if (windowAncestor != null) { 627 windowAncestor.removeWindowFocusListener( 628 getWindowFocusListener()); 629 } 630 Container c = frame.getTopLevelAncestor(); 631 if (c instanceof JFrame) { 632 ((JFrame)frame.getTopLevelAncestor()).getGlassPane().setCursor( 633 Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 634 635 ((JFrame)frame.getTopLevelAncestor()).getGlassPane( 636 ).setVisible(false); 637 } else if (c instanceof JApplet) { 638 ((JApplet)c).getGlassPane().setCursor( 639 Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 640 ((JApplet)c).getGlassPane().setVisible(false); 641 } else if (c instanceof JWindow) { 642 ((JWindow)c).getGlassPane().setCursor( 643 Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 644 ((JWindow)c).getGlassPane().setVisible(false); 645 } else if (c instanceof JDialog) { 646 ((JDialog)c).getGlassPane().setCursor( 647 Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 648 ((JDialog)c).getGlassPane().setVisible(false); 649 } 650 getDesktopManager().endResizingFrame(frame); 651 resizing = false; 652 } 653 _x = 0; 654 _y = 0; 655 __x = 0; 656 __y = 0; 657 startingBounds = null; 658 resizeDir = RESIZE_NONE; 659 discardRelease = true; 660 } 661 662 public void mouseReleased(MouseEvent e) { 663 finishMouseReleased(); 664 } 665 666 public void mousePressed(MouseEvent e) { 667 Point p = SwingUtilities.convertPoint((Component)e.getSource(), 668 e.getX(), e.getY(), null); 669 __x = e.getX(); 670 __y = e.getY(); 671 _x = p.x; 672 _y = p.y; 673 startingBounds = frame.getBounds(); 674 resizeDir = RESIZE_NONE; 675 discardRelease = false; 676 677 if(!frame.isSelected()) { 678 try { frame.setSelected(true); } 679 catch (PropertyVetoException e1) { } 680 } 681 682 Insets i = frame.getInsets(); 683 684 Point ep = new Point(__x, __y); 685 if (e.getSource() == getNorthPane()) { 686 Point np = getNorthPane().getLocation(); 687 ep.x += np.x; 688 ep.y += np.y; 689 } 690 691 if (e.getSource() == getNorthPane()) { 692 if (ep.x > i.left && ep.y > i.top && ep.x < frame.getWidth() - i.right) { 693 getDesktopManager().beginDraggingFrame(frame); 694 dragging = true; 695 return; 696 } 697 } 698 if (!frame.isResizable()) { 699 return; 700 } 701 702 if (e.getSource() == frame || e.getSource() == getNorthPane()) { 703 if (ep.x <= i.left) { 704 if (ep.y < resizeCornerSize + i.top) { 705 resizeDir = NORTH_WEST; 706 } else if (ep.y > frame.getHeight() 707 - resizeCornerSize - i.bottom) { 708 resizeDir = SOUTH_WEST; 709 } else { 710 resizeDir = WEST; 711 } 712 } else if (ep.x >= frame.getWidth() - i.right) { 713 if (ep.y < resizeCornerSize + i.top) { 714 resizeDir = NORTH_EAST; 715 } else if (ep.y > frame.getHeight() 716 - resizeCornerSize - i.bottom) { 717 resizeDir = SOUTH_EAST; 718 } else { 719 resizeDir = EAST; 720 } 721 } else if (ep.y <= i.top) { 722 if (ep.x < resizeCornerSize + i.left) { 723 resizeDir = NORTH_WEST; 724 } else if (ep.x > frame.getWidth() 725 - resizeCornerSize - i.right) { 726 resizeDir = NORTH_EAST; 727 } else { 728 resizeDir = NORTH; 729 } 730 } else if (ep.y >= frame.getHeight() - i.bottom) { 731 if (ep.x < resizeCornerSize + i.left) { 732 resizeDir = SOUTH_WEST; 733 } else if (ep.x > frame.getWidth() 734 - resizeCornerSize - i.right) { 735 resizeDir = SOUTH_EAST; 736 } else { 737 resizeDir = SOUTH; 738 } 739 } else { 740 742 discardRelease = true; 743 return; 744 } 745 Cursor s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); 746 switch (resizeDir) { 747 case SOUTH: 748 s = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR); 749 break; 750 case NORTH: 751 s = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR); 752 break; 753 case WEST: 754 s = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR); 755 break; 756 case EAST: 757 s = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); 758 break; 759 case SOUTH_EAST: 760 s = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR); 761 break; 762 case SOUTH_WEST: 763 s = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR); 764 break; 765 case NORTH_WEST: 766 s = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR); 767 break; 768 case NORTH_EAST: 769 s = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR); 770 break; 771 } 772 Container c = frame.getTopLevelAncestor(); 773 if (c instanceof JFrame){ 774 ((JFrame)c).getGlassPane().setVisible(true); 775 ((JFrame)c).getGlassPane().setCursor(s); 776 } else if (c instanceof JApplet){ 777 ((JApplet)c).getGlassPane().setVisible(true); 778 ((JApplet)c).getGlassPane().setCursor(s); 779 } else if (c instanceof JWindow){ 780 ((JWindow)c).getGlassPane().setVisible(true); 781 ((JWindow)c).getGlassPane().setCursor(s); 782 } else if (c instanceof JDialog){ 783 ((JDialog)c).getGlassPane().setVisible(true); 784 ((JDialog)c).getGlassPane().setCursor(s); 785 } 786 getDesktopManager().beginResizingFrame(frame, resizeDir); 787 resizing = true; 788 Window windowAncestor = SwingUtilities.getWindowAncestor(frame); 789 if (windowAncestor != null) { 790 windowAncestor.addWindowFocusListener( 791 getWindowFocusListener()); 792 } 793 return; 794 } 795 } 796 797 public void mouseDragged(MouseEvent e) { 798 799 if ( startingBounds == null ) { 800 return; 802 } 803 804 Point p = SwingUtilities.convertPoint((Component)e.getSource(), 805 e.getX(), e.getY(), null); 806 int deltaX = _x - p.x; 807 int deltaY = _y - p.y; 808 Dimension min = frame.getMinimumSize(); 809 Dimension max = frame.getMaximumSize(); 810 int newX, newY, newW, newH; 811 Insets i = frame.getInsets(); 812 813 if (dragging) { 815 if (frame.isMaximum() || ((e.getModifiers() & 816 InputEvent.BUTTON1_MASK) != 817 InputEvent.BUTTON1_MASK)) { 818 return; 821 } 822 int pWidth, pHeight; 823 Dimension s = frame.getParent().getSize(); 824 pWidth = s.width; 825 pHeight = s.height; 826 827 828 newX = startingBounds.x - deltaX; 829 newY = startingBounds.y - deltaY; 830 831 if(newX + i.left <= -__x) 833 newX = -__x - i.left + 1; 834 if(newY + i.top <= -__y) 835 newY = -__y - i.top + 1; 836 if(newX + __x + i.right >= pWidth) 837 newX = pWidth - __x - i.right - 1; 838 if(newY + __y + i.bottom >= pHeight) 839 newY = pHeight - __y - i.bottom - 1; 840 841 getDesktopManager().dragFrame(frame, newX, newY); 842 return; 843 } 844 845 if(!frame.isResizable()) { 846 return; 847 } 848 849 newX = frame.getX(); 850 newY = frame.getY(); 851 newW = frame.getWidth(); 852 newH = frame.getHeight(); 853 854 parentBounds = frame.getParent().getBounds(); 855 856 switch(resizeDir) { 857 case RESIZE_NONE: 858 return; 859 case NORTH: 860 if(startingBounds.height + deltaY < min.height) 861 deltaY = -(startingBounds.height - min.height); 862 else if(startingBounds.height + deltaY > max.height) 863 deltaY = max.height - startingBounds.height; 864 if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;} 865 866 newX = startingBounds.x; 867 newY = startingBounds.y - deltaY; 868 newW = startingBounds.width; 869 newH = startingBounds.height + deltaY; 870 break; 871 case NORTH_EAST: 872 if(startingBounds.height + deltaY < min.height) 873 deltaY = -(startingBounds.height - min.height); 874 else if(startingBounds.height + deltaY > max.height) 875 deltaY = max.height - startingBounds.height; 876 if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;} 877 878 if(startingBounds.width - deltaX < min.width) 879 deltaX = startingBounds.width - min.width; 880 else if(startingBounds.width - deltaX > max.width) 881 deltaX = -(max.width - startingBounds.width); 882 if (startingBounds.x + startingBounds.width - deltaX > 883 parentBounds.width) { 884 deltaX = startingBounds.x + startingBounds.width - 885 parentBounds.width; 886 } 887 888 newX = startingBounds.x; 889 newY = startingBounds.y - deltaY; 890 newW = startingBounds.width - deltaX; 891 newH = startingBounds.height + deltaY; 892 break; 893 case EAST: 894 if(startingBounds.width - deltaX < min.width) 895 deltaX = startingBounds.width - min.width; 896 else if(startingBounds.width - deltaX > max.width) 897 deltaX = -(max.width - startingBounds.width); 898 if (startingBounds.x + startingBounds.width - deltaX > 899 parentBounds.width) { 900 deltaX = startingBounds.x + startingBounds.width - 901 parentBounds.width; 902 } 903 904 newW = startingBounds.width - deltaX; 905 newH = startingBounds.height; 906 break; 907 case SOUTH_EAST: 908 if(startingBounds.width - deltaX < min.width) 909 deltaX = startingBounds.width - min.width; 910 else if(startingBounds.width - deltaX > max.width) 911 deltaX = -(max.width - startingBounds.width); 912 if (startingBounds.x + startingBounds.width - deltaX > 913 parentBounds.width) { 914 deltaX = startingBounds.x + startingBounds.width - 915 parentBounds.width; 916 } 917 918 if(startingBounds.height - deltaY < min.height) 919 deltaY = startingBounds.height - min.height; 920 else if(startingBounds.height - deltaY > max.height) 921 deltaY = -(max.height - startingBounds.height); 922 if (startingBounds.y + startingBounds.height - deltaY > 923 parentBounds.height) { 924 deltaY = startingBounds.y + startingBounds.height - 925 parentBounds.height ; 926 } 927 928 newW = startingBounds.width - deltaX; 929 newH = startingBounds.height - deltaY; 930 break; 931 case SOUTH: 932 if(startingBounds.height - deltaY < min.height) 933 deltaY = startingBounds.height - min.height; 934 else if(startingBounds.height - deltaY > max.height) 935 deltaY = -(max.height - startingBounds.height); 936 if (startingBounds.y + startingBounds.height - deltaY > 937 parentBounds.height) { 938 deltaY = startingBounds.y + startingBounds.height - 939 parentBounds.height ; 940 } 941 942 newW = startingBounds.width; 943 newH = startingBounds.height - deltaY; 944 break; 945 case SOUTH_WEST: 946 if(startingBounds.height - deltaY < min.height) 947 deltaY = startingBounds.height - min.height; 948 else if(startingBounds.height - deltaY > max.height) 949 deltaY = -(max.height - startingBounds.height); 950 if (startingBounds.y + startingBounds.height - deltaY > 951 parentBounds.height) { 952 deltaY = startingBounds.y + startingBounds.height - 953 parentBounds.height ; 954 } 955 956 if(startingBounds.width + deltaX < min.width) 957 deltaX = -(startingBounds.width - min.width); 958 else if(startingBounds.width + deltaX > max.width) 959 deltaX = max.width - startingBounds.width; 960 if (startingBounds.x - deltaX < 0) { 961 deltaX = startingBounds.x; 962 } 963 964 newX = startingBounds.x - deltaX; 965 newY = startingBounds.y; 966 newW = startingBounds.width + deltaX; 967 newH = startingBounds.height - deltaY; 968 break; 969 case WEST: 970 if(startingBounds.width + deltaX < min.width) 971 deltaX = -(startingBounds.width - min.width); 972 else if(startingBounds.width + deltaX > max.width) 973 deltaX = max.width - startingBounds.width; 974 if (startingBounds.x - deltaX < 0) { 975 deltaX = startingBounds.x; 976 } 977 978 newX = startingBounds.x - deltaX; 979 newY = startingBounds.y; 980 newW = startingBounds.width + deltaX; 981 newH = startingBounds.height; 982 break; 983 case NORTH_WEST: 984 if(startingBounds.width + deltaX < min.width) 985 deltaX = -(startingBounds.width - min.width); 986 else if(startingBounds.width + deltaX > max.width) 987 deltaX = max.width - startingBounds.width; 988 if (startingBounds.x - deltaX < 0) { 989 deltaX = startingBounds.x; 990 } 991 992 if(startingBounds.height + deltaY < min.height) 993 deltaY = -(startingBounds.height - min.height); 994 else if(startingBounds.height + deltaY > max.height) 995 deltaY = max.height - startingBounds.height; 996 if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;} 997 998 newX = startingBounds.x - deltaX; 999 newY = startingBounds.y - deltaY; 1000 newW = startingBounds.width + deltaX; 1001 newH = startingBounds.height + deltaY; 1002 break; 1003 default: 1004 return; 1005 } 1006 getDesktopManager().resizeFrame(frame, newX, newY, newW, newH); 1007 } 1008 1009 public void mouseMoved(MouseEvent e) { 1010 1011 if(!frame.isResizable()) 1012 return; 1013 1014 if (e.getSource() == frame || e.getSource() == getNorthPane()) { 1015 Insets i = frame.getInsets(); 1016 Point ep = new Point(e.getX(), e.getY()); 1017 if (e.getSource() == getNorthPane()) { 1018 Point np = getNorthPane().getLocation(); 1019 ep.x += np.x; 1020 ep.y += np.y; 1021 } 1022 if(ep.x <= i.left) { 1023 if(ep.y < resizeCornerSize + i.top) 1024 frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); 1025 else if(ep.y > frame.getHeight() - resizeCornerSize - i.bottom) 1026 frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR)); 1027 else 1028 frame.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); 1029 } else if(ep.x >= frame.getWidth() - i.right) { 1030 if(e.getY() < resizeCornerSize + i.top) 1031 frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); 1032 else if(ep.y > frame.getHeight() - resizeCornerSize - i.bottom) 1033 frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR)); 1034 else 1035 frame.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); 1036 } else if(ep.y <= i.top) { 1037 if(ep.x < resizeCornerSize + i.left) 1038 frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); 1039 else if(ep.x > frame.getWidth() - resizeCornerSize - i.right) 1040 frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); 1041 else 1042 frame.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); 1043 } else if(ep.y >= frame.getHeight() - i.bottom) { 1044 if(ep.x < resizeCornerSize + i.left) 1045 frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR)); 1046 else if(ep.x > frame.getWidth() - resizeCornerSize - i.right) 1047 frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR)); 1048 else 1049 frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); 1050 } 1051 else 1052 frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return; 1053 } 1054 1055 frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 1056 } 1057 1058 public void mouseExited(MouseEvent e) { 1059 frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 1060 } 1061 }; 1063 protected class ComponentHandler implements ComponentListener { 1064 1069 public void componentResized(ComponentEvent e) { 1070 getHandler().componentResized(e); 1071 } 1072 1073 public void componentMoved(ComponentEvent e) { 1074 getHandler().componentMoved(e); 1075 } 1076 public void componentShown(ComponentEvent e) { 1077 getHandler().componentShown(e); 1078 } 1079 public void componentHidden(ComponentEvent e) { 1080 getHandler().componentHidden(e); 1081 } 1082 } 1083 1084 protected ComponentListener createComponentListener() { 1085 return getHandler(); 1086 } 1087 1088 1089 protected class GlassPaneDispatcher implements MouseInputListener { 1090 public void mousePressed(MouseEvent e) { 1095 getHandler().mousePressed(e); 1096 } 1097 1098 public void mouseEntered(MouseEvent e) { 1099 getHandler().mouseEntered(e); 1100 } 1101 1102 public void mouseMoved(MouseEvent e) { 1103 getHandler().mouseMoved(e); 1104 } 1105 1106 public void mouseExited(MouseEvent e) { 1107 getHandler().mouseExited(e); 1108 } 1109 1110 public void mouseClicked(MouseEvent e) { 1111 getHandler().mouseClicked(e); 1112 } 1113 1114 public void mouseReleased(MouseEvent e) { 1115 getHandler().mouseReleased(e); 1116 } 1117 1118 public void mouseDragged(MouseEvent e) { 1119 getHandler().mouseDragged(e); 1120 } 1121 } 1122 1123 protected MouseInputListener createGlassPaneDispatcher() { 1124 return getHandler(); 1125 } 1126 1127 1128 protected class BasicInternalFrameListener implements InternalFrameListener 1129 { 1130 public void internalFrameClosing(InternalFrameEvent e) { 1135 getHandler().internalFrameClosing(e); 1136 } 1137 1138 public void internalFrameClosed(InternalFrameEvent e) { 1139 getHandler().internalFrameClosed(e); 1140 } 1141 1142 public void internalFrameOpened(InternalFrameEvent e) { 1143 getHandler().internalFrameOpened(e); 1144 } 1145 1146 public void internalFrameIconified(InternalFrameEvent e) { 1147 getHandler().internalFrameIconified(e); 1148 } 1149 1150 public void internalFrameDeiconified(InternalFrameEvent e) { 1151 getHandler().internalFrameDeiconified(e); 1152 } 1153 1154 public void internalFrameActivated(InternalFrameEvent e) { 1155 getHandler().internalFrameActivated(e); 1156 } 1157 1158 1159 public void internalFrameDeactivated(InternalFrameEvent e) { 1160 getHandler().internalFrameDeactivated(e); 1161 } 1162 } 1163 1164 private static boolean isDragging = false; 1165 private class Handler implements ComponentListener, InternalFrameListener, 1166 LayoutManager, MouseInputListener, PropertyChangeListener, 1167 WindowFocusListener, SwingConstants { 1168 1169 public void windowGainedFocus(WindowEvent e) { 1170 } 1171 1172 public void windowLostFocus(WindowEvent e) { 1173 cancelResize(); 1174 } 1175 1176 1178 public void componentResized(ComponentEvent e) { 1179 Rectangle parentNewBounds = ((Component) e.getSource()).getBounds(); 1181 JInternalFrame.JDesktopIcon icon = null; 1182 1183 if (frame != null) { 1184 icon = frame.getDesktopIcon(); 1185 if (frame.isMaximum()) { 1188 frame.setBounds(0, 0, parentNewBounds.width, 1189 parentNewBounds.height); 1190 } 1191 } 1192 1193 if (icon != null) { 1195 Rectangle iconBounds = icon.getBounds(); 1196 int y = iconBounds.y + 1197 (parentNewBounds.height - parentBounds.height); 1198 icon.setBounds(iconBounds.x, y, 1199 iconBounds.width, iconBounds.height); 1200 } 1201 1202 if (!parentBounds.equals(parentNewBounds)) { 1204 parentBounds = parentNewBounds; 1205 } 1206 1207 if (frame != null) frame.validate(); 1209 } 1210 1211 public void componentMoved(ComponentEvent e) {} 1212 public void componentShown(ComponentEvent e) {} 1213 public void componentHidden(ComponentEvent e) {} 1214 1215 1216 public void internalFrameClosed(InternalFrameEvent e) { 1218 frame.removeInternalFrameListener(getHandler()); 1219 } 1220 1221 public void internalFrameActivated(InternalFrameEvent e) { 1222 if (!isKeyBindingRegistered()){ 1223 setKeyBindingRegistered(true); 1224 setupMenuOpenKey(); 1225 setupMenuCloseKey(); 1226 } 1227 if (isKeyBindingRegistered()) 1228 setKeyBindingActive(true); 1229 } 1230 1231 public void internalFrameDeactivated(InternalFrameEvent e) { 1232 setKeyBindingActive(false); 1233 } 1234 1235 public void internalFrameClosing(InternalFrameEvent e) { } 1236 public void internalFrameOpened(InternalFrameEvent e) { } 1237 public void internalFrameIconified(InternalFrameEvent e) { } 1238 public void internalFrameDeiconified(InternalFrameEvent e) { } 1239 1240 1241 public void addLayoutComponent(String name, Component c) {} 1243 public void removeLayoutComponent(Component c) {} 1244 public Dimension preferredLayoutSize(Container c) { 1245 Dimension result; 1246 Insets i = frame.getInsets(); 1247 1248 result = new Dimension(frame.getRootPane().getPreferredSize()); 1249 result.width += i.left + i.right; 1250 result.height += i.top + i.bottom; 1251 1252 if(getNorthPane() != null) { 1253 Dimension d = getNorthPane().getPreferredSize(); 1254 result.width = Math.max(d.width, result.width); 1255 result.height += d.height; 1256 } 1257 1258 if(getSouthPane() != null) { 1259 Dimension d = getSouthPane().getPreferredSize(); 1260 result.width = Math.max(d.width, result.width); 1261 result.height += d.height; 1262 } 1263 1264 if(getEastPane() != null) { 1265 Dimension d = getEastPane().getPreferredSize(); 1266 result.width += d.width; 1267 result.height = Math.max(d.height, result.height); 1268 } 1269 1270 if(getWestPane() != null) { 1271 Dimension d = getWestPane().getPreferredSize(); 1272 result.width += d.width; 1273 result.height = Math.max(d.height, result.height); 1274 } 1275 return result; 1276 } 1277 1278 public Dimension minimumLayoutSize(Container c) { 1279 Dimension result = new Dimension(); 1283 if (getNorthPane() != null && 1284 getNorthPane() instanceof BasicInternalFrameTitlePane ) { 1285 result = new Dimension(getNorthPane().getMinimumSize()); 1286 } 1287 Insets i = frame.getInsets(); 1288 result.width += i.left + i.right; 1289 result.height += i.top + i.bottom; 1290 1291 return result; 1292 } 1293 1294 public void layoutContainer(Container c) { 1295 Insets i = frame.getInsets(); 1296 int cx, cy, cw, ch; 1297 1298 cx = i.left; 1299 cy = i.top; 1300 cw = frame.getWidth() - i.left - i.right; 1301 ch = frame.getHeight() - i.top - i.bottom; 1302 1303 if(getNorthPane() != null) { 1304 Dimension size = getNorthPane().getPreferredSize(); 1305 if (DefaultLookup.getBoolean(frame, BasicInternalFrameUI.this, 1306 "InternalFrame.layoutTitlePaneAtOrigin", false)) { 1307 cy = 0; 1308 ch += i.top; 1309 getNorthPane().setBounds(0, 0, frame.getWidth(), 1310 size.height); 1311 } 1312 else { 1313 getNorthPane().setBounds(cx, cy, cw, size.height); 1314 } 1315 cy += size.height; 1316 ch -= size.height; 1317 } 1318 1319 if(getSouthPane() != null) { 1320 Dimension size = getSouthPane().getPreferredSize(); 1321 getSouthPane().setBounds(cx, frame.getHeight() 1322 - i.bottom - size.height, 1323 cw, size.height); 1324 ch -= size.height; 1325 } 1326 1327 if(getWestPane() != null) { 1328 Dimension size = getWestPane().getPreferredSize(); 1329 getWestPane().setBounds(cx, cy, size.width, ch); 1330 cw -= size.width; 1331 cx += size.width; 1332 } 1333 1334 if(getEastPane() != null) { 1335 Dimension size = getEastPane().getPreferredSize(); 1336 getEastPane().setBounds(cw - size.width, cy, size.width, ch); 1337 cw -= size.width; 1338 } 1339 1340 if(frame.getRootPane() != null) { 1341 frame.getRootPane().setBounds(cx, cy, cw, ch); 1342 } 1343 } 1344 1345 1346 private Component mouseEventTarget = null; 1348 private Component dragSource = null; 1349 1350 public void mousePressed(MouseEvent e) { 1351 if (borderListener != null){ 1356 borderListener.mousePressed(e); 1357 } 1358 forwardMouseEvent(e); 1359 } 1360 1361 1365 public void mouseEntered(MouseEvent e) { 1366 forwardMouseEvent(e); 1367 } 1368 1369 1373 1374 public void mouseMoved(MouseEvent e) { 1375 forwardMouseEvent(e); 1376 } 1377 1378 1382 public void mouseExited(MouseEvent e) { 1383 forwardMouseEvent(e); 1384 } 1385 1386 1390 1391 public void mouseClicked(MouseEvent e) { } 1392 1396 public void mouseReleased(MouseEvent e) { 1397 forwardMouseEvent(e); 1398 } 1399 1400 1404 public void mouseDragged(MouseEvent e) { 1405 forwardMouseEvent(e); 1406 } 1407 1408 1412 private void forwardMouseEvent(MouseEvent e) { 1413 Component target = 1415 findComponentAt(frame.getRootPane().getLayeredPane(), 1416 e.getX(), e.getY()); 1417 1418 while ((target != null) && 1420 ((target.getMouseListeners().length == 0) && 1421 (target.getMouseMotionListeners().length == 0) && 1422 (target.getMouseWheelListeners().length == 0))) { 1423 target = target.getParent(); 1424 } 1425 if (target == null) { 1426 return; 1428 } 1429 1430 int id = e.getID(); 1431 switch(id) { 1432 case MouseEvent.MOUSE_ENTERED: 1433 if (isDragging && !frame.isSelected()) { 1434 return; 1435 } 1436 if (target != mouseEventTarget) { 1437 mouseEventTarget = target; 1438 } 1439 retargetMouseEvent(id, e, mouseEventTarget); 1440 break; 1441 case MouseEvent.MOUSE_PRESSED: 1442 if (target != mouseEventTarget) { 1443 mouseEventTarget = target; 1444 } 1445 retargetMouseEvent(id, e, mouseEventTarget); 1446 dragSource = target; 1448 break; 1449 case MouseEvent.MOUSE_EXITED: 1450 if (isDragging && !frame.isSelected()) { 1451 return; 1452 } 1453 retargetMouseEvent(id, e, mouseEventTarget); 1454 break; 1455 case MouseEvent.MOUSE_CLICKED: 1456 retargetMouseEvent(id, e, mouseEventTarget); 1457 break; 1458 case MouseEvent.MOUSE_MOVED: 1459 if (target != mouseEventTarget) { 1460 retargetMouseEvent(MouseEvent.MOUSE_EXITED, e, 1461 mouseEventTarget); 1462 mouseEventTarget = target; 1463 retargetMouseEvent(MouseEvent.MOUSE_ENTERED, e, 1464 mouseEventTarget); 1465 } 1466 retargetMouseEvent(id, e, mouseEventTarget); 1467 break; 1468 case MouseEvent.MOUSE_DRAGGED: 1469 if (!isDragging) { 1470 isDragging = true; 1471 } 1472 retargetMouseEvent(id, e, dragSource); 1473 break; 1474 case MouseEvent.MOUSE_RELEASED: 1475 if (isDragging) { 1476 retargetMouseEvent(id, e, dragSource); 1477 isDragging = false; 1478 } else { 1479 retargetMouseEvent(id, e, mouseEventTarget); 1480 } 1481 break; 1482 case MouseEvent.MOUSE_WHEEL: 1483 retargetMouseEvent(id, e, mouseEventTarget); 1484 break; 1485 } 1486 } 1487 1488 1494 private Component findComponentAt(Container c, int x, int y) { 1495 if (!c.contains(x, y)) { 1496 return c; 1497 } 1498 int ncomponents = c.getComponentCount(); 1499 Component component[] = c.getComponents(); 1500 for (int i = 0 ; i < ncomponents ; i++) { 1501 Component comp = component[i]; 1502 Point loc = comp.getLocation(); 1503 if ((comp != null) && (comp.contains(x - loc.x, y - loc.y)) && 1504 (comp.getPeer() instanceof LightweightPeer) && 1505 (comp.isVisible() == true)) { 1506 if (comp instanceof Container) { 1509 Container child = (Container) comp; 1510 Point childLoc = child.getLocation(); 1511 Component deeper = findComponentAt(child, 1512 x - childLoc.x, y - childLoc.y); 1513 if (deeper != null) { 1514 return deeper; 1515 } 1516 } else { 1517 return comp; 1518 } 1519 } 1520 } 1521 return c; 1522 } 1523 1524 1527 private void retargetMouseEvent(int id, MouseEvent e, 1528 Component target) { 1529 if (target == null) { 1530 return; 1531 } 1532 1536 Point p = SwingUtilities.convertPoint(frame.getLayeredPane(), 1537 e.getX(), e.getY(), 1538 target); 1539 MouseEvent retargeted = new MouseEvent(target, 1540 id, 1541 e.getWhen(), 1542 e.getModifiers() | e.getModifiersEx(), 1543 p.x, 1544 p.y, 1545 e.getClickCount(), 1546 e.isPopupTrigger()); 1547 target.dispatchEvent(retargeted); 1548 } 1549 1550 1551 public void propertyChange(PropertyChangeEvent evt) { 1553 String prop = (String )evt.getPropertyName(); 1554 JInternalFrame f = (JInternalFrame)evt.getSource(); 1555 Object newValue = evt.getNewValue(); 1556 Object oldValue = evt.getOldValue(); 1557 1558 if (JInternalFrame.IS_CLOSED_PROPERTY == prop) { 1559 if (newValue == Boolean.TRUE) { 1560 cancelResize(); 1561 if ((frame.getParent() != null) && componentListenerAdded) { 1562 frame.getParent().removeComponentListener( 1563 componentListener); 1564 } 1565 closeFrame(f); 1566 } 1567 } else if (JInternalFrame.IS_MAXIMUM_PROPERTY == prop) { 1568 if(newValue == Boolean.TRUE) { 1569 maximizeFrame(f); 1570 } else { 1571 minimizeFrame(f); 1572 } 1573 } else if(JInternalFrame.IS_ICON_PROPERTY == prop) { 1574 if (newValue == Boolean.TRUE) { 1575 iconifyFrame(f); 1576 } else { 1577 deiconifyFrame(f); 1578 } 1579 } else if (JInternalFrame.IS_SELECTED_PROPERTY == prop) { 1580 Component glassPane = f.getGlassPane(); 1581 if (newValue == Boolean.TRUE && oldValue == Boolean.FALSE) { 1582 activateFrame(f); 1583 glassPane.setVisible(false); 1584 } else if (newValue == Boolean.FALSE && 1585 oldValue == Boolean.TRUE) { 1586 deactivateFrame(f); 1587 glassPane.setVisible(true); 1588 } 1589 } else if (prop == "ancestor") { 1590 if (newValue == null) { 1591 cancelResize(); 1592 } 1593 if (frame.getParent() != null) { 1594 parentBounds = f.getParent().getBounds(); 1595 } else { 1596 parentBounds = null; 1597 } 1598 if ((frame.getParent() != null) && !componentListenerAdded) { 1599 f.getParent().addComponentListener(componentListener); 1600 componentListenerAdded = true; 1601 } else if ((newValue == null) && componentListenerAdded) { 1602 if (f.getParent() != null) { 1603 f.getParent().removeComponentListener( 1604 componentListener); 1605 } 1606 componentListenerAdded = false; 1607 } 1608 } else if (JInternalFrame.TITLE_PROPERTY == prop || 1609 prop == "closable" || prop == "iconable" || 1610 prop == "maximizable") { 1611 Dimension dim = frame.getMinimumSize(); 1612 Dimension frame_dim = frame.getSize(); 1613 if (dim.width > frame_dim.width) { 1614 frame.setSize(dim.width, frame_dim.height); 1615 } 1616 } 1617 } 1618 } 1619} 1620 | Popular Tags |