I'm trying to create frames with JArchi.
The Frame is created. However, it seems that the events are not captured.
Not possible to close the windows clicking on the close window button at the top left side of the window.
Nothing happen when clicking on the button.
Any idea concerning the ability to capture the events?
The code looking like:
var JFrame = Java.type("javax.swing.JFrame");
var JPanel = Java.type("javax.swing.JPanel");
var JButton = Java.type("javax.swing.JButton");
var JLabel = Java.type("javax.swing.JLabel");
var BorderLayout = Java.type('java.awt.BorderLayout');
var ActionListener = Java.type('java.awt.event.ActionListener');
var win = new JFrame("My Window");
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setSize(400, 400);
var panel = new JPanel();
win.add(panel);
var button = new JButton('Click me!');
button.addActionListener(function() {
console.log("Hello World!");
javax.swing.JOptionPane.showMessageDialog(frame, "Hello World!");
});
panel.add(button, BorderLayout.CENTER);
win.setVisible(true);
Hi Nicolas,
I can't really help on this, I can only says that jArchi is not meant to be used this way (the fact that the whole eclipse framework and JRE is available from jArchi is just a side effect of the way the Nashorn javascript engine works, but we don't support it).
BTW, what are you trying to achieve (there might be alternative way of doing it, like simply opening a browser tab) ?
Regards,
JB
Hi Nicolas,
in line with JB's comments, mixing Java Swing and AWT with Eclipse SWT via Nashorn will lead to problems. In this case it is to do with different threading and event queues. Better to stick to only SWT components.
Hi Nicolas,
See post https://forum.archimatetool.com/index.php?topic=843.msg4660#msg4660
for example of creating/using a dialog box in SWT thru jArchi