I'm trying to use DJ Native Swing (http://djproject.sourceforge.net/ns/) in a sketch, particularly at the moment the native File Dialogs (though I wouldn't mind getting the web browser to work later).
One problem I have with it is that you need to NativeInterface.open(); in the Main(). I'm not sure how to do this. Here is the error I get.
Quote:***WARNING: Display must be created on main thread due to Cocoa restrictions.
Exception in thread "Animation Thread" java.lang.IllegalStateException: An error occurred while creating the SWT Display! On a Mac, the Native Interface can only be initialized from the main thread and the Java process needs to be started with the "-XstartOnFirstThread" VM parameter.
Code:import chrriis.dj.nativeswing.swtimpl.components.JFileDialog.*;
void setup() {
size(800,600);
NativeInterface.open();
NativeSwing.initialize();
//The file dialog supports multiple selection and extension filters. Here is such an example (an "open file" dialog):
JFileDialog fileDialog = new JFileDialog();
fileDialog.setSelectionMode(SelectionMode.MULTIPLE_SELECTION);
// We want 3 extension filters, and want the second choice (index 1) to be the default.
fileDialog.setExtensionFilters(
new String[] {
"*.*", "*.mp3;*.avi", "*.txt;*.doc" }
,
new String[] {
"All files", "Multimedia file (*.mp3, *.avi)", "Text document (*.txt, *.doc)" }
,
1);
fileDialog.show(this);
System.out.println("You selected: " + Arrays.toString(fileDialog.getSelectedFileNames()));
}