Java-JFilechooser窗口顶置
JFrame frame=new JFrame();
frame.setAlwaysOnTop(true);// 设置顶置
frame.setVisible(false);// 隐藏顶置窗口
frame.setBounds(400, 200, 0, 0);
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
jfc.showDialog(frame, "选择文件夹");// 因JFileChooser未知父类窗口,自建一个顶置窗体。
File file = jfc.getSelectedFile();
if (file.isDirectory()) {
System.out.println("文件夹bai:" + file.getAbsolutePath());
} else if (file.isFile()) {
System.out.println("文件:" + file.getAbsolutePath());
}
System.out.println(jfc.getSelectedFile().getName());
JFileChooser 客户端不显示问题,springboot启动类修改headless=false
SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class); builder.headless(false).run(args);