Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c38fcef1
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看板
提交
c38fcef1
编写于
3月 02, 2016
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8147994: [macosx] JScrollPane jitters up/down during trackpad scrolling on MacOS/Aqua
Reviewed-by: alexp, aivanov
上级
815a6a4e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
26 deletion
+40
-26
src/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java
...are/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java
+3
-8
test/javax/swing/JScrollPane/HorizontalMouseWheelOnShiftPressed/HorizontalMouseWheelOnShiftPressed.java
...eelOnShiftPressed/HorizontalMouseWheelOnShiftPressed.java
+37
-18
未找到文件。
src/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java
浏览文件 @
c38fcef1
/*
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, 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
...
...
@@ -870,18 +870,13 @@ public class BasicScrollPaneUI
int
orientation
=
SwingConstants
.
VERTICAL
;
// find which scrollbar to scroll, or return if none
if
(
toScroll
==
null
||
!
toScroll
.
isVisible
())
{
if
(
toScroll
==
null
||
!
toScroll
.
isVisible
()
||
e
.
isShiftDown
())
{
toScroll
=
scrollpane
.
getHorizontalScrollBar
();
if
(
toScroll
==
null
||
!
toScroll
.
isVisible
())
{
return
;
}
orientation
=
SwingConstants
.
HORIZONTAL
;
}
else
if
(
e
.
isShiftDown
()){
JScrollBar
hScroll
=
scrollpane
.
getHorizontalScrollBar
();
if
(
hScroll
!=
null
&&
hScroll
.
isVisible
())
{
toScroll
=
hScroll
;
orientation
=
SwingConstants
.
HORIZONTAL
;
}
}
e
.
consume
();
...
...
test/javax/swing/JScrollPane/
8033000/bug8033000
.java
→
test/javax/swing/JScrollPane/
HorizontalMouseWheelOnShiftPressed/HorizontalMouseWheelOnShiftPressed
.java
浏览文件 @
c38fcef1
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015,
2016,
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
...
...
@@ -20,6 +20,7 @@
* 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
;
...
...
@@ -29,22 +30,23 @@ 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
* @bug 8033000
8147994
* @author Alexander Scherbatiy
* @summary No Horizontal Mouse Wheel Support In BasicScrollPaneUI
* @run main
bug8033000
* @run main
HorizontalMouseWheelOnShiftPressed
*/
public
class
bug8033000
{
public
class
HorizontalMouseWheelOnShiftPressed
{
private
static
JScrollPane
scrollPane
;
private
static
JTextArea
textArea
;
private
static
Point
point
;
private
static
final
int
delta
;
private
static
JFrame
frame
;
static
{
delta
=
OSInfo
.
getOSType
().
equals
(
OSInfo
.
OSType
.
MACOSX
)
?
-
30
:
30
;
...
...
@@ -55,9 +57,17 @@ public class bug8033000 {
Robot
robot
=
new
Robot
();
robot
.
setAutoDelay
(
50
);
SwingUtilities
.
invokeAndWait
(
bug8033000:
:
createAndShowGUI
);
SwingUtilities
.
invokeAndWait
(
HorizontalMouseWheelOnShiftPressed:
:
createAndShowGUI
);
robot
.
waitForIdle
();
try
{
test
(
robot
);
}
finally
{
frame
.
dispose
();
}
}
private
static
void
test
(
Robot
robot
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
Point
locationOnScreen
=
scrollPane
.
getLocationOnScreen
();
point
=
new
Point
(
...
...
@@ -73,7 +83,7 @@ public class bug8033000 {
robot
.
waitForIdle
();
robot
.
mouseWheel
(
delta
);
robot
.
waitForIdle
();
checkScrollPane
(
true
);
checkScrollPane
(
true
,
false
);
// vertical scroll bar is enabled + shift
initScrollPane
(
true
,
false
);
...
...
@@ -82,14 +92,14 @@ public class bug8033000 {
robot
.
mouseWheel
(
delta
);
robot
.
keyRelease
(
KeyEvent
.
VK_SHIFT
);
robot
.
waitForIdle
();
checkScrollPane
(
tru
e
);
checkScrollPane
(
false
,
fals
e
);
// horizontal scroll bar is enabled
initScrollPane
(
false
,
true
);
robot
.
waitForIdle
();
robot
.
mouseWheel
(
delta
);
robot
.
waitForIdle
();
checkScrollPane
(
false
);
checkScrollPane
(
false
,
true
);
// horizontal scroll bar is enabled + shift
initScrollPane
(
false
,
true
);
...
...
@@ -98,14 +108,14 @@ public class bug8033000 {
robot
.
mouseWheel
(
delta
);
robot
.
keyRelease
(
KeyEvent
.
VK_SHIFT
);
robot
.
waitForIdle
();
checkScrollPane
(
false
);
checkScrollPane
(
false
,
true
);
// both scroll bars are enabled
initScrollPane
(
true
,
true
);
robot
.
waitForIdle
();
robot
.
mouseWheel
(
delta
);
robot
.
waitForIdle
();
checkScrollPane
(
true
);
checkScrollPane
(
true
,
false
);
// both scroll bars are enabled + shift
initScrollPane
(
true
,
true
);
...
...
@@ -114,7 +124,7 @@ public class bug8033000 {
robot
.
mouseWheel
(
delta
);
robot
.
keyRelease
(
KeyEvent
.
VK_SHIFT
);
robot
.
waitForIdle
();
checkScrollPane
(
false
);
checkScrollPane
(
false
,
true
);
}
static
void
initScrollPane
(
boolean
vVisible
,
boolean
hVisible
)
throws
Exception
{
...
...
@@ -129,17 +139,25 @@ public class bug8033000 {
});
}
static
void
checkScrollPane
(
boolean
verticalScrolled
)
throws
Exception
{
static
void
checkScrollPane
(
boolean
verticalScrolled
,
boolean
horizontalScrolled
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
if
(
verticalScrolled
)
{
if
(
scrollPane
.
getVerticalScrollBar
().
getValue
()
==
0
||
scrollPane
.
getHorizontalScrollBar
().
getValue
()
!=
0
)
{
if
(
scrollPane
.
getVerticalScrollBar
().
getValue
()
==
0
)
{
throw
new
RuntimeException
(
"Wrong vertical scrolling!"
);
}
}
else
{
if
(
scrollPane
.
getVerticalScrollBar
().
getValue
()
!=
0
)
{
throw
new
RuntimeException
(
"Wrong vertical scrolling!"
);
}
}
if
(
horizontalScrolled
)
{
if
(
scrollPane
.
getHorizontalScrollBar
().
getValue
()
==
0
)
{
throw
new
RuntimeException
(
"Wrong horizontal scrolling!"
);
}
}
else
{
if
(
scrollPane
.
getVerticalScrollBar
().
getValue
()
!=
0
||
scrollPane
.
getHorizontalScrollBar
().
getValue
()
==
0
)
{
if
(
scrollPane
.
getHorizontalScrollBar
().
getValue
()
!=
0
)
{
throw
new
RuntimeException
(
"Wrong horizontal scrolling!"
);
}
}
...
...
@@ -147,9 +165,10 @@ public class bug8033000 {
}
static
void
createAndShowGUI
()
{
JFrame
frame
=
new
JFrame
();
frame
=
new
JFrame
();
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setSize
(
300
,
300
);
frame
.
setLocationRelativeTo
(
null
);
textArea
=
new
JTextArea
(
"Hello World!"
);
scrollPane
=
new
JScrollPane
(
textArea
);
JPanel
panel
=
new
JPanel
(
new
BorderLayout
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录