JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 請問一下開多檔案問題
yji35j4





發文: 2
積分: 0
於 2013-11-14 19:10 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
目前的話,是能開啟一個檔案,想請問一下要怎麼才能再開檔那邊可以一次選取多個資料呢??
之後再一次把選取到的檔名印出

import java.awt.BorderLayout;
import java.awt.FileDialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class main extends JFrame {
  public main() {
    JButton btnFile = new JButton("開啟檔案");
    JPanel jp = new JPanel();
    jp.add(btnFile);
    this.setLayout(new BorderLayout());
    this.add(jp);
    this.setVisible(true);
    this.setSize(200, 80);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setLocationRelativeTo(null);
    btnFile.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        btnFileAction();
      }
    });
  }
  public void btnFileAction() {    
    FileDialog fd = new FileDialog(this, "", FileDialog.LOAD);
    fd.setVisible(true);
    String file = fd.getFile();
    if (file == null)
      return;
    file = fd.getDirectory() + file;    
    System.out.print(file);
  }
  public static void main(String[] args) {
    new main();
  }
}


reply to postreply to post
» JWorld@TW »  Java 新手區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8