-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtraCredits.java
More file actions
55 lines (47 loc) · 1.51 KB
/
ExtraCredits.java
File metadata and controls
55 lines (47 loc) · 1.51 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Name: Triance, Nick
// Due: 03 Dec. 2021
// Description:
// Extra credits dialog for notepad
import javax.swing.*;
import java.awt.GridLayout;
public class ExtraCredits {
private static final String[] ec = {"View Help",
"Frame title changes dynamically",
"Undo/Redo",
"Print",
"Page Setup",
"Zoom in/out/reset",
"Custom Colors",
"Find Next",
"Replace"
};
/**
* Displays the Extra Credit dialog
* @param parent <code>JFrame</code> to attach the dialog to.
* @return <code>0</code>
*/
public static int showDialog(JFrame parent) {
JDialog dlg = new JDialog(parent, "Extra Credits", true);
JPanel jpl = new JPanel(new GridLayout(2,1));
String displayString = new String();
for(int i = 0; i < ec.length; i++) {
displayString+=ec[i];
displayString+="\n";
}
JTextArea jLab = new JTextArea(displayString);
jLab.setEditable(false);
JButton okBtn = new JButton("Close");
okBtn.addActionListener((ae) -> {
dlg.dispose();
});
jpl.add(jLab);
jpl.add(okBtn);
dlg.add(jpl);
dlg.pack();
dlg.setLocationRelativeTo(parent);
dlg.getRootPane().setDefaultButton(okBtn);
dlg.setVisible(true);
return 0; //for some reason the dialog wasn't working right if it didn't return anything.
}
}