1 | static void inputDirPath(fS msg, fO action) {
|
2 | inputDirPath(msg, userDir(), action); |
3 | } |
4 | |
5 | // action: voidfunc(File) |
6 | static void inputDirPath(fS msg, final File defaultDir, fO action) {
|
7 | awt {
|
8 | final JTextField tfPath = jtextfield(f2s(or(defaultDir, userDir()))); |
9 | S title = joinStrings(" | ", msg, programName());
|
10 | final Runnable ok = r {
|
11 | callF(action, new File(getTextTrim(tfPath))) |
12 | }; |
13 | JComponent form = showFormTitled(title, |
14 | unnull(msg), centerAndEast(tfPath, jbutton("Browse...", r {
|
15 | JFileChooser fileChooser = new JFileChooser(getTextTrim(tfPath)); |
16 | fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
17 | fileChooser.setAcceptAllFileFilterUsed(false); |
18 | |
19 | if (fileChooser.showOpenDialog(tfPath) == JFileChooser.APPROVE_OPTION) {
|
20 | tfPath.setText(fileChooser.getSelectedFile().getAbsolutePath()); |
21 | //tfPath.requestFocus(); |
22 | callF(ok); |
23 | disposePossiblyInternalFrame(tfPath); |
24 | } |
25 | })), ok); |
26 | renameSubmitButton(form, "OK"); |
27 | } |
28 | } |
Began life as a copy of #1006692
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1015950 |
| Snippet name: | inputDirPath - show input form for a directory path. Calls action in UI thread |
| Eternal ID of this version: | #1015950/5 |
| Text MD5: | 92220da1946a8d29c672a4cfdefaea2a |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-12-03 19:18:07 |
| Source code size: | 1073 bytes / 28 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 634 / 683 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |