• <bdo id='f3VAr'></bdo><ul id='f3VAr'></ul>
        <tfoot id='f3VAr'></tfoot>

        <small id='f3VAr'></small><noframes id='f3VAr'>

      1. <i id='f3VAr'><tr id='f3VAr'><dt id='f3VAr'><q id='f3VAr'><span id='f3VAr'><b id='f3VAr'><form id='f3VAr'><ins id='f3VAr'></ins><ul id='f3VAr'></ul><sub id='f3VAr'></sub></form><legend id='f3VAr'></legend><bdo id='f3VAr'><pre id='f3VAr'><center id='f3VAr'></center></pre></bdo></b><th id='f3VAr'></th></span></q></dt></tr></i><div id='f3VAr'><tfoot id='f3VAr'></tfoot><dl id='f3VAr'><fieldset id='f3VAr'></fieldset></dl></div>

        <legend id='f3VAr'><style id='f3VAr'><dir id='f3VAr'><q id='f3VAr'></q></dir></style></legend>

        如何制作“打开方式"对话框?

        How to make the #39;open with#39; dialog box?(如何制作“打开方式对话框?)
          <bdo id='ic563'></bdo><ul id='ic563'></ul>
            1. <tfoot id='ic563'></tfoot>

              <small id='ic563'></small><noframes id='ic563'>

              <i id='ic563'><tr id='ic563'><dt id='ic563'><q id='ic563'><span id='ic563'><b id='ic563'><form id='ic563'><ins id='ic563'></ins><ul id='ic563'></ul><sub id='ic563'></sub></form><legend id='ic563'></legend><bdo id='ic563'><pre id='ic563'><center id='ic563'></center></pre></bdo></b><th id='ic563'></th></span></q></dt></tr></i><div id='ic563'><tfoot id='ic563'></tfoot><dl id='ic563'><fieldset id='ic563'></fieldset></dl></div>

                    <tbody id='ic563'></tbody>

                1. <legend id='ic563'><style id='ic563'><dir id='ic563'><q id='ic563'></q></dir></style></legend>
                2. 本文介绍了如何制作“打开方式"对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I made a program to search for .txt files.

                  If I click a file it means that the "open with" dialog box should appear, and that dialog box will contain a list of all installed programs.

                  I am using this code for searching through the files:

                    public File[] finder( String dirName)
                    {
                        // Create a file object on the directory.
                        File dir = new File(dirName);
                        // Return a list of all files in the directory.
                        return dir.listFiles(new FilenameFilter();
                    } 
                  
                    public boolean accept(File dir, String filename)
                    { 
                        return filename.endsWith(".txt");
                    } 
                  

                  What Java code can I use to make the "open with" dialog box appear?

                  解决方案

                  You should use FileChooser for this. Take a look here:

                  //Create a file chooser
                  final JFileChooser fc = new JFileChooser();
                  ...
                  //In response to a button click:
                  int returnVal = fc.showOpenDialog(aComponent);
                  
                  
                  public void actionPerformed(ActionEvent e) {
                      //Handle open button action.
                      if (e.getSource() == openButton) {
                          int returnVal = fc.showOpenDialog(FileChooserDemo.this);
                  
                          if (returnVal == JFileChooser.APPROVE_OPTION) {
                              File file = fc.getSelectedFile();
                              //This is where a real application would open the file.
                              log.append("Opening: " + file.getName() + "." + newline);
                          } else {
                              log.append("Open command cancelled by user." + newline);
                          }
                     } ...
                  }
                  

                  这篇关于如何制作“打开方式"对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                    <tbody id='kKLSa'></tbody>
                    <tfoot id='kKLSa'></tfoot>
                    <legend id='kKLSa'><style id='kKLSa'><dir id='kKLSa'><q id='kKLSa'></q></dir></style></legend>
                          <bdo id='kKLSa'></bdo><ul id='kKLSa'></ul>

                          <small id='kKLSa'></small><noframes id='kKLSa'>

                        • <i id='kKLSa'><tr id='kKLSa'><dt id='kKLSa'><q id='kKLSa'><span id='kKLSa'><b id='kKLSa'><form id='kKLSa'><ins id='kKLSa'></ins><ul id='kKLSa'></ul><sub id='kKLSa'></sub></form><legend id='kKLSa'></legend><bdo id='kKLSa'><pre id='kKLSa'><center id='kKLSa'></center></pre></bdo></b><th id='kKLSa'></th></span></q></dt></tr></i><div id='kKLSa'><tfoot id='kKLSa'></tfoot><dl id='kKLSa'><fieldset id='kKLSa'></fieldset></dl></div>