MCPcopy Index your code
hub / github.com/benfry/processing4 / selectImpl

Method selectImpl

core/src/processing/awt/ShimAWT.java:796–836  ·  view source on GitHub ↗
(final String prompt,
                                final String callbackMethod,
                                final File defaultSelection,
                                final Object callbackObject,
                                final Frame parentFrame,
                                final int mode)

Source from the content-addressed store, hash-verified

794
795
796 static public void selectImpl(final String prompt,
797 final String callbackMethod,
798 final File defaultSelection,
799 final Object callbackObject,
800 final Frame parentFrame,
801 final int mode) {
802 File selectedFile = null;
803
804 if (PApplet.useNativeSelect) {
805 FileDialog dialog = new FileDialog(parentFrame, prompt, mode);
806 if (defaultSelection != null) {
807 dialog.setDirectory(defaultSelection.getParent());
808 dialog.setFile(defaultSelection.getName());
809 }
810
811 dialog.setVisible(true);
812 String directory = dialog.getDirectory();
813 String filename = dialog.getFile();
814 if (filename != null) {
815 selectedFile = new File(directory, filename);
816 }
817
818 } else {
819 JFileChooser chooser = new JFileChooser();
820 chooser.setDialogTitle(prompt);
821 if (defaultSelection != null) {
822 chooser.setSelectedFile(defaultSelection);
823 }
824
825 int result = -1;
826 if (mode == FileDialog.SAVE) {
827 result = chooser.showSaveDialog(parentFrame);
828 } else if (mode == FileDialog.LOAD) {
829 result = chooser.showOpenDialog(parentFrame);
830 }
831 if (result == JFileChooser.APPROVE_OPTION) {
832 selectedFile = chooser.getSelectedFile();
833 }
834 }
835 PApplet.selectCallback(selectedFile, callbackMethod, callbackObject);
836 }
837
838
839 static public void selectFolder(final String prompt,

Callers 4

selectInputMethod · 0.95
selectOutputMethod · 0.95
selectInputMethod · 0.95
selectOutputMethod · 0.95

Calls 5

selectCallbackMethod · 0.95
getFileMethod · 0.80
setVisibleMethod · 0.65
getParentMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected