zoukankan      html  css  js  c++  java
  • JAVA GUI学习

     1 public class JFileChooserKnow
     2 {
     3 
     4     /**
     5      * @param args
     6      */
     7     public static void main(String[] args)
     8     {
     9         // TODO Auto-generated method stub
    10         //文件选择器
    11         JFileChooser chooser = new JFileChooser();
    12         //设置文件过滤器
    13         chooser.setFileFilter(new FileNameExtensionFilter("图片","gif","jpg","bmp"));
    14         //获取用户的操作结果,是确认了,还是取消了
    15         int choose = chooser.showOpenDialog(null);
    16         //判断选择的结果
    17         if(choose == JFileChooser.APPROVE_OPTION)
    18         {
    19             //获取文件路径
    20             JOptionPane.showMessageDialog(null, chooser.getSelectedFile().getAbsolutePath());
    21         }
    22     }
    23 
    24 }
  • 相关阅读:
    POJ 2689
    NEFU 109
    HDU 2098
    NEFU 2
    NEFU 117
    NEFU 84
    POJ 1061
    NEFU116 GCD
    NEFU 115
    HDU 2099
  • 原文地址:https://www.cnblogs.com/Wfei/p/3332726.html
Copyright © 2011-2022 走看看