I don’t have package PyObjCTools installed. Also, it seems it’s MacOS-only! ![]()
I’ve replaced your AppHelper.runEventLoop() w/ a while True: loop plus time.sleep(), so it can run on Windows, even though the code works OK w/o the infinite loop: ![]()
import jpype
import jpype.imports
from time import sleep
jpype.startJVM()
from javax.swing import JFrame, JButton, SwingUtilities
def buildWnd():
btn = JButton("Button")
btn.setBounds(30, 60, 100, 24)
btn.addActionListener(lambda evt: print(evt, '\n'))
frame.add(btn)
frame.setVisible(True)
print("JButton:", btn)
print("EDT:", SwingUtilities.isEventDispatchThread(), '\n')
def main():
global frame
frame = JFrame("Swing EDT")
frame.setBounds(100, 100, 400, 400)
frame.setLayout(None)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
SwingUtilities.invokeLater(buildWnd)
if __name__ == '__main__':
main()
while True: # AppHelper.runEventLoop() replacement.
try: sleep(1) # Sleep to avoid burning the CPU!
except KeyboardInterrupt: break # Exit loop on Ctrl+C.