-
Notifications
You must be signed in to change notification settings - Fork 0
/
Screen.java
155 lines (139 loc) · 5.49 KB
/
Screen.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package ws.thurn.dossier;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
/*
* .
*/
/**
* The Screen class provides the template for all of the main screens of the
* program. It standardizes layout and button placement.
*
* @author Derek Thurn
*/
public abstract class Screen implements ActionListener
{
public JFrame frm;
public JButton knew;
private JLabel currentlyLabel;
private JPanel topright;
private JPanel topleft;
public JButton back;
public JButton save;
public JButton load;
private JPanel Main;
public JPanel content;
public JComboBox currentCombo;
/**
* Builds the GUI for the screen object.
*
* @pre the correct variables have been declared
* @post the GUI has been displayed.
*/
public void init()
{
try
{
{
frm = new JFrame();
BoxLayout frmLayout = new BoxLayout( frm.getContentPane(),
javax.swing.BoxLayout.Y_AXIS );
frm.getContentPane().setLayout( frmLayout );
frm.setSize( 800, 650 );
GradeBook.center( frm );
frm.setVisible( true );
Main = new JPanel();
BoxLayout MainLayout = new BoxLayout( Main,
javax.swing.BoxLayout.X_AXIS );
Main.setLayout( MainLayout );
frm.getContentPane().add( Main, BorderLayout.NORTH );
{
topleft = new JPanel();
Main.add( topleft );
topleft
.setPreferredSize( new java.awt.Dimension( 297, 47 ) );
{
knew = new JButton();
topleft.add( knew );
knew.setIcon( new ImageIcon( getClass()
.getClassLoader().getResource( "new.gif" ) ) );
knew.setToolTipText( "New" );
}
{
load = new JButton();
topleft.add( load );
load.setIcon( new ImageIcon( getClass()
.getClassLoader().getResource( "load.gif" ) ) );
load.setToolTipText( "Load" );
}
{
save = new JButton();
topleft.add( save );
save.setIcon( new ImageIcon( getClass()
.getClassLoader().getResource( "save.gif" ) ) );
save.setToolTipText( "Save" );
}
}
{
topright = new JPanel();
Main.add( topright );
topright
.setPreferredSize( new java.awt.Dimension( 555, 47 ) );
{
currentlyLabel = new JLabel();
topright.add( currentlyLabel );
currentlyLabel.setText( "Currently Selected Class:" );
}
{
String classes[] = GradeBook.getClassesStringArray();
ComboBoxModel classComboModel = new DefaultComboBoxModel(
classes );
currentCombo = new JComboBox();
topright.add( currentCombo );
currentCombo.setModel( classComboModel );
currentCombo.addActionListener( this );
if( GradeBook.getCurrentClassLocation() < 0 )
currentCombo.setSelectedIndex( -1 );
else
currentCombo.setSelectedIndex( GradeBook
.getCurrentClassLocation() );
}
{
back = new JButton();
topright.add( back );
back.setIcon( new ImageIcon( getClass()
.getClassLoader().getResource( "back.gif" ) ) );
back.setToolTipText( "Return to the Main Menu" );
}
}
back.addActionListener( this );
knew.addActionListener( this );
save.addActionListener( this );
load.addActionListener( this );
}
{
content = new JPanel();
BoxLayout ContentLayout = new BoxLayout( content,
javax.swing.BoxLayout.Y_AXIS );
content.setLayout( ContentLayout );
frm.getContentPane().add( content );
content.setPreferredSize( new java.awt.Dimension( 386, 569 ) );
content.setSize( 792, 800 );
frm.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frm.setFocusCycleRoot( false );
}
}
catch( Exception e )
{
e.printStackTrace();
}
}
}