NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

JavaFX and Swing on same Thread

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
Lusito



Joined: 06 Apr 2016
Posts: 12

PostPosted: Fri Mar 03, 2017 7:08 pm    Post subject: JavaFX and Swing on same Thread Reply with quote

On the book "JavaFX- Rich Client Programming on the NetBeans Platform", the authors mentioned the experimental feature to run javafx on the same thread as swing.

I was wondering if anyone got this working.
I tried enabling it with this option in the app.conf:
Code:
 -J-Djavafx.embed.singleThread=true

But I get an exception on startup:

Quote:
at org.netbeans.core.windows.WindowManagerImpl.warnIfNotInEDT(WindowManagerImpl.java:1770)
at org.netbeans.core.windows.ModeImpl.setBounds(ModeImpl.java:180)
at org.netbeans.core.windows.PersistenceHandler.initModeFromConfig(PersistenceHandler.java:465)
at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:204)
at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:81)
at org.netbeans.core.GuiRunLevel$InitWinSys.run(GuiRunLevel.java:229)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
SEVERE [global]
java.lang.AssertionError: Window System API is required to be called from AWT thread only, see http://core.netbeans.org/proposals/threading/
at org.netbeans.core.windows.WindowManagerImpl.assertEventDispatchThread(WindowManagerImpl.java:1734)
at org.netbeans.core.windows.ModeImpl.getSelectedTopComponent(ModeImpl.java:312)
at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:236)
at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:81)
at org.netbeans.core.GuiRunLevel$InitWinSys.run(GuiRunLevel.java:229)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


Looking at the code, it seems SwingUtilities.isEventDispatchThread() is returning false at that point. That's weird, since the stacktrace shows it is on the EDT.

I know this is marked experimental, but why mention it in the book, if it's preventing a netbeans platform app from running? So I'm guessing there must be some way to get this running.
Back to top
emi



Joined: 14 Aug 2009
Posts: 245

PostPosted: Sat Mar 18, 2017 8:23 pm    Post subject: JavaFX and Swing on same Thread Reply with quote

I haven't used this, but how can SwingUtilities.isEventDispatchThread() return false and still be on the EDT?

You can probably make a small self-contained app and verify if this truly works.

Another possibility is that org.netbeans.core.TimableEventQueue is getting in the way of JavaFX.




--emi





On Fri, Mar 3, 2017 at 9:08 PM, Lusito <address-removed ([email]address-removed[/email])> wrote:
Quote:
On the book "JavaFX- Rich Client Programming on the NetBeans Platform", the authors mentioned the experimental feature to run javafx on the same thread as swing.

I was wondering if anyone got this working.
I tried enabling it with this option in the app.conf:

Code:
 -J-Djavafx.embed.singleThread=true


But I get an exception on startup:


Quote:
       at org.netbeans.core.windows.WindowManagerImpl.warnIfNotInEDT(WindowManagerImpl.java:1770)
       at org.netbeans.core.windows.ModeImpl.setBounds(ModeImpl.java:180)
       at org.netbeans.core.windows.PersistenceHandler.initModeFromConfig(PersistenceHandler.java:465)
       at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:204)
       at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:81)
       at org.netbeans.core.GuiRunLevel$InitWinSys.run(GuiRunLevel.java:229)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
       at java.awt.EventQueue.access$500(EventQueue.java:97)
       at java.awt.EventQueue$3.run(EventQueue.java:709)
       at java.awt.EventQueue$3.run(EventQueue.java:703)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
       at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
SEVERE [global]
java.lang.AssertionError: Window System API is required to be called from AWT thread only, see http://core.netbeans.org/proposals/threading/
       at org.netbeans.core.windows.WindowManagerImpl.assertEventDispatchThread(WindowManagerImpl.java:1734)
       at org.netbeans.core.windows.ModeImpl.getSelectedTopComponent(ModeImpl.java:312)
       at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:236)
       at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:81)
       at org.netbeans.core.GuiRunLevel$InitWinSys.run(GuiRunLevel.java:229)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
       at java.awt.EventQueue.access$500(EventQueue.java:97)
       at java.awt.EventQueue$3.run(EventQueue.java:709)
       at java.awt.EventQueue$3.run(EventQueue.java:703)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
       at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)



Looking at the code, it seems SwingUtilities.isEventDispatchThread() is returning false at that point. That's weird, since the stacktrace shows it is on the EDT.

I know this is marked experimental, but why mention it in the book, if it's preventing a netbeans platform app from running? So I'm guessing there must be some way to get this running.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo