Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1006692 // inputFilePath - show input form for a file path

JavaX fragment (include)

1  
static void inputFilePath(fS msg, fO action) {
2  
  inputFilePath(msg, userDir(), action);
3  
}
4  
5  
// action: voidfunc(File)
6  
static void inputFilePath(fS msg, final File defaultFile, fO action) {
7  
  awt {
8  
    final JTextField tfPath = jtextfield(f2s(or(defaultFile, userDir())));
9  
    S title = joinStrings(" | ", msg, programName());
10  
    JComponent form = showFormTitled(title,
11  
      unnull(msg), centerAndEast(tfPath, jbutton("Browse...", r {
12  
        JFileChooser fileChooser = new JFileChooser(getTextTrim(tfPath));
13  
        if (fileChooser.showOpenDialog(tfPath) == JFileChooser.APPROVE_OPTION) {
14  
          tfPath.setText(fileChooser.getSelectedFile().getAbsolutePath());
15  
          tfPath.requestFocus();
16  
        }
17  
      })), r {
18  
        callF(action, new File(getTextTrim(tfPath)))
19  
      });
20  
    renameSubmitButton(form, "OK");
21  
  }
22  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006692
Snippet name: inputFilePath - show input form for a file path
Eternal ID of this version: #1006692/14
Text MD5: f2b1543523901ccc9bf11e16ff509d0d
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-31 17:44:00
Source code size: 848 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 554 / 578
Version history: 13 change(s)
Referenced in: [show references]