Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1d63e50b
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1d63e50b
编写于
9月 09, 2009
作者:
A
alexp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6878792: Sample provided in javax.swing.JLayer class description is not usable
Reviewed-by: rupashka
上级
a3d57685
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
21 deletion
+63
-21
src/share/classes/javax/swing/JLayer.java
src/share/classes/javax/swing/JLayer.java
+63
-21
未找到文件。
src/share/classes/javax/swing/JLayer.java
浏览文件 @
1d63e50b
...
...
@@ -56,28 +56,70 @@ import java.security.PrivilegedAction;
* {@code JLayer} is a good solution if you only need to do custom painting
* over compound component or catch input events from its subcomponents.
* <pre>
* import javax.swing.*;
* import javax.swing.plaf.LayerUI;
* import java.awt.*;
*
* public class JLayerSample {
*
* private static JLayer<JComponent> createLayer() {
* // This custom layerUI will fill the layer with translucent green
* // and print out all mouseMotion events generated within its borders
* LayerUI<JComponent> layerUI = new LayerUI<JComponent>() {
*
* public void paint(Graphics g, JComponent c) {
* // paint the layer as is
* super.paint(g, c);
* // fill it with the translucent green
* g.setColor(new Color(0, 128, 0, 128));
* g.fillRect(0, 0, c.getWidth(), c.getHeight());
* }
*
* public void installUI(JComponent c) {
* super.installUI(c);
* // enable mouse motion events for the layer's subcomponents
* ((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK);
* }
*
* public void uninstallUI(JComponent c) {
* super.uninstallUI(c);
* // reset the layer event mask
* ((JLayer) c).setLayerEventMask(0);
* }
*
* // overridden method which catches MouseMotion events
* public void eventDispatched(AWTEvent e, JLayer<? extends JComponent> l) {
* System.out.println("AWTEvent detected: " + e);
* }
* };
* // create a component to be decorated with the layer
* JPanel panel = new JPanel();
* panel.add(new JButton("JButton"));
* // This custom layerUI will fill the layer with translucent green
* // and print out all mouseMotion events generated within its borders
* LayerUI<JPanel> layerUI = new LayerUI<JPanel>() {
* public void paint(Graphics g, JCompo nent c) {
* // paint the layer as is
* super.paint(g, c);
* // fill it with the translucent green
* g.setColor(new Color(0, 128, 0, 128));
* g.fillRect(0, 0, c.getWidth(), c.getHeight());
* }
* // overridden method which catches MouseMotion events
* public void eventDispatched(AWTEvent e, JLayer<JPanel> l) {
* System.out.println("AWTEvent detected: " + e);
* }
* };
* // create the layer for the panel using our custom layerUI
* JLayer<JPanel> layer = new JLayer<JPanel>(panel, layerUI);
* // work with the layer as with any other Swing component
* frame.add(layer);
* JPanel panel = new JPanel();
* panel.add(new JButton("JButton"));
*
* // create the layer for the panel using our custom layerUI
* return new JLayer<JComponent>(panel, layerUI);
* }
*
* private static void createAndShowGUI() {
* final JFrame frame = new JFrame();
* frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
*
* // work with the layer as with any other Swing component
* frame.add(createLayer());
*
* frame.setSize(200, 200);
* frame.setLocationRelativeTo(null);
* frame.setVisible(true);
* }
*
* public static void main(String[] args) throws Exception {
* SwingUtilities.invokeAndWait(new Runnable() {
* public void run() {
* createAndShowGUI();
* }
* });
* }
* }
* </pre>
*
* <b>Note:</b> {@code JLayer} doesn't support the following methods:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录