Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
8a08d694
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看板
提交
8a08d694
编写于
3月 25, 2011
作者:
M
mrkam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7027694: /jfc/FileChooserDemo demo needs to be improved
Reviewed-by: rupashka
上级
a0226263
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
212 addition
and
129 deletion
+212
-129
src/share/demo/jfc/FileChooserDemo/ExampleFileSystemView.java
...share/demo/jfc/FileChooserDemo/ExampleFileSystemView.java
+8
-5
src/share/demo/jfc/FileChooserDemo/ExampleFileView.java
src/share/demo/jfc/FileChooserDemo/ExampleFileView.java
+19
-13
src/share/demo/jfc/FileChooserDemo/FileChooserDemo.java
src/share/demo/jfc/FileChooserDemo/FileChooserDemo.java
+185
-111
未找到文件。
src/share/demo/jfc/FileChooserDemo/ExampleFileSystemView.java
浏览文件 @
8a08d694
/*
* Copyright (c) 1998, 20
05
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 20
11
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -29,13 +29,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import
java.io.File
;
import
java.io.IOException
;
import
javax.swing.filechooser.FileSystemView
;
/**
* This is a simple example that uses the FileSystemView class.
* You can provide a superclass of the FileSystemView class with your own functionality.
...
...
@@ -43,6 +42,7 @@ import javax.swing.filechooser.FileSystemView;
* @author Pavel Porvatov
*/
public
class
ExampleFileSystemView
extends
FileSystemView
{
/**
* Creates a new folder with the default name "New folder". This method is invoked
* when the user presses the "New folder" button.
...
...
@@ -65,8 +65,9 @@ public class ExampleFileSystemView extends FileSystemView {
* Returns a list which appears in a drop-down list of the FileChooser component.
* In this implementation only the home directory is returned.
*/
@Override
public
File
[]
getRoots
()
{
return
new
File
[]
{
getHomeDirectory
()
};
return
new
File
[]
{
getHomeDirectory
()
};
}
/**
...
...
@@ -74,9 +75,11 @@ public class ExampleFileSystemView extends FileSystemView {
* A string with all upper case letters is returned for a directory.
* A string with all lower case letters is returned for a file.
*/
@Override
public
String
getSystemDisplayName
(
File
f
)
{
String
displayName
=
super
.
getSystemDisplayName
(
f
);
return
f
.
isDirectory
()
?
displayName
.
toUpperCase
()
:
displayName
.
toLowerCase
();
return
f
.
isDirectory
()
?
displayName
.
toUpperCase
()
:
displayName
.
toLowerCase
();
}
}
src/share/demo/jfc/FileChooserDemo/ExampleFileView.java
浏览文件 @
8a08d694
/*
* Copyright (c) 1998, 20
05
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 20
11
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -29,14 +29,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import
javax.swing.*
;
import
javax.swing.filechooser.*
;
import
java.io.File
;
import
java.util.Hashtable
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* A convenience implementation of the FileView interface that
...
...
@@ -61,15 +60,19 @@ import java.util.Hashtable;
* @author Jeff Dinkins
*/
public
class
ExampleFileView
extends
FileView
{
private
final
Hashtable
<
String
,
Icon
>
icons
=
new
Hashtable
<
String
,
Icon
>();
private
final
Hashtable
<
File
,
String
>
fileDescriptions
=
new
Hashtable
<
File
,
String
>();
private
final
Hashtable
<
String
,
String
>
typeDescriptions
=
new
Hashtable
<
String
,
String
>();
private
final
Map
<
String
,
Icon
>
icons
=
new
HashMap
<
String
,
Icon
>();
private
final
Map
<
File
,
String
>
fileDescriptions
=
new
HashMap
<
File
,
String
>();
private
final
Map
<
String
,
String
>
typeDescriptions
=
new
HashMap
<
String
,
String
>();
/**
* The name of the file. Do nothing special here. Let
* the system file view handle this.
* @see FileView#getName
*/
@Override
public
String
getName
(
File
f
)
{
return
null
;
}
...
...
@@ -86,6 +89,7 @@ public class ExampleFileView extends FileView {
*
* @see FileView#getDescription
*/
@Override
public
String
getDescription
(
File
f
)
{
return
fileDescriptions
.
get
(
f
);
}
...
...
@@ -112,6 +116,7 @@ public class ExampleFileView extends FileView {
*
* @see FileView#getTypeDescription
*/
@Override
public
String
getTypeDescription
(
File
f
)
{
return
typeDescriptions
.
get
(
getExtension
(
f
));
}
...
...
@@ -122,12 +127,12 @@ public class ExampleFileView extends FileView {
*/
private
String
getExtension
(
File
f
)
{
String
name
=
f
.
getName
();
if
(
name
!=
null
)
{
if
(
name
!=
null
)
{
int
extensionIndex
=
name
.
lastIndexOf
(
'.'
);
if
(
extensionIndex
<
0
)
{
if
(
extensionIndex
<
0
)
{
return
null
;
}
return
name
.
substring
(
extensionIndex
+
1
).
toLowerCase
();
return
name
.
substring
(
extensionIndex
+
1
).
toLowerCase
();
}
return
null
;
}
...
...
@@ -147,10 +152,11 @@ public class ExampleFileView extends FileView {
*
* @see FileView#getIcon
*/
@Override
public
Icon
getIcon
(
File
f
)
{
Icon
icon
=
null
;
String
extension
=
getExtension
(
f
);
if
(
extension
!=
null
)
{
if
(
extension
!=
null
)
{
icon
=
icons
.
get
(
extension
);
}
return
icon
;
...
...
@@ -168,11 +174,11 @@ public class ExampleFileView extends FileView {
*
* @see FileView#isTraversable
*/
@Override
public
Boolean
isTraversable
(
File
f
)
{
// if (some_reason) {
// return Boolean.FALSE;
// }
return
null
;
// Use default from FileSystemView
}
}
src/share/demo/jfc/FileChooserDemo/FileChooserDemo.java
浏览文件 @
8a08d694
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录