Como criar um evento onde meu botão está em outra classe?
Aqui crio um botão.
import javax.swing.JPanel;
import javax.swing.JButton;
public class Panel extends JPanel {
private JButton jButton = null;
public Panel() {
super();
initialize();
}
private void initialize() {
this.setLayout(null);
this.setSize(60, 60);
this.add(getJButton(), null);
}
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText("OK");
jButton.setBounds(new java.awt.Rectangle(0,0,60,60));
}
return jButton;
}
}
agora estou adicionando o botão em outra classe:
import javax.swing.JPanel;
public class PanelAction2 extends JPanel {
Panel panel = new Panel();
public PanelAction2() {
super();
initialize();
}
private void initialize() {
this.setSize(300, 200);
this.add(panel, null);
}
}