當前位置: 首頁>>代碼示例>>Java>>正文


Java JRootPane.getContentPane方法代碼示例

本文整理匯總了Java中javax.swing.JRootPane.getContentPane方法的典型用法代碼示例。如果您正苦於以下問題:Java JRootPane.getContentPane方法的具體用法?Java JRootPane.getContentPane怎麽用?Java JRootPane.getContentPane使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JRootPane的用法示例。


在下文中一共展示了JRootPane.getContentPane方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: minimumLayoutSize

import javax.swing.JRootPane; //導入方法依賴的package包/類
public Dimension minimumLayoutSize(Container parent)
{
    Insets insets = parent.getInsets();

    JRootPane root = (JRootPane) parent;

    Dimension cpd = null;

    if (root.getContentPane() != null)
    {
        cpd = root.getContentPane().getMinimumSize();
    }
    else
    {
        cpd = root.getSize();
    }

    return getDimension(insets, cpd.width, cpd.height);
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:20,代碼來源:LuckRootPaneLayout.java

示例2: maximumLayoutSize

import javax.swing.JRootPane; //導入方法依賴的package包/類
public Dimension maximumLayoutSize(Container parent)
{
    Insets insets = parent.getInsets();

    JRootPane root = (JRootPane) parent;

    Dimension cpd = null;

    if (root.getContentPane() != null)
    {
        cpd = root.getContentPane().getMaximumSize();
    }
    else
    {
        cpd = root.getSize();
    }

    return getDimension(insets, cpd.width, cpd.height);
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:20,代碼來源:LuckRootPaneLayout.java

示例3: componentAt

import javax.swing.JRootPane; //導入方法依賴的package包/類
private Component componentAt( int x, int y, Component parent, boolean scanRootPanes ) {
        if ( scanRootPanes && parent instanceof JRootPane ) {
            JRootPane rootPane = (JRootPane) parent;
            parent = rootPane.getContentPane();
        }

        Component child = parent;
        if ( !parent.contains( x, y ) ) {
            child = null;
        }
        else {
            synchronized ( parent.getTreeLock() ) {
                if ( parent instanceof Container ) {
                    Container container = (Container) parent;
                    int ncomponents = container.getComponentCount();
                    for ( int i = 0; i < ncomponents; i++ ) {
                        Component comp = container.getComponent( i );
                        if ( comp != null
                             && comp.isVisible()
//                             && ( dragAndDropSupport == null || !dragAndDropSupport.isDragPanel( comp ) )
                             && comp.contains( x - comp.getX(), y - comp.getY() ) ) {
                            child = comp;
                            break;
                        }
                    }
                }
            }
        }

        if ( child != null ) {
            if ( parent instanceof JTabbedPane && child != parent ) {
                child = ( (JTabbedPane) parent ).getSelectedComponent();
            }
            x -= child.getX();
            y -= child.getY();
        }
        return child != parent && child != null ? componentAt( x, y, child, scanRootPanes ) : child;
    }
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:39,代碼來源:HUDNode.java

示例4: preferredLayoutSize

import javax.swing.JRootPane; //導入方法依賴的package包/類
public Dimension preferredLayoutSize(Container parent)
 {
     Insets insets = parent.getInsets();

     JRootPane root = (JRootPane) parent;

     int h = 0;

     Dimension cpd = null;

     if (root.getContentPane() != null)
     {
         cpd = root.getContentPane().getPreferredSize();

if (!(root.getContentPane() instanceof LuckBackgroundPanel)
        && root.getWindowDecorationStyle() != JRootPane.NONE)
{
	h += UIManager.getInt(LuckRootPaneUIBundle.TITLEPANEL_HEIGHT);
}
     }
     else
     {
         cpd = root.getSize();
     }

     h += cpd.height;

     return getDimension(insets, cpd.width, h);
 }
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:30,代碼來源:LuckRootPaneLayout.java

示例5: uninstallOther

import javax.swing.JRootPane; //導入方法依賴的package包/類
protected void uninstallOther(JRootPane root)
{
    Container content = root.getContentPane();

    if (content != null && content instanceof LuckBackgroundPanel)
    {
        LuckBackgroundPanel bgPanel = (LuckBackgroundPanel) content;

        root.setContentPane(bgPanel.getContentPane());

        root.setJMenuBar(bgPanel.getJMenuBar());

        bgPanel.uninstallMenubar(true);
    }

    int style = root.getWindowDecorationStyle();

    if (style == JRootPane.NONE)
    {
        root.repaint();

        root.revalidate();
    }

    Window window = SwingUtilities.getWindowAncestor(root);

    if (window != null)
    {
        window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:32,代碼來源:LuckRootPaneUI.java

示例6: preferredLayoutSize

import javax.swing.JRootPane; //導入方法依賴的package包/類
public Dimension preferredLayoutSize(Container parent)
{
  JRootPane rp = (JRootPane) parent;
  JLayeredPane layeredPane = rp.getLayeredPane();
  Component contentPane = rp.getContentPane();
  Component menuBar = rp.getJMenuBar();

  // We must synchronize here, otherwise we cannot guarantee that the
  // prefSize is still non-null when returning.
  synchronized (this)
    {
      if (prefSize == null)
        {
          Insets i = parent.getInsets();
          prefSize = new Dimension(i.left + i.right, i.top + i.bottom);
          Dimension contentPrefSize = contentPane.getPreferredSize();
          prefSize.width += contentPrefSize.width;
          prefSize.height += contentPrefSize.height
                             + titlePane.getPreferredSize().height;
          if (menuBar != null)
            {
              Dimension menuBarSize = menuBar.getPreferredSize();
              if (menuBarSize.width > contentPrefSize.width)
                prefSize.width += menuBarSize.width - contentPrefSize.width;
              prefSize.height += menuBarSize.height;
            }
        }
      // Return a copy here so the cached value won't get trashed by some
      // other component.
      return new Dimension(prefSize);
  }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:33,代碼來源:MetalRootPaneUI.java

示例7: layoutContainer

import javax.swing.JRootPane; //導入方法依賴的package包/類
public void layoutContainer(Container parent)
{
    JRootPane root = (JRootPane) parent;
    Rectangle bound = root.getBounds();
    Insets inset = root.getInsets();

    // 獲取內容麵板實際寬度, 減去左右邊框麵積
    // Calculate the actual width
    int w = bound.width - inset.right - inset.left;

    // 獲取內容麵板實際高度, 減去上下邊框麵積
    int h = bound.height - inset.top - inset.bottom;

    // 設置層級麵板在根窗格中的位置
    // Calculate the actual height
    if(root.getLayeredPane() != null)
    {
        root.getLayeredPane().setBounds(inset.left, inset.top, w, h);
    }

    // 布局玻璃窗格
    // layout LayeredPane
    if(root.getGlassPane() != null)
    {
        root.getGlassPane().setBounds(inset.left, inset.top, w, h);
    }

    // 獲取當前內容麵板
    // get current ContentPane
    Container content = root.getContentPane();

    LuckRootPaneUI rootPaneUI = (LuckRootPaneUI) root.getUI();

    // 使用 <code>LuckBackgroundPanel</code>替換當前的內容麵板
    // Use <code>LuckBackgroundPanel</code> replace the current contents of the panel
    if(!(content instanceof LuckBackgroundPanel))
    {
        Window window = SwingUtilities.getWindowAncestor(root);

       	boolean isResizeableOnInit = LuckWindowUtil.isResizable(window);

    	int initStyle = root.getWindowDecorationStyle();

        if(initStyle != JRootPane.NONE)
        {
            //
            LuckTitlePanel titlePanel = rootPaneUI.createTitlePanel(initStyle, isResizeableOnInit);

            LuckBackgroundPanel background = rootPaneUI.createContentPane(titlePanel, content);

            root.setContentPane(background);
        }
    }

    root.getContentPane().setBounds(0, 0, w, h);
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:57,代碼來源:LuckRootPaneLayout.java

示例8: layoutContainer

import javax.swing.JRootPane; //導入方法依賴的package包/類
public void layoutContainer(Container parent)
{
  JRootPane rp = (JRootPane) parent;
  JLayeredPane layeredPane = rp.getLayeredPane();
  Component contentPane = rp.getContentPane();
  Component menuBar = rp.getJMenuBar();
  Component glassPane = rp.getGlassPane();

  if (glassPaneBounds == null || layeredPaneBounds == null
      || contentPaneBounds == null || menuBarBounds == null)
    {
      Insets i = rp.getInsets();
      int containerWidth = parent.getBounds().width - i.left - i.right;
      int containerHeight = parent.getBounds().height - i.top - i.bottom;

      // 1. The glassPane fills entire viewable region (bounds - insets).
      // 2. The layeredPane filles entire viewable region.
      // 3. The titlePane is placed at the upper edge of the layeredPane.
      // 4. The menuBar is positioned at the upper edge of layeredPane.
      // 5. The contentPane fills viewable region minus menuBar minus
      //    titlePane, if present.

      // +-------------------------------+
      // |  JLayeredPane                 |
      // |  +--------------------------+ |
      // |  | titlePane                + |
      // |  +--------------------------+ |
      // |  +--------------------------+ |
      // |  | menuBar                  | |
      // |  +--------------------------+ |
      // |  +--------------------------+ |
      // |  |contentPane               | |
      // |  |                          | |
      // |  |                          | |
      // |  |                          | |
      // |  +--------------------------+ |
      // +-------------------------------+

      // Setup titlePaneBounds.
      if (titlePaneBounds == null)
        titlePaneBounds = new Rectangle();
      titlePaneBounds.width = containerWidth;
      titlePaneBounds.height = titlePane.getPreferredSize().height;

      // Setup menuBarBounds.
      if (menuBarBounds == null)
        menuBarBounds = new Rectangle();
      menuBarBounds.setBounds(0,
                              titlePaneBounds.y + titlePaneBounds.height,
                              containerWidth, 0);
      if (menuBar != null)
        {
          Dimension menuBarSize = menuBar.getPreferredSize();
          if (menuBarSize.height > containerHeight)
            menuBarBounds.height = containerHeight;
          else
            menuBarBounds.height = menuBarSize.height;
        }

      // Setup contentPaneBounds.
      if (contentPaneBounds == null)
        contentPaneBounds = new Rectangle();
      contentPaneBounds.setBounds(0,
                                  menuBarBounds.y + menuBarBounds.height,
                                  containerWidth,
                                  containerHeight - menuBarBounds.y
                                  - menuBarBounds.height);
      glassPaneBounds = new Rectangle(i.left, i.top, containerWidth, containerHeight);
      layeredPaneBounds = new Rectangle(i.left, i.top, containerWidth, containerHeight);
    }

  // Layout components.
  glassPane.setBounds(glassPaneBounds);
  layeredPane.setBounds(layeredPaneBounds);
  if (menuBar != null)
    menuBar.setBounds(menuBarBounds);
  contentPane.setBounds(contentPaneBounds);
  titlePane.setBounds(titlePaneBounds);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:80,代碼來源:MetalRootPaneUI.java


注:本文中的javax.swing.JRootPane.getContentPane方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。