Creation of JFrame with JArchi - events seems not to be captured.

Started by nfigay, November 11, 2020, 17:29:49 PM

Previous topic - Next topic

nfigay

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);


Jean-Baptiste Sarrodie

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
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

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.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rchevallier