I have explained the embedding of swing control (Jbutton) in the JavaFX application in my first tutorial. If you have not seen that session, please watch that tutorial first and continue from this session for better understanding.
We will handle the event that is delivered to an appropriate Swing button and get processed.
– Using the same project that we have created in the first part of this tutorial.
– Please watch part #1 of this session for a better understanding.
– Create an instance of Swing component,
– Then associate an ActionLinster with it to handle click events: b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println(“Swing Button Clicked!”); }
});
– Then associate an ActionLinster with it to handle click events: b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println(“Swing Button Clicked!”); }
});
I have explained the whole process in detail in the video tutorial session. You can watch the video below.
If you found this post useful and would like to support me, you can do so by buying me a coffee using the button on the right-hand side!