I have 3 classes (3 separate files).
- just launching the application
- The class draws the form with one JLabel and JButton.
I want the JLabel text to change when I click on the button, but so that the event handler is in the 3rd grade. How to organize it?
one)
import javax.swing.*; public class App { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Form(); } }); } } 2)
import javax.swing.*; import java.awt.*; public class Form { JFrame jForm; Form(){ jForm = new JFrame("Test"); JPanel jp = new JPanel(new FlowLayout()); jForm.setBounds(500,500,200,200); JLabel jl = new JLabel("Text"); jp.add(jl); JButton jb = new JButton("Button"); jp.add(jb); jForm.setContentPane(jp); jForm.setVisible(true); } } 3)
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Controller implements ActionListener { @Override public void actionPerformed(ActionEvent e) { } }