JFileChooser problem on MAC OS
In JavaFX UI on click of Browse button, I am using JFileChooser to open the file system. Below is the piece of code which I am executing and the exception I am getting:
Later I used DirectoryChooser. This is working fine but the pop-up is always coming behind javafx applet when started in browser.
Note: This is working fine if we run as stand alone application.
JFileChooser chooser = new JFileChooser(new File("/Volumes/"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = chooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
System.out.println("selectedFile: "+chooser.getSelectedFile());
//tfFileSelected.setText(getParent(chooser.getSelectedFile()));
}
2013-03-04 10:16:40.480 java[15576:5803] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
2013-03-04 10:16:42.614 java[15576:707] [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode.
Glass detected outstanding Java exception at -[GlassViewDelegate sendJavaMouseEvent:]:src/com/sun/mat/ui/GlassViewDelegate.m:541
Exception in thread "AWT-AppKit" java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
at java.awt.Window.<init>(Window.java:535)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1759)
at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1834)
at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1697)
at javax.swing.JOptionPane.getWindowForComponent(JOptionPane.java:1638)
at javax.swing.JFileChooser.createDialog(JFileChooser.java:785)
at javax.swing.JFileChooser.showDialog(JFileChooser.java:732)
at javax.swing.JFileChooser.showOpenDialog(JFileChooser.java:639)
at samplebrowse.SampleBrowse$1.handle(SampleBrowse.java:46)
at samplebrowse.SampleBrowse$1.handle(SampleBrowse.java:31)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Node.fireEvent(Node.java:6863)
at javafx.scene.control.Button.fire(Button.java:179)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3324)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3164)
at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3119)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1559)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2261)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:228)
at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
at com.sun.glass.ui.View.notifyMouse(View.java:922)
2013-03-04 10:16:44.769 java[15576:707] unrecognized type is -2
2013-03-04 10:16:44.770 java[15576:707] *** Assertion failure in -[NSEvent _initWithCGSEvent:eventRef:], /SourceCache/AppKit/AppKit-1187.34/AppKit.subproj/NSEvent.m:1348
2013-03-04 10:16:44.770 java[15576:707] Invalid parameter not satisfying: cgsEvent.type > 0 && cgsEvent.type <= kCGSLastEventType
2013-03-04 10:16:44.771 java[15576:707] (
0 CoreFoundation 0x00007fff952af0a6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff93fc13f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff952aeee8 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00007fff8af8e6a2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 AppKit 0x00007fff8c8da56c -[NSEvent _initWithCGSEvent:eventRef:] + 2782
5 AppKit 0x00007fff8cb5b3ea +[NSEvent eventWithCGEvent:] + 243
6 libglass.dylib 0x0000000163f4c02f listenTouchEvents + 31
7 CoreGraphics 0x00007fff919b20d9 processEventTapData + 150
8 CoreGraphics 0x00007fff919b1f2c _CGYPostEventTapData + 189
9 CoreGraphics 0x00007fff9191155d _XPostEventTapData + 107
10 CoreGraphics 0x00007fff91911655 CGYEventTap_server + 106
11 CoreGraphics 0x00007fff919b201a eventTapMessageHandler + 30
12 CoreFoundation 0x00007fff9521e410 __CFMachPortPerform + 288
13 CoreFoundation 0x00007fff9521e2d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
14 CoreFoundation 0x00007fff9521e019 __CFRunLoopDoSource1 + 153
15 CoreFoundation 0x00007fff9525119f __CFRunLoopRun + 1775
16 CoreFoundation 0x00007fff952506b2 CFRunLoopRunSpecific + 290
17 HIToolbox 0x00007fff8db930a4 RunCurrentEventLoopInMode + 209
18 HIToolbox 0x00007fff8db92e42 ReceiveNextEventCommon + 356
19 HIToolbox 0x00007fff8db92cd3 BlockUntilNextEventMatchingListInMode + 62
20 AppKit 0x00007fff8c7fb613 _DPSNextEvent + 685
21 AppKit 0x00007fff8c7faed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
22 AppKit 0x00007fff8c7f2283 -[NSApplication run] + 517
23 libglass.dylib 0x0000000163f394e9 -[GlassApplication runLoop:] + 777
24 Foundation 0x00007fff8b014677 __NSThreadPerformPerform + 225
25 CoreFoundation 0x00007fff9522e101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26 CoreFoundation 0x00007fff9522da25 __CFRunLoopDoSources0 + 245
27 CoreFoundation 0x00007fff95250dc5 __CFRunLoopRun + 789
28 CoreFoundation 0x00007fff952506b2 CFRunLoopRunSpecific + 290
29 java 0x0000000109e274bc CreateExecutionEnvironment + 871
30 java 0x0000000109e21cac JLI_Launch + 1952
31 java 0x0000000109e27819 main + 101
32 java 0x0000000109e21504 start + 52
)