-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventhandling.java
More file actions
27 lines (27 loc) · 814 Bytes
/
eventhandling.java
File metadata and controls
27 lines (27 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
class dialogbox{
dialogbox(){
JFrame window = new JFrame("EventHandling");
JButton btn = new JButton("click");
btn.setBounds(140, 180, 100, 40);
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(btn,"Hello");
}
});
window.add(btn);
window.setSize(400,500);
window.setLayout(null);
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class eventhandling {
public static void main(String[] args) {
SwingUtilities.invokeLater(()->{
new dialogbox();
});
}
}