DBILITY

java swing file open 본문

java/basic

java swing file open

DBILITY 2016. 10. 28. 14:28
반응형

VS계열이나 Delphi 등의 IDE기반 툴에서 했던 것과 유사합니다.

역시 경험은 중요한 것~한가지를 경험하지 않으면 한가지 지혜가 자라지 않는다는 명심보감(?)의 말씀이 떠오르는 오후~

package com.dbility.apps;
 
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
 
public class FileOpen extends JFrame {
 
    private static final long serialVersionUID = 511012135676462354L;
 
    public static void main(String[] args) {
 
        JFileChooser jfc = new JFileChooser();
 
        jfc.setDoubleBuffered(true);
        jfc.setMultiSelectionEnabled(false);
        jfc.setFileFilter(new FileNameExtensionFilter("HWP File", "hwp"));
 
        int retVal = jfc.showOpenDialog(null);
 
        if ( retVal != JFileChooser.APPROVE_OPTION ){
            JOptionPane.showMessageDialog(null, "파일을 선택하라 말이야");
            return;
        }
 
        JOptionPane.showMessageDialog(null, jfc.getSelectedFile().getPath());
    }
 
}

 

반응형
Comments