仿Windows界面的JFileChooser 2016-05-30 | Visit count 1234567891011121314151617181920try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());} catch (Exception e1) { e1.printStackTrace();}String out = new SimpleDateFormat("yyMMddhhmmss").format(new Date());JFileChooser fc = new JFileChooser();//设置默认文件名fc.setSelectedFile(new File("项目内容表" + out + ".xls"));fc.setDialogType(JFileChooser.FILES_ONLY);fc.setDialogTitle("选择保存路径");fc.setMultiSelectionEnabled(false);int result = fc.showSaveDialog(fc);if (result == JFileChooser.APPROVE_OPTION) { //保存 //your code here} else { //取消 //your code here}如图:更换图标:重写其父类JFrame:123JFrame jf=new JFrame();ImageIcon imgIcon = new ImageIcon(ProExportUtil.class.getResource("icon.png"));jf.setIconImage(imgIcon.getImage());将上面13行代码改为:1int result = fc.showSaveDialog(jf);效果如图所示:请作者喝瓶肥宅水🥤¥本文作者: MrBird本文链接: http://mrbird.cc/仿Windows界面的JFileChooser.html版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!