Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
64c71f34
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看板
提交
64c71f34
编写于
3月 30, 2015
作者:
A
alexsch
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8033000: No Horizontal Mouse Wheel Support In BasicScrollPaneUI
Reviewed-by: serb, azvegint
上级
09ba7191
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
168 addition
and
20 deletion
+168
-20
src/macosx/classes/com/apple/laf/AquaScrollPaneUI.java
src/macosx/classes/com/apple/laf/AquaScrollPaneUI.java
+2
-20
src/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java
...are/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java
+6
-0
test/javax/swing/JScrollPane/8033000/bug8033000.java
test/javax/swing/JScrollPane/8033000/bug8033000.java
+160
-0
未找到文件。
src/macosx/classes/com/apple/laf/AquaScrollPaneUI.java
浏览文件 @
64c71f34
...
@@ -29,6 +29,7 @@ import java.awt.event.*;
...
@@ -29,6 +29,7 @@ import java.awt.event.*;
import
javax.swing.*
;
import
javax.swing.*
;
import
javax.swing.plaf.ComponentUI
;
import
javax.swing.plaf.ComponentUI
;
import
javax.swing.plaf.basic.BasicScrollPaneUI
;
public
class
AquaScrollPaneUI
extends
javax
.
swing
.
plaf
.
basic
.
BasicScrollPaneUI
{
public
class
AquaScrollPaneUI
extends
javax
.
swing
.
plaf
.
basic
.
BasicScrollPaneUI
{
public
static
ComponentUI
createUI
(
final
JComponent
x
)
{
public
static
ComponentUI
createUI
(
final
JComponent
x
)
{
...
@@ -39,28 +40,9 @@ public class AquaScrollPaneUI extends javax.swing.plaf.basic.BasicScrollPaneUI {
...
@@ -39,28 +40,9 @@ public class AquaScrollPaneUI extends javax.swing.plaf.basic.BasicScrollPaneUI {
return
new
XYMouseWheelHandler
();
return
new
XYMouseWheelHandler
();
}
}
// This is a grody hack to trick BasicScrollPaneUI into scrolling horizontally
protected
class
XYMouseWheelHandler
extends
BasicScrollPaneUI
.
MouseWheelHandler
{
// when we notice that the shift key is down. This should be removed when AWT/Swing
// becomes aware of of multi-axis scroll wheels.
protected
class
XYMouseWheelHandler
extends
javax
.
swing
.
plaf
.
basic
.
BasicScrollPaneUI
.
MouseWheelHandler
{
public
void
mouseWheelMoved
(
final
MouseWheelEvent
e
)
{
public
void
mouseWheelMoved
(
final
MouseWheelEvent
e
)
{
JScrollBar
vScrollBar
=
null
;
boolean
wasVisible
=
false
;
if
(
e
.
isShiftDown
())
{
vScrollBar
=
scrollpane
.
getVerticalScrollBar
();
if
(
vScrollBar
!=
null
)
{
wasVisible
=
vScrollBar
.
isVisible
();
vScrollBar
.
setVisible
(
false
);
}
}
super
.
mouseWheelMoved
(
e
);
super
.
mouseWheelMoved
(
e
);
if
(
wasVisible
)
{
vScrollBar
.
setVisible
(
true
);
}
// Consume the event even when the scrollBar is invisible
// Consume the event even when the scrollBar is invisible
// see #7124320
// see #7124320
e
.
consume
();
e
.
consume
();
...
...
src/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java
浏览文件 @
64c71f34
...
@@ -876,6 +876,12 @@ public class BasicScrollPaneUI
...
@@ -876,6 +876,12 @@ public class BasicScrollPaneUI
return
;
return
;
}
}
orientation
=
SwingConstants
.
HORIZONTAL
;
orientation
=
SwingConstants
.
HORIZONTAL
;
}
else
if
(
e
.
isShiftDown
()){
JScrollBar
hScroll
=
scrollpane
.
getHorizontalScrollBar
();
if
(
hScroll
!=
null
&&
hScroll
.
isVisible
())
{
toScroll
=
hScroll
;
orientation
=
SwingConstants
.
HORIZONTAL
;
}
}
}
e
.
consume
();
e
.
consume
();
...
...
test/javax/swing/JScrollPane/8033000/bug8033000.java
0 → 100644
浏览文件 @
64c71f34
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.BorderLayout
;
import
java.awt.Point
;
import
java.awt.Robot
;
import
java.awt.event.KeyEvent
;
import
javax.swing.JFrame
;
import
javax.swing.JPanel
;
import
javax.swing.JScrollPane
;
import
javax.swing.JTextArea
;
import
javax.swing.SwingUtilities
;
import
javax.swing.UIManager
;
import
sun.awt.OSInfo
;
/**
* @test
* @bug 8033000
* @author Alexander Scherbatiy
* @summary No Horizontal Mouse Wheel Support In BasicScrollPaneUI
* @run main bug8033000
*/
public
class
bug8033000
{
private
static
JScrollPane
scrollPane
;
private
static
JTextArea
textArea
;
private
static
Point
point
;
private
static
final
int
delta
;
static
{
delta
=
OSInfo
.
getOSType
().
equals
(
OSInfo
.
OSType
.
MACOSX
)
?
-
30
:
30
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Robot
robot
=
new
Robot
();
robot
.
setAutoDelay
(
50
);
SwingUtilities
.
invokeAndWait
(
bug8033000:
:
createAndShowGUI
);
robot
.
waitForIdle
();
SwingUtilities
.
invokeAndWait
(()
->
{
Point
locationOnScreen
=
scrollPane
.
getLocationOnScreen
();
point
=
new
Point
(
locationOnScreen
.
x
+
scrollPane
.
getWidth
()
/
2
,
locationOnScreen
.
y
+
scrollPane
.
getHeight
()
/
2
);
});
robot
.
mouseMove
(
point
.
x
,
point
.
y
);
robot
.
waitForIdle
();
// vertical scroll bar is enabled
initScrollPane
(
true
,
false
);
robot
.
waitForIdle
();
robot
.
mouseWheel
(
delta
);
robot
.
waitForIdle
();
checkScrollPane
(
true
);
// vertical scroll bar is enabled + shift
initScrollPane
(
true
,
false
);
robot
.
waitForIdle
();
robot
.
keyPress
(
KeyEvent
.
VK_SHIFT
);
robot
.
mouseWheel
(
delta
);
robot
.
keyRelease
(
KeyEvent
.
VK_SHIFT
);
robot
.
waitForIdle
();
checkScrollPane
(
true
);
// horizontal scroll bar is enabled
initScrollPane
(
false
,
true
);
robot
.
waitForIdle
();
robot
.
mouseWheel
(
delta
);
robot
.
waitForIdle
();
checkScrollPane
(
false
);
// horizontal scroll bar is enabled + shift
initScrollPane
(
false
,
true
);
robot
.
waitForIdle
();
robot
.
keyPress
(
KeyEvent
.
VK_SHIFT
);
robot
.
mouseWheel
(
delta
);
robot
.
keyRelease
(
KeyEvent
.
VK_SHIFT
);
robot
.
waitForIdle
();
checkScrollPane
(
false
);
// both scroll bars are enabled
initScrollPane
(
true
,
true
);
robot
.
waitForIdle
();
robot
.
mouseWheel
(
delta
);
robot
.
waitForIdle
();
checkScrollPane
(
true
);
// both scroll bars are enabled + shift
initScrollPane
(
true
,
true
);
robot
.
waitForIdle
();
robot
.
keyPress
(
KeyEvent
.
VK_SHIFT
);
robot
.
mouseWheel
(
delta
);
robot
.
keyRelease
(
KeyEvent
.
VK_SHIFT
);
robot
.
waitForIdle
();
checkScrollPane
(
false
);
}
static
void
initScrollPane
(
boolean
vVisible
,
boolean
hVisible
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
scrollPane
.
getVerticalScrollBar
().
setValue
(
0
);
scrollPane
.
getHorizontalScrollBar
().
setValue
(
0
);
textArea
.
setRows
(
vVisible
?
100
:
1
);
textArea
.
setColumns
(
hVisible
?
100
:
1
);
scrollPane
.
getVerticalScrollBar
().
setVisible
(
vVisible
);
scrollPane
.
getHorizontalScrollBar
().
setVisible
(
hVisible
);
});
}
static
void
checkScrollPane
(
boolean
verticalScrolled
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
if
(
verticalScrolled
)
{
if
(
scrollPane
.
getVerticalScrollBar
().
getValue
()
==
0
||
scrollPane
.
getHorizontalScrollBar
().
getValue
()
!=
0
)
{
throw
new
RuntimeException
(
"Wrong vertical scrolling!"
);
}
}
else
{
if
(
scrollPane
.
getVerticalScrollBar
().
getValue
()
!=
0
||
scrollPane
.
getHorizontalScrollBar
().
getValue
()
==
0
)
{
throw
new
RuntimeException
(
"Wrong horizontal scrolling!"
);
}
}
});
}
static
void
createAndShowGUI
()
{
JFrame
frame
=
new
JFrame
();
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setSize
(
300
,
300
);
textArea
=
new
JTextArea
(
"Hello World!"
);
scrollPane
=
new
JScrollPane
(
textArea
);
JPanel
panel
=
new
JPanel
(
new
BorderLayout
());
panel
.
add
(
scrollPane
,
BorderLayout
.
CENTER
);
frame
.
getContentPane
().
add
(
panel
);
frame
.
setVisible
(
true
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录