-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackButton.java
29 lines (25 loc) · 1.02 KB
/
BackButton.java
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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class BackButton extends CustomButton {
// Class: BackButton
// Methods: BackButton, actionPerformed
// Objects: currentFrame, mainFrame, currentLocation
// Accessors: addActionListener
BackButton(JFrame currentFrame, JFrame mainFrame) {
super("Home", 100, 50, 10, 10);
addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Method: actionPerformed
// Objects: currentFrame, mainFrame, currentLocation
Point currentLocation = currentFrame.getLocation();
currentFrame.dispose();
mainFrame.setLocation(currentLocation);
mainFrame.setVisible(true);
}
});
}
}
// This thing just makes the frame not close everything (dispose) and kinda minimize and go invisible, and set the new frame as the mainframe