请问一下,同样是JFileChooser,为什么我的是这样。。。。

Survivors_2012 2014-11-11 05:01:42

别人的

我的
...全文
209 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_39626314 2018-06-19
  • 打赏
  • 举报
回复
请教!为什么我的JFileChooser在本机上能用,把项目部署到Linux之后却没点反应,求大神指点
百里马 2014-11-12
  • 打赏
  • 举报
回复
引用 4 楼 Survivors_2012 的回复:
[quote=引用 2 楼 u012345283 的回复:]

		JFileChooser fileChooser = new JFileChooser(
				FileSystemView.getFileSystemView());
让它根据当前系统来呈现
import javax.swing.filechooser.*;
import javax.swing.*;

public class demo2 extends JFrame {
	JFileChooser filechooser = new JFileChooser(FileSystemView.getFileSystemView());

	public demo2() {
		filechooser.showOpenDialog(demo2.this); // 显示打开文件对话框
	};

	public static void main(String[] args) {
		demo2 a = new demo2();
	};

}
还是这样,请指教。[/quote]

		try {
			UIManager.setLookAndFeel(UIManager
					.getSystemLookAndFeelClassName());
			JFileChooser fileChooser = new JFileChooser();
			fileChooser.showOpenDialog(null);
		} catch (Exception e) {
		}
这样可以了,根据系统来得到UI
cjh_tostring 2014-11-12
  • 打赏
  • 举报
回复
你可以用皮肤来解决这个问题,java里面自带了一些window的皮肤,用上去之后就和系统保持一致了。
Survivors_2012 2014-11-12
  • 打赏
  • 举报
回复
引用 2 楼 u012345283 的回复:

		JFileChooser fileChooser = new JFileChooser(
				FileSystemView.getFileSystemView());
让它根据当前系统来呈现
import javax.swing.filechooser.*;
import javax.swing.*;

public class demo2 extends JFrame {
	JFileChooser filechooser = new JFileChooser(FileSystemView.getFileSystemView());

	public demo2() {
		filechooser.showOpenDialog(demo2.this); // 显示打开文件对话框
	};

	public static void main(String[] args) {
		demo2 a = new demo2();
	};

}
还是这样,请指教。
humanity 2014-11-12
  • 打赏
  • 举报
回复
高大上啊。
引用 2 楼 u012345283 的回复:

		JFileChooser fileChooser = new JFileChooser(
				FileSystemView.getFileSystemView());
让它根据当前系统来呈现
Survivors_2012 2014-11-12
  • 打赏
  • 举报
回复
引用 6 楼 u012345283 的回复:
[quote=引用 4 楼 Survivors_2012 的回复:] [quote=引用 2 楼 u012345283 的回复:]

		JFileChooser fileChooser = new JFileChooser(
				FileSystemView.getFileSystemView());
让它根据当前系统来呈现
import javax.swing.filechooser.*;
import javax.swing.*;

public class demo2 extends JFrame {
	JFileChooser filechooser = new JFileChooser(FileSystemView.getFileSystemView());

	public demo2() {
		filechooser.showOpenDialog(demo2.this); // 显示打开文件对话框
	};

	public static void main(String[] args) {
		demo2 a = new demo2();
	};

}
还是这样,请指教。[/quote]

		try {
			UIManager.setLookAndFeel(UIManager
					.getSystemLookAndFeelClassName());
			JFileChooser fileChooser = new JFileChooser();
			fileChooser.showOpenDialog(null);
		} catch (Exception e) {
		}
这样可以了,根据系统来得到UI[/quote] 可以,表示非常感谢。
百里马 2014-11-11
  • 打赏
  • 举报
回复

		JFileChooser fileChooser = new JFileChooser(
				FileSystemView.getFileSystemView());
让它根据当前系统来呈现
庚武讲堂 2014-11-11
  • 打赏
  • 举报
回复
个人猜测,仅供参考。 别人的是调用操作系统原生的,AWT或SWT框架,你的是Swing模拟的。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