forked from aneez9n/Basic-Projects
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonHandler.java
More file actions
Latest commit
33 lines (28 loc) · 872 Bytes
/
Copy pathButtonHandler.java
File metadata and controls
33 lines (28 loc) · 872 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
28
29
30
31
32
33
packageeventbuttonframe;
importjavax.swing.*;
importjava.awt.*;
importjava.awt.event.*;
/**
*
* @author INAM
*/
publicclassButtonHandlerimplementsActionListener
{
publicvoidactionPerformed(ActionEventevent)
{
JButtonclickedButton = (JButton) event.getSource();
JRootPanerootPane = clickedButton.getRootPane();
JFrameframe = (JFrame) rootPane.getParent();
StringbuttonText = clickedButton.getText();
frame.setTitle("You clicked " + buttonText);
ContainerC = frame.getContentPane();
if(buttonText.equalsIgnoreCase("ok"))
{
C.setBackground(Color.YELLOW);
}
elseif(buttonText.equalsIgnoreCase("CANCEL"))
{
C.setBackground(Color.MAGENTA);
}
}
}