< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java

Print this page




 424                 installWindowListeners(root, root.getParent());
 425             }
 426         }
 427         return;
 428     }
 429 
 430     /**
 431      * A custom layout manager that is responsible for the layout of
 432      * layeredPane, glassPane, menuBar and titlePane, if one has been
 433      * installed.
 434      */
 435     // NOTE: Ideally this would extends JRootPane.RootLayout, but that
 436     //       would force this to be non-static.
 437     private static class MetalRootLayout implements LayoutManager2 {
 438         /**
 439          * Returns the amount of space the layout would like to have.
 440          *
 441          * @param the Container for which this layout manager is being used
 442          * @return a Dimension object containing the layout's preferred size
 443          */

 444         public Dimension preferredLayoutSize(Container parent) {
 445             Dimension cpd, mbd, tpd;
 446             int cpWidth = 0;
 447             int cpHeight = 0;
 448             int mbWidth = 0;
 449             int mbHeight = 0;
 450             int tpWidth = 0;
 451             int tpHeight = 0;
 452             Insets i = parent.getInsets();
 453             JRootPane root = (JRootPane) parent;
 454 
 455             if(root.getContentPane() != null) {
 456                 cpd = root.getContentPane().getPreferredSize();
 457             } else {
 458                 cpd = root.getSize();
 459             }
 460             if (cpd != null) {
 461                 cpWidth = cpd.width;
 462                 cpHeight = cpd.height;
 463             }


 476                                        getTitlePane();
 477                 if (titlePane != null) {
 478                     tpd = titlePane.getPreferredSize();
 479                     if (tpd != null) {
 480                         tpWidth = tpd.width;
 481                         tpHeight = tpd.height;
 482                     }
 483                 }
 484             }
 485 
 486             return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
 487                                  cpHeight + mbHeight + tpWidth + i.top + i.bottom);
 488         }
 489 
 490         /**
 491          * Returns the minimum amount of space the layout needs.
 492          *
 493          * @param the Container for which this layout manager is being used
 494          * @return a Dimension object containing the layout's minimum size
 495          */

 496         public Dimension minimumLayoutSize(Container parent) {
 497             Dimension cpd, mbd, tpd;
 498             int cpWidth = 0;
 499             int cpHeight = 0;
 500             int mbWidth = 0;
 501             int mbHeight = 0;
 502             int tpWidth = 0;
 503             int tpHeight = 0;
 504             Insets i = parent.getInsets();
 505             JRootPane root = (JRootPane) parent;
 506 
 507             if(root.getContentPane() != null) {
 508                 cpd = root.getContentPane().getMinimumSize();
 509             } else {
 510                 cpd = root.getSize();
 511             }
 512             if (cpd != null) {
 513                 cpWidth = cpd.width;
 514                 cpHeight = cpd.height;
 515             }


 527                                        getTitlePane();
 528                 if (titlePane != null) {
 529                     tpd = titlePane.getMinimumSize();
 530                     if (tpd != null) {
 531                         tpWidth = tpd.width;
 532                         tpHeight = tpd.height;
 533                     }
 534                 }
 535             }
 536 
 537             return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
 538                                  cpHeight + mbHeight + tpWidth + i.top + i.bottom);
 539         }
 540 
 541         /**
 542          * Returns the maximum amount of space the layout can use.
 543          *
 544          * @param the Container for which this layout manager is being used
 545          * @return a Dimension object containing the layout's maximum size
 546          */

 547         public Dimension maximumLayoutSize(Container target) {
 548             Dimension cpd, mbd, tpd;
 549             int cpWidth = Integer.MAX_VALUE;
 550             int cpHeight = Integer.MAX_VALUE;
 551             int mbWidth = Integer.MAX_VALUE;
 552             int mbHeight = Integer.MAX_VALUE;
 553             int tpWidth = Integer.MAX_VALUE;
 554             int tpHeight = Integer.MAX_VALUE;
 555             Insets i = target.getInsets();
 556             JRootPane root = (JRootPane) target;
 557 
 558             if(root.getContentPane() != null) {
 559                 cpd = root.getContentPane().getMaximumSize();
 560                 if (cpd != null) {
 561                     cpWidth = cpd.width;
 562                     cpHeight = cpd.height;
 563                 }
 564             }
 565 
 566             if(root.getMenuBar() != null) {


 590             // Only will happen if sums to more than 2 billion units.  Not likely.
 591             if (maxHeight != Integer.MAX_VALUE) {
 592                 maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom;
 593             }
 594 
 595             int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth);
 596             // Similar overflow comment as above
 597             if (maxWidth != Integer.MAX_VALUE) {
 598                 maxWidth += i.left + i.right;
 599             }
 600 
 601             return new Dimension(maxWidth, maxHeight);
 602         }
 603 
 604         /**
 605          * Instructs the layout manager to perform the layout for the specified
 606          * container.
 607          *
 608          * @param the Container for which this layout manager is being used
 609          */

 610         public void layoutContainer(Container parent) {
 611             JRootPane root = (JRootPane) parent;
 612             Rectangle b = root.getBounds();
 613             Insets i = root.getInsets();
 614             int nextY = 0;
 615             int w = b.width - i.right - i.left;
 616             int h = b.height - i.top - i.bottom;
 617 
 618             if(root.getLayeredPane() != null) {
 619                 root.getLayeredPane().setBounds(i.left, i.top, w, h);
 620             }
 621             if(root.getGlassPane() != null) {
 622                 root.getGlassPane().setBounds(i.left, i.top, w, h);
 623             }
 624             // Note: This is laying out the children in the layeredPane,
 625             // technically, these are not our children.
 626             if (root.getWindowDecorationStyle() != JRootPane.NONE &&
 627                      (root.getUI() instanceof MetalRootPaneUI)) {
 628                 JComponent titlePane = ((MetalRootPaneUI)root.getUI()).
 629                                        getTitlePane();




 424                 installWindowListeners(root, root.getParent());
 425             }
 426         }
 427         return;
 428     }
 429 
 430     /**
 431      * A custom layout manager that is responsible for the layout of
 432      * layeredPane, glassPane, menuBar and titlePane, if one has been
 433      * installed.
 434      */
 435     // NOTE: Ideally this would extends JRootPane.RootLayout, but that
 436     //       would force this to be non-static.
 437     private static class MetalRootLayout implements LayoutManager2 {
 438         /**
 439          * Returns the amount of space the layout would like to have.
 440          *
 441          * @param the Container for which this layout manager is being used
 442          * @return a Dimension object containing the layout's preferred size
 443          */
 444         @SuppressWarnings("deprecation")
 445         public Dimension preferredLayoutSize(Container parent) {
 446             Dimension cpd, mbd, tpd;
 447             int cpWidth = 0;
 448             int cpHeight = 0;
 449             int mbWidth = 0;
 450             int mbHeight = 0;
 451             int tpWidth = 0;
 452             int tpHeight = 0;
 453             Insets i = parent.getInsets();
 454             JRootPane root = (JRootPane) parent;
 455 
 456             if(root.getContentPane() != null) {
 457                 cpd = root.getContentPane().getPreferredSize();
 458             } else {
 459                 cpd = root.getSize();
 460             }
 461             if (cpd != null) {
 462                 cpWidth = cpd.width;
 463                 cpHeight = cpd.height;
 464             }


 477                                        getTitlePane();
 478                 if (titlePane != null) {
 479                     tpd = titlePane.getPreferredSize();
 480                     if (tpd != null) {
 481                         tpWidth = tpd.width;
 482                         tpHeight = tpd.height;
 483                     }
 484                 }
 485             }
 486 
 487             return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
 488                                  cpHeight + mbHeight + tpWidth + i.top + i.bottom);
 489         }
 490 
 491         /**
 492          * Returns the minimum amount of space the layout needs.
 493          *
 494          * @param the Container for which this layout manager is being used
 495          * @return a Dimension object containing the layout's minimum size
 496          */
 497         @SuppressWarnings("deprecation")
 498         public Dimension minimumLayoutSize(Container parent) {
 499             Dimension cpd, mbd, tpd;
 500             int cpWidth = 0;
 501             int cpHeight = 0;
 502             int mbWidth = 0;
 503             int mbHeight = 0;
 504             int tpWidth = 0;
 505             int tpHeight = 0;
 506             Insets i = parent.getInsets();
 507             JRootPane root = (JRootPane) parent;
 508 
 509             if(root.getContentPane() != null) {
 510                 cpd = root.getContentPane().getMinimumSize();
 511             } else {
 512                 cpd = root.getSize();
 513             }
 514             if (cpd != null) {
 515                 cpWidth = cpd.width;
 516                 cpHeight = cpd.height;
 517             }


 529                                        getTitlePane();
 530                 if (titlePane != null) {
 531                     tpd = titlePane.getMinimumSize();
 532                     if (tpd != null) {
 533                         tpWidth = tpd.width;
 534                         tpHeight = tpd.height;
 535                     }
 536                 }
 537             }
 538 
 539             return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
 540                                  cpHeight + mbHeight + tpWidth + i.top + i.bottom);
 541         }
 542 
 543         /**
 544          * Returns the maximum amount of space the layout can use.
 545          *
 546          * @param the Container for which this layout manager is being used
 547          * @return a Dimension object containing the layout's maximum size
 548          */
 549         @SuppressWarnings("deprecation")
 550         public Dimension maximumLayoutSize(Container target) {
 551             Dimension cpd, mbd, tpd;
 552             int cpWidth = Integer.MAX_VALUE;
 553             int cpHeight = Integer.MAX_VALUE;
 554             int mbWidth = Integer.MAX_VALUE;
 555             int mbHeight = Integer.MAX_VALUE;
 556             int tpWidth = Integer.MAX_VALUE;
 557             int tpHeight = Integer.MAX_VALUE;
 558             Insets i = target.getInsets();
 559             JRootPane root = (JRootPane) target;
 560 
 561             if(root.getContentPane() != null) {
 562                 cpd = root.getContentPane().getMaximumSize();
 563                 if (cpd != null) {
 564                     cpWidth = cpd.width;
 565                     cpHeight = cpd.height;
 566                 }
 567             }
 568 
 569             if(root.getMenuBar() != null) {


 593             // Only will happen if sums to more than 2 billion units.  Not likely.
 594             if (maxHeight != Integer.MAX_VALUE) {
 595                 maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom;
 596             }
 597 
 598             int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth);
 599             // Similar overflow comment as above
 600             if (maxWidth != Integer.MAX_VALUE) {
 601                 maxWidth += i.left + i.right;
 602             }
 603 
 604             return new Dimension(maxWidth, maxHeight);
 605         }
 606 
 607         /**
 608          * Instructs the layout manager to perform the layout for the specified
 609          * container.
 610          *
 611          * @param the Container for which this layout manager is being used
 612          */
 613         @SuppressWarnings("deprecation")
 614         public void layoutContainer(Container parent) {
 615             JRootPane root = (JRootPane) parent;
 616             Rectangle b = root.getBounds();
 617             Insets i = root.getInsets();
 618             int nextY = 0;
 619             int w = b.width - i.right - i.left;
 620             int h = b.height - i.top - i.bottom;
 621 
 622             if(root.getLayeredPane() != null) {
 623                 root.getLayeredPane().setBounds(i.left, i.top, w, h);
 624             }
 625             if(root.getGlassPane() != null) {
 626                 root.getGlassPane().setBounds(i.left, i.top, w, h);
 627             }
 628             // Note: This is laying out the children in the layeredPane,
 629             // technically, these are not our children.
 630             if (root.getWindowDecorationStyle() != JRootPane.NONE &&
 631                      (root.getUI() instanceof MetalRootPaneUI)) {
 632                 JComponent titlePane = ((MetalRootPaneUI)root.getUI()).
 633                                        getTitlePane();


< prev index next >