-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPageB.java
38 lines (31 loc) · 976 Bytes
/
PageB.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
30
31
32
33
34
35
36
37
38
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
class PageB extends JPanel {
private BasicApp app;
private String text;
public PageB(BasicApp app) {
this.app = app;
JButton backButton = new JButton("Back");
JButton showButton = new JButton("Show");
add(backButton);
add(showButton);
backButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageB.this.app.switchToPageA();
}
});
showButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, text);
}
});
}
void setData(String text) {
this.text = text;
}
}