本文整理汇总了Java中javax.swing.JRootPane.getWindowDecorationStyle方法的典型用法代码示例。如果您正苦于以下问题:Java JRootPane.getWindowDecorationStyle方法的具体用法?Java JRootPane.getWindowDecorationStyle怎么用?Java JRootPane.getWindowDecorationStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JRootPane
的用法示例。
在下文中一共展示了JRootPane.getWindowDecorationStyle方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installBorder
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* <p>给根窗格安装边框</p>
*
* <p>To install JRootPane border</p>
*
* @param root <code>JRootPane</code>
*/
protected void installBorder(JRootPane root)
{
int style = root.getWindowDecorationStyle();
// 这句必须,否则会出现无法安装边框的情况
// Sentence must, otherwise there will not be installed border situation
root.setBorder(null);
//
if(LuckPlatformUtils.isWindows())
{
root.setBorder(UIManager.getBorder(borderKeys[style]));
}
else
{
root.setBorder(LineBorder.createBlackLineBorder());
}
}
示例2: 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);
}
示例3: installUI
import javax.swing.JRootPane; //导入方法依赖的package包/类
@Override
public void installUI(JComponent c)
{
super.installUI(c);
JRootPane root = (JRootPane) c;
int style = root.getWindowDecorationStyle();
if (style != JRootPane.NONE)
{
installClientDecorations(root);
}
}
示例4: 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));
}
}
示例5: installUI
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* Installs this UI to the root pane. If the
* <code>windowDecorationsStyle</code> property is set on the root pane,
* the Metal window decorations are installed on the root pane.
*
* @param c
*/
public void installUI(JComponent c)
{
super.installUI(c);
JRootPane rp = (JRootPane) c;
if (rp.getWindowDecorationStyle() != JRootPane.NONE)
installWindowDecorations(rp);
}
示例6: uninstallUI
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* Uninstalls the UI from the root pane. This performs the superclass
* behaviour and uninstalls the window decorations that have possibly been
* installed by {@link #installUI}.
*
* @param c the root pane
*/
public void uninstallUI(JComponent c)
{
JRootPane rp = (JRootPane) c;
if (rp.getWindowDecorationStyle() != JRootPane.NONE)
uninstallWindowDecorations(rp);
super.uninstallUI(c);
}
示例7: propertyChange
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* Receives notification if any of the JRootPane's property changes. In
* particular this catches changes to the <code>windowDecorationStyle</code>
* property and installs the window decorations accordingly.
*
* @param ev the property change event
*/
public void propertyChange(PropertyChangeEvent ev)
{
super.propertyChange(ev);
String propertyName = ev.getPropertyName();
if (propertyName.equals("windowDecorationStyle"))
{
JRootPane rp = (JRootPane) ev.getSource();
if (rp.getWindowDecorationStyle() != JRootPane.NONE)
installWindowDecorations(rp);
else
uninstallWindowDecorations(rp);
}
}
示例8: mouseClicked
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* 处理JFrame的双击标题面板缩放事件
*/
public void mouseClicked(MouseEvent e)
{
Window window = (Window) e.getSource();
if(window instanceof JFrame)
{
JFrame frame = (JFrame) window;
JRootPane root = frame.getRootPane();
// 不包含窗体装饰直接返回
if (root.getWindowDecorationStyle() == JRootPane.NONE)
{
return;
}
// 不在标题栏覆盖区域直接返回
if(!titleArea.contains(e.getPoint()))
{
return;
}
if ((e.getClickCount() % 2) == 0 && ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0))
{
int state = frame.getExtendedState();
if (frame.isResizable())
{
if ((state & JFrame.MAXIMIZED_BOTH) != 0)
{
frame.setExtendedState(state & ~JFrame.MAXIMIZED_BOTH);
}
else
{
frame.setExtendedState(state | JFrame.MAXIMIZED_BOTH);
}
}
}
}
}
示例9: mousePressed
import javax.swing.JRootPane; //导入方法依赖的package包/类
/**
* v1.0.1:修复自定义拖拽区域BUG, 增加边界判断
*/
public void mousePressed(MouseEvent e)
{
Window window = (Window) e.getSource();
JRootPane root = LuckWindowUtil.getRootPane(window);
// 不包含窗体装饰直接返回
if (root == null || root.getWindowDecorationStyle() == JRootPane.NONE)
{
return;
}
if (window != null)
{
window.toFront();
}
// 如果是单击标题栏, 则标记接下来的拖动事件为移动窗口, 判断当前鼠标是否超出边界
if (dragArea.contains(e.getPoint())
&& dragCursor == Cursor.DEFAULT_CURSOR)
{
if(window instanceof JFrame)
{
JFrame frame = (JFrame)window;
// 如果当前窗体是全屏状态则直接返回
if(frame.getExtendedState() == JFrame.MAXIMIZED_BOTH)
{
return;
}
}
// 设置为可以移动并记录当前坐标
isMovingWindow = true;
dragOffsetX = e.getPoint().x;
dragOffsetY = e.getPoint().y;
}
else if(LuckWindowUtil.isResizable(window))
{
dragOffsetX = e.getPoint().x;
dragOffsetY = e.getPoint().y;
dragWidth = window.getWidth();
dragHeight = window.getHeight();
JRootPane rootPane = LuckWindowUtil.getRootPane(window);
if(rootPane != null && LuckWindowUtil.isResizable(window))
{
dragCursor = getCursor(dragWidth, dragHeight, e.getPoint(), rootPane.getInsets());
}
}
}
示例10: 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);
}
示例11: propertyChange
import javax.swing.JRootPane; //导入方法依赖的package包/类
public void propertyChange(PropertyChangeEvent e)
{
super.propertyChange(e);
String propertyName = e.getPropertyName();
if (propertyName == null)
{
return;
}
JRootPane root = (JRootPane) e.getSource();
Container parent = root.getParent();
if (!(parent instanceof Window))
{
return;
}
if (WINDOWDECORATIONSTYLE_EVENT.equals(propertyName))
{
int style = root.getWindowDecorationStyle();
uninstallClientDecorations(root);
if (style != JRootPane.NONE)
{
installClientDecorations(root);
}
}
else if (ANCESTOR_EVENT.equals(propertyName))
{
uninstallWindowListener(root);
if (((JRootPane) e.getSource()).getWindowDecorationStyle() != JRootPane.NONE)
{
installWindowListeners(root);
}
}
}
示例12: installClientDecorations
import javax.swing.JRootPane; //导入方法依赖的package包/类
@Override
protected void installClientDecorations(JRootPane root)
{
super.installClientDecorations(root);
Window window = SwingUtilities.getWindowAncestor(root);
boolean isResize = LuckWindowUtil.isResizable(window);
int style = root.getWindowDecorationStyle();
installTitlePane(root, createTitlePanel(style, isResize), window);
}