javax.swing.JRootPane#getLayeredPane ( )源码实例Demo

下面列出了javax.swing.JRootPane#getLayeredPane ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pumpernickel   文件: AbstractSearchHighlight.java
private void initialize(HighlightInfo info) {
	highlightInfo = info;
	currentID = id;

	JRootPane rootPane = info.jc.getRootPane();
	layeredPane = rootPane.getLayeredPane();

	highlights = highlightInfo.createHighlights();
	for (HighlightImage highlight : highlights) {
		layeredPane.add(highlight, JLayeredPane.DRAG_LAYER);
	}
	updateAnimation(highlights, 0);

	timer.start();

}
 
源代码2 项目: littleluck   文件: LuckMetalRootPaneUI.java
protected void installTitlePane(JRootPane root, LuckTitlePanel titlePane, Window window)
{
    JLayeredPane layeredPane = root.getLayeredPane();

    JComponent oldTitlePane = getTitlePane();

    if (oldTitlePane != null)
    {
        oldTitlePane.setVisible(false);

        layeredPane.remove(oldTitlePane);
    }

    if (titlePane != null)
    {
    	titlePane.setOpaque(true);
    	
        layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);

        titlePane.setVisible(true);
    }

    this.titlePane = titlePane;
}
 
源代码3 项目: beautyeye   文件: BERootPaneUI.java
/**
 * Sets the window title pane -- the JComponent used to provide a plaf a
 * way to override the native operating system's window title pane with
 * one whose look and feel are controlled by the plaf.  The plaf creates
 * and sets this value; the default is null, implying a native operating
 * system window title pane.
 *
 * @param root the root
 * @param titlePane the title pane
 */
private void setTitlePane(JRootPane root, JComponent titlePane) 
{
	JLayeredPane layeredPane = root.getLayeredPane();
	JComponent oldTitlePane = getTitlePane();

	if (oldTitlePane != null)
	{
		oldTitlePane.setVisible(false);
		layeredPane.remove(oldTitlePane);
	}
	if (titlePane != null) 
	{
		layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
		titlePane.setVisible(true);
	}
	this.titlePane = titlePane;
}
 
源代码4 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * Sets the window title pane -- the JComponent used to provide a plaf a way
 * to override the native operating system's window title pane with one
 * whose look and feel are controlled by the plaf. The plaf creates and sets
 * this value; the default is null, implying a native operating system
 * window title pane.
 *
 * @param root      content the <code>JComponent</code> to use for the
 *                  window title pane.
 * @param titlePane the SeaGlassTitlePane.
 */
private void setTitlePane(JRootPane root, JComponent titlePane) {
    JLayeredPane layeredPane  = root.getLayeredPane();
    JComponent   oldTitlePane = getTitlePane();

    if (oldTitlePane != null) {
        oldTitlePane.setVisible(false);
        layeredPane.remove(oldTitlePane);
    }

    if (titlePane != null) {
        layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
        titlePane.setVisible(true);
    }

    this.titlePane = titlePane;
}
 
源代码5 项目: pumpernickel   文件: TextHighlightSheet.java
public void actionPerformed(ActionEvent e) {

			if (active && layeredPane == null) {
				JRootPane rootPane = jtc.getRootPane();
				if (rootPane == null)
					return;

				layeredPane = rootPane.getLayeredPane();
				int layer = JLayeredPane.DRAG_LAYER.intValue() * 3 / 4
						+ JLayeredPane.POPUP_LAYER.intValue() * 1 / 4;
				layeredPane.add(TextHighlightSheet.this, new Integer(layer));
				makeHighlightsDirty();
			}

			if (layeredPane == null) {
				animator.stop();
				return;
			}

			layeredPane.repaint(getX(), getY(), getWidth(), getHeight());
			if (active && searchPhrase.length() > 0) {
				setVisible(true);
				if (opacity == 1) {
					animator.stop();
				} else {
					opacity = (float) Math.min(1, opacity + .3);
				}
			} else {
				if (opacity == 0) {
					setVisible(false);
					animator.stop();
				} else {
					opacity = (float) Math.max(0, opacity - .3);
				}
			}
			layeredPane.repaint(getX(), getY(), getWidth(), getHeight());
		}
 
源代码6 项目: littleluck   文件: LuckMetalRootPaneLayout.java
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;

    // 获取内容面板实际高度, 减去上下边框面积
    // Calculate the actual height
    int h = bound.height - inset.top - inset.bottom;

    // 设置层级面板在根窗格中的位置
    // layout LayeredPane
    if(root.getLayeredPane() != null)
    {
        root.getLayeredPane().setBounds(inset.left, inset.top, w, h);
    }

    // 玻璃窗格是在层级面板中,所以坐标从(0, 0)开始
    // layout GlassPane
    if(root.getGlassPane() != null)
    {
        root.getGlassPane().setBounds(inset.left, inset.top, w, h);
    }

    int nextY = 0;

    RootPaneUI rootPaneUI = root.getUI();

    if(rootPaneUI instanceof LuckMetalRootPaneUI)
    {
        // 布局标题面板
        // layout TitlePane
        Component titlePanel = ((LuckMetalRootPaneUI)rootPaneUI).getTitlePane();

        // 如果未取消窗体装饰
        if (titlePanel != null)
        {
            titlePanel.setBounds(0, nextY, w, titlePanel.getHeight());

            nextY += titlePanel.getHeight();
        }
    }

    // 布局JMenuBar
    // layout JMenuBar
    JMenuBar menuBar = root.getJMenuBar();

    if(menuBar != null && menuBar.isVisible())
    {
        menuBar.setBounds(0, nextY, w, menuBar.getPreferredSize().height);

        nextY += menuBar.getPreferredSize().getHeight();
    }

    // 布局内容面板
    // layout ContentPane
    root.getContentPane().setBounds(0, nextY, w, h - nextY);
}
 
