• <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>

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

        时间:2023-06-27
          <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);
                          }
                     } ...
                  }
                  

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

                  上一篇:Java Swing 内部框架作为对话框 下一篇:JavaFX 创建警报并获得结果

                  相关文章

                    <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'>

                    1. <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>