• <bdo id='LOpj5'></bdo><ul id='LOpj5'></ul>

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

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

      1. <small id='LOpj5'></small><noframes id='LOpj5'>

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

        时间:2023-09-28

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

                <tfoot id='rdmGu'></tfoot>
                  <tbody id='rdmGu'></tbody>
                <legend id='rdmGu'><style id='rdmGu'><dir id='rdmGu'><q id='rdmGu'></q></dir></style></legend>
                1. <small id='rdmGu'></small><noframes id='rdmGu'>

                  本文介绍了如何制作“打开方式"对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  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);
                          }
                     } ...
                  }
                  

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

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

                  相关文章

                  最新文章

                    <bdo id='uhQsS'></bdo><ul id='uhQsS'></ul>

                  1. <tfoot id='uhQsS'></tfoot>

                  2. <legend id='uhQsS'><style id='uhQsS'><dir id='uhQsS'><q id='uhQsS'></q></dir></style></legend>

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

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