源代码7 项目: littleluck   文件: LuckRootPaneLayout.java
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);
}
 
源代码8 项目: beautyeye   文件: BERootPaneUI.java
/**
 * Instructs the layout manager to perform the layout for the specified
 * container.
 *
 * @param parent the parent
 */ 
@SuppressWarnings("deprecation")
public void layoutContainer(Container parent) 
{
	JRootPane root = (JRootPane) parent;
	Rectangle b = root.getBounds();
	Insets i = root.getInsets();
	int nextY = 0;
	int w = b.width - i.right - i.left;
	int h = b.height - i.top - i.bottom;

	if(root.getLayeredPane() != null)
	{
		root.getLayeredPane().setBounds(i.left, i.top, w, h);
	}
	if(root.getGlassPane() != null) 
	{
		root.getGlassPane().setBounds(i.left, i.top, w, h);
	}
	// Note: This is laying out the children in the layeredPane,
	// technically, these are not our children.
	if (root.getWindowDecorationStyle() != JRootPane.NONE &&
			(root.getUI() instanceof BERootPaneUI)) 
	{
		JComponent titlePane = ((BERootPaneUI)root.getUI()).
		getTitlePane();
		if (titlePane != null) 
		{
			Dimension tpd = titlePane.getPreferredSize();
			if (tpd != null) 
			{
				int tpHeight = tpd.height;
				titlePane.setBounds(0, 0, w, tpHeight);
				nextY += tpHeight;
			}                    
		}
	}
	if(root.getMenuBar() != null
			//* 该 行代码由Jack Jiang于2012-10-20增加:目的是为解决当
			//* MebuBar被设置不可见时任然被错误地当作可视组件占据布局空间,这
			//* 在BE LNF中的表现就是当menuBar不可见,它占据的那块空间将会是全透明
			//* 的空白区。这个问题在Metal主题中仍然存在(就是设置JFrame.setDefaultLookAndFeelDecorated(true);
			//* JDialog.setDefaultLookAndFeelDecorated(true);后的Metal主题状态),
			//* 可能官方不认为这是个bug吧。
			//* 为什么无论什么外观当在使用系统窗口边框类型时不会出现这样的情况呢?它
			//* 可能是由于窗口外观的实现原理决定的吧(按理说是同一原理),有待深究!!!
			&& root.getMenuBar().isVisible()
			) 
	{
		Dimension mbd = root.getMenuBar().getPreferredSize();
		root.getMenuBar().setBounds(0, nextY, w, mbd.height);
		nextY += mbd.height;
	}
	if(root.getContentPane() != null
			//* 该 行代码由Jack Jiang于2012-10-20增加:目的是为解决与menubar在设置可见性时遇难到的一样的问题
			&& root.getContentPane().isVisible()
			) 
	{
		Dimension cpd = root.getContentPane().getPreferredSize();
		root.getContentPane().setBounds(0, nextY, w, 
				h < nextY ? 0 : h - nextY);
	}
}
 
源代码9 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * Instructs the layout manager to perform the layout for the specified
 * container.
 *
 * @param parent the Container for which this layout manager is being
 *               used
 */
public void layoutContainer(Container parent) {
    JRootPane root  = (JRootPane) parent;
    Rectangle b     = root.getBounds();
    Insets    i     = root.getInsets();
    int       nextY = 0;
    int       w     = b.width - i.right - i.left;
    int       h     = b.height - i.top - i.bottom;

    if (root.getLayeredPane() != null) {
        root.getLayeredPane().setBounds(i.left, i.top, w, h);
    }

    if (root.getGlassPane() != null) {
        root.getGlassPane().setBounds(i.left, i.top, w, h);
    }
    // Note: This is laying out the children in the layeredPane,
    // technically, these are not our children.
    if (root.getWindowDecorationStyle() != JRootPane.NONE && (root.getUI() instanceof SeaGlassRootPaneUI)) {
        JComponent titlePane = ((SeaGlassRootPaneUI) root.getUI()).getTitlePane();

        if (titlePane != null) {
            Dimension tpd = titlePane.getPreferredSize();

            if (tpd != null) {
                int tpHeight = tpd.height;

                titlePane.setBounds(0, 0, w, tpHeight);
                nextY += tpHeight;
            }
        }
    }

    if (root.getJMenuBar() != null) {
        boolean   menuInTitle = (root.getClientProperty("JRootPane.MenuInTitle") == Boolean.TRUE);
        Dimension mbd         = root.getJMenuBar().getPreferredSize();
        int x = menuInTitle? 20 : 0;
        root.getJMenuBar().setBounds(x, menuInTitle ? 0 : nextY, w, mbd.height);
        root.getJMenuBar().setOpaque(false);
        root.getJMenuBar().setBackground(transparentColor);
        if (!menuInTitle) {
            nextY += mbd.height;
        }
    }

    if (root.getContentPane() != null) {
        /* Dimension cpd = */ root.getContentPane().getPreferredSize();
        root.getContentPane().setBounds(0, nextY, w, h < nextY ? 0 : h - nextY);
    }
}