下面列出了javax.swing.JRootPane#repaint ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Uninstalls any state that <code>installClientDecorations</code> has
* installed.
* <p>
* NOTE: This may be called if you haven't installed client decorations
* yet (ie before <code>installClientDecorations</code> has been invoked).
*
* @param root the root
*/
private void uninstallClientDecorations(JRootPane root)
{
uninstallBorder(root);
uninstallWindowListeners(root);
setTitlePane(root, null);
uninstallLayout(root);
// We have to revalidate/repaint root if the style is JRootPane.NONE
// only. When we needs to call revalidate/repaint with other styles
// the installClientDecorations is always called after this method
// imediatly and it will cause the revalidate/repaint at the proper
// time.
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE)
{
root.repaint();
root.revalidate();
}
// Reset the cursor, as we may have changed it to a resize cursor
if (window != null)
{
window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
window = null;
}
/**
* Installs the necessary state onto the JRootPane to render client
* decorations. This is ONLY invoked if the <code>JRootPane</code> has a
* decoration style other than <code>JRootPane.NONE</code>.
*
* @param root the JRootPane.
*/
private void installClientDecorations(JRootPane root) {
installBorder(root);
if (root.getParent() instanceof JFrame || root.getParent() instanceof JDialog) {
if (PlatformUtils.isMac()) {
makeFrameBackgroundTransparent(root);
} else {
shapeWindow(root);
}
}
JComponent titlePane = createTitlePane(root);
setTitlePane(root, titlePane);
installWindowListeners(root, root.getParent());
installLayout(root);
if (window != null) {
root.revalidate();
root.repaint();
}
}
/**
* Uninstalls any state that <code>installClientDecorations</code> has
* installed.
*
* <p>NOTE: This may be called if you haven't installed client decorations
* yet (ie before <code>installClientDecorations</code> has been invoked).
* </p>
*
* @param root the JRootPane.
*/
private void uninstallClientDecorations(JRootPane root) {
uninstallBorder(root);
uninstallWindowListeners(root);
setTitlePane(root, null);
uninstallLayout(root);
// We have to revalidate/repaint root if the style is JRootPane.NONE
// only. When we needs to call revalidate/repaint with other styles
// the installClientDecorations is always called after this method
// imediatly and it will cause the revalidate/repaint at the proper
// time.
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE) {
root.repaint();
root.revalidate();
}
// Reset the cursor, as we may have changed it to a resize cursor
if (window != null) {
window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
window = null;
}
private void removeFloater() {
if (mFloater != null) {
JRootPane rootPane = getRootPane();
Container parent = mFloater.getParent();
Rectangle bounds = mFloater.getBounds();
UIUtilities.convertRectangle(bounds, parent, rootPane);
if (parent != null) {
parent.remove(mFloater);
}
mFloater = null;
if (rootPane != null) {
rootPane.repaint(bounds);
}
}
}
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));
}
}
/**
* Installs the necessary state onto the JRootPane to render client
* decorations. This is ONLY invoked if the <code>JRootPane</code>
* has a decoration style other than <code>JRootPane.NONE</code>.
*
* @param root the root
*/
private void installClientDecorations(JRootPane root)
{
installBorder(root);
JComponent titlePane = createTitlePane(root);
setTitlePane(root, titlePane);
installWindowListeners(root, root.getParent());
installLayout(root);
//只有在窗口边框是半透明的情况下,以下才需要设置窗口透明
//* 注意:本类中的此处代码的目的就是为了实现半透明边框窗口的
//* 正常显示,而且仅针对此目的。如果该边框不为透明,则此处也就不需要设置
//* 窗口透明了,那么如果你的程序其它地方需要窗口透明的话,自行.setWindowOpaque(..)
//* 就行了,由开发者自先决定,此处就不承载过多的要求了
if (!BeautyEyeLNFHelper.__isFrameBorderOpaque()
&& window != null)
{
//** 20111222 by jb2011,让窗口全透明(用以实现窗口的透明边框效果)
// AWTUtilities.setWindowOpaque(window, false);
// TODO BUG:1)目前可知,在jdk1.7.0_u6下,JDialog的半透明边框的透明度比原设计深一倍
// TODO BUG:2)目前可知,在jdk1.6.0_u33下+win7平台下,JFrame窗口被调置成透明后,
// 该窗口内所在文本都会被反走样(不管你要没有要求反走样),真悲具,这应该
// 是官方AWTUtilities.setWindowOpaque(..)bug导致的,1.7.0_u6同样存在该问题,
// 使用BeautyEye时,遇到这样的问题只能自行使用__isFrameBorderOpaque中指定的
// 不透明边框才行(这样此类的以下代码就不用执行,也就不用触发该bug了),但
// JDialog不受此bug影响,诡异!
WindowTranslucencyHelper.setWindowOpaque(window, false);
root.revalidate();
root.repaint();
}
}