Created
November 25, 2019 17:53
-
-
Save LucasHild/a10fbd15133fb3648f679c468c43595c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package exam; | |
import java.awt.BorderLayout; | |
import java.awt.EventQueue; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import javax.swing.border.EmptyBorder; | |
import javax.swing.JLabel; | |
import java.awt.GridBagLayout; | |
import java.awt.GridBagConstraints; | |
import javax.swing.JTextField; | |
import java.awt.Insets; | |
import javax.swing.JButton; | |
import javax.swing.SwingConstants; | |
import java.awt.event.ActionListener; | |
import java.awt.event.ActionEvent; | |
import javax.swing.BoxLayout; | |
import java.awt.Color; | |
import javax.swing.JComboBox; | |
import javax.swing.DefaultComboBoxModel; | |
public class WindowGrades extends JFrame { | |
private JPanel contentPane; | |
private JTextField txtGerman; | |
private JTextField txtMaths; | |
private JTextField textField; | |
private JTextField textField_1; | |
private JTextField textField_2; | |
private JTextField textField_3; | |
private JTextField textField_4; | |
private JTextField textField_5; | |
private JTextField textField_6; | |
private JTextField textField_7; | |
private JTextField textField_8; | |
private JTextField textField_9; | |
private JTextField textField_10; | |
private JTextField textField_11; | |
private JTextField textField_12; | |
private JTextField textField_13; | |
private JTextField textField_14; | |
private JTextField textField_15; | |
private JTextField textField_16; | |
private JTextField textField_17; | |
private JTextField textField_18; | |
private JTextField textField_19; | |
private JTextField textField_20; | |
private JTextField textField_21; | |
private JTextField textField_22; | |
private JTextField textField_23; | |
private JLabel label_1; | |
private JLabel label_2; | |
private JLabel label_3; | |
private JLabel label_4; | |
private JLabel lblDurchschnitt; | |
private JLabel lblDs; | |
private JLabel labelAverageGerman; | |
private JLabel label_6; | |
private JLabel label_7; | |
private JLabel label_8; | |
private JLabel label_9; | |
private JButton btnSpeichern; | |
private JButton btnSummieren; | |
private JButton btnDurchschnitte; | |
private JButton btnBeenden; | |
private JLabel lblFremdsprache_1; | |
private JTextField txtLanguage; | |
private JLabel lblKernfach_2; | |
private JTextField txtMainSubject4; | |
private JLabel lblKernfach_3; | |
private JTextField txtMainSubject5; | |
private JPanel panel_1; | |
private JLabel lblNotenverwaltungOberstufe; | |
private JTextField txtSemester; | |
/** | |
* Launch the application. | |
*/ | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
try { | |
WindowGrades frame = new WindowGrades(); | |
frame.setVisible(true); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
/** | |
* Create the frame. | |
*/ | |
public WindowGrades() { | |
setTitle("Lucas Hild"); | |
setResizable(false); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setBounds(100, 100, 1000, 400); | |
contentPane = new JPanel(); | |
contentPane.setBackground(Color.GRAY); | |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); | |
setContentPane(contentPane); | |
contentPane.setLayout(new BorderLayout(0, 0)); | |
JPanel mainPanel = new JPanel(); | |
mainPanel.setBackground(Color.GRAY); | |
contentPane.add(mainPanel, BorderLayout.CENTER); | |
GridBagLayout gbl_mainPanel = new GridBagLayout(); | |
gbl_mainPanel.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0}; | |
gbl_mainPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
gbl_mainPanel.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE}; | |
gbl_mainPanel.rowWeights = new double[]{1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE}; | |
mainPanel.setLayout(gbl_mainPanel); | |
JPanel panel = new JPanel(); | |
panel.setBackground(Color.GRAY); | |
GridBagConstraints gbc_panel = new GridBagConstraints(); | |
gbc_panel.gridwidth = 6; | |
gbc_panel.insets = new Insets(0, 0, 5, 0); | |
gbc_panel.fill = GridBagConstraints.BOTH; | |
gbc_panel.gridx = 0; | |
gbc_panel.gridy = 0; | |
mainPanel.add(panel, gbc_panel); | |
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); | |
JLabel lblHj = new JLabel("HJ"); | |
panel.add(lblHj); | |
txtSemester = new JTextField(); | |
panel.add(txtSemester); | |
txtSemester.setColumns(10); | |
JLabel lblDeutsch = new JLabel("Deutsch"); | |
panel.add(lblDeutsch); | |
txtGerman = new JTextField(); | |
panel.add(txtGerman); | |
txtGerman.setColumns(10); | |
JLabel lblMathematik = new JLabel("Mathematik"); | |
panel.add(lblMathematik); | |
txtMaths = new JTextField(); | |
panel.add(txtMaths); | |
txtMaths.setColumns(10); | |
lblFremdsprache_1 = new JLabel("Fremdsprache"); | |
panel.add(lblFremdsprache_1); | |
txtLanguage = new JTextField(); | |
panel.add(txtLanguage); | |
txtLanguage.setColumns(10); | |
lblKernfach_2 = new JLabel("Kernfach 4"); | |
panel.add(lblKernfach_2); | |
txtMainSubject4 = new JTextField(); | |
panel.add(txtMainSubject4); | |
txtMainSubject4.setColumns(10); | |
lblKernfach_3 = new JLabel("Kernfach 5"); | |
panel.add(lblKernfach_3); | |
txtMainSubject5 = new JTextField(); | |
panel.add(txtMainSubject5); | |
txtMainSubject5.setColumns(10); | |
JLabel lblAuswertung = new JLabel("Auswertung"); | |
GridBagConstraints gbc_lblAuswertung = new GridBagConstraints(); | |
gbc_lblAuswertung.insets = new Insets(0, 0, 5, 5); | |
gbc_lblAuswertung.gridx = 0; | |
gbc_lblAuswertung.gridy = 1; | |
mainPanel.add(lblAuswertung, gbc_lblAuswertung); | |
JLabel lblHj_1 = new JLabel("HJ"); | |
GridBagConstraints gbc_lblHj_1 = new GridBagConstraints(); | |
gbc_lblHj_1.insets = new Insets(0, 0, 5, 5); | |
gbc_lblHj_1.gridx = 0; | |
gbc_lblHj_1.gridy = 2; | |
mainPanel.add(lblHj_1, gbc_lblHj_1); | |
JLabel lblDeutsch_1 = new JLabel("Deutsch"); | |
GridBagConstraints gbc_lblDeutsch_1 = new GridBagConstraints(); | |
gbc_lblDeutsch_1.insets = new Insets(0, 0, 5, 5); | |
gbc_lblDeutsch_1.gridx = 1; | |
gbc_lblDeutsch_1.gridy = 2; | |
mainPanel.add(lblDeutsch_1, gbc_lblDeutsch_1); | |
JLabel lblNewLabel = new JLabel("Mathematik"); | |
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); | |
gbc_lblNewLabel.anchor = GridBagConstraints.NORTH; | |
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); | |
gbc_lblNewLabel.gridx = 2; | |
gbc_lblNewLabel.gridy = 2; | |
mainPanel.add(lblNewLabel, gbc_lblNewLabel); | |
JLabel lblFremdsprache = new JLabel("Fremdsprache"); | |
GridBagConstraints gbc_lblFremdsprache = new GridBagConstraints(); | |
gbc_lblFremdsprache.insets = new Insets(0, 0, 5, 5); | |
gbc_lblFremdsprache.gridx = 3; | |
gbc_lblFremdsprache.gridy = 2; | |
mainPanel.add(lblFremdsprache, gbc_lblFremdsprache); | |
JLabel lblKernfach_1 = new JLabel("Kernfach 4"); | |
GridBagConstraints gbc_lblKernfach_1 = new GridBagConstraints(); | |
gbc_lblKernfach_1.insets = new Insets(0, 0, 5, 5); | |
gbc_lblKernfach_1.gridx = 4; | |
gbc_lblKernfach_1.gridy = 2; | |
mainPanel.add(lblKernfach_1, gbc_lblKernfach_1); | |
JLabel lblKernfach = new JLabel("Kernfach 5"); | |
GridBagConstraints gbc_lblKernfach = new GridBagConstraints(); | |
gbc_lblKernfach.insets = new Insets(0, 0, 5, 0); | |
gbc_lblKernfach.gridx = 5; | |
gbc_lblKernfach.gridy = 2; | |
mainPanel.add(lblKernfach, gbc_lblKernfach); | |
textField = new JTextField(); | |
textField.setEditable(false); | |
textField.setText("1"); | |
GridBagConstraints gbc_textField = new GridBagConstraints(); | |
gbc_textField.insets = new Insets(0, 0, 5, 5); | |
gbc_textField.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField.gridx = 0; | |
gbc_textField.gridy = 3; | |
mainPanel.add(textField, gbc_textField); | |
textField.setColumns(10); | |
textField_1 = new JTextField(); | |
textField_1.setEditable(false); | |
GridBagConstraints gbc_textField_1 = new GridBagConstraints(); | |
gbc_textField_1.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_1.gridx = 1; | |
gbc_textField_1.gridy = 3; | |
mainPanel.add(textField_1, gbc_textField_1); | |
textField_1.setColumns(10); | |
textField_2 = new JTextField(); | |
textField_2.setEditable(false); | |
GridBagConstraints gbc_textField_2 = new GridBagConstraints(); | |
gbc_textField_2.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_2.gridx = 2; | |
gbc_textField_2.gridy = 3; | |
mainPanel.add(textField_2, gbc_textField_2); | |
textField_2.setColumns(10); | |
textField_3 = new JTextField(); | |
textField_3.setEditable(false); | |
GridBagConstraints gbc_textField_3 = new GridBagConstraints(); | |
gbc_textField_3.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_3.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_3.gridx = 3; | |
gbc_textField_3.gridy = 3; | |
mainPanel.add(textField_3, gbc_textField_3); | |
textField_3.setColumns(10); | |
textField_4 = new JTextField(); | |
textField_4.setEditable(false); | |
GridBagConstraints gbc_textField_4 = new GridBagConstraints(); | |
gbc_textField_4.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_4.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_4.gridx = 4; | |
gbc_textField_4.gridy = 3; | |
mainPanel.add(textField_4, gbc_textField_4); | |
textField_4.setColumns(10); | |
textField_5 = new JTextField(); | |
textField_5.setEditable(false); | |
GridBagConstraints gbc_textField_5 = new GridBagConstraints(); | |
gbc_textField_5.insets = new Insets(0, 0, 5, 0); | |
gbc_textField_5.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_5.gridx = 5; | |
gbc_textField_5.gridy = 3; | |
mainPanel.add(textField_5, gbc_textField_5); | |
textField_5.setColumns(10); | |
textField_6 = new JTextField(); | |
textField_6.setEditable(false); | |
textField_6.setText("2"); | |
GridBagConstraints gbc_textField_6 = new GridBagConstraints(); | |
gbc_textField_6.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_6.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_6.gridx = 0; | |
gbc_textField_6.gridy = 4; | |
mainPanel.add(textField_6, gbc_textField_6); | |
textField_6.setColumns(10); | |
textField_7 = new JTextField(); | |
textField_7.setEditable(false); | |
GridBagConstraints gbc_textField_7 = new GridBagConstraints(); | |
gbc_textField_7.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_7.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_7.gridx = 1; | |
gbc_textField_7.gridy = 4; | |
mainPanel.add(textField_7, gbc_textField_7); | |
textField_7.setColumns(10); | |
textField_8 = new JTextField(); | |
textField_8.setEditable(false); | |
GridBagConstraints gbc_textField_8 = new GridBagConstraints(); | |
gbc_textField_8.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_8.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_8.gridx = 2; | |
gbc_textField_8.gridy = 4; | |
mainPanel.add(textField_8, gbc_textField_8); | |
textField_8.setColumns(10); | |
textField_9 = new JTextField(); | |
textField_9.setEditable(false); | |
GridBagConstraints gbc_textField_9 = new GridBagConstraints(); | |
gbc_textField_9.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_9.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_9.gridx = 3; | |
gbc_textField_9.gridy = 4; | |
mainPanel.add(textField_9, gbc_textField_9); | |
textField_9.setColumns(10); | |
textField_10 = new JTextField(); | |
textField_10.setEditable(false); | |
GridBagConstraints gbc_textField_10 = new GridBagConstraints(); | |
gbc_textField_10.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_10.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_10.gridx = 4; | |
gbc_textField_10.gridy = 4; | |
mainPanel.add(textField_10, gbc_textField_10); | |
textField_10.setColumns(10); | |
textField_11 = new JTextField(); | |
textField_11.setEditable(false); | |
GridBagConstraints gbc_textField_11 = new GridBagConstraints(); | |
gbc_textField_11.insets = new Insets(0, 0, 5, 0); | |
gbc_textField_11.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_11.gridx = 5; | |
gbc_textField_11.gridy = 4; | |
mainPanel.add(textField_11, gbc_textField_11); | |
textField_11.setColumns(10); | |
textField_12 = new JTextField(); | |
textField_12.setEditable(false); | |
textField_12.setText("3"); | |
GridBagConstraints gbc_textField_12 = new GridBagConstraints(); | |
gbc_textField_12.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_12.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_12.gridx = 0; | |
gbc_textField_12.gridy = 5; | |
mainPanel.add(textField_12, gbc_textField_12); | |
textField_12.setColumns(10); | |
textField_13 = new JTextField(); | |
textField_13.setEditable(false); | |
GridBagConstraints gbc_textField_13 = new GridBagConstraints(); | |
gbc_textField_13.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_13.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_13.gridx = 1; | |
gbc_textField_13.gridy = 5; | |
mainPanel.add(textField_13, gbc_textField_13); | |
textField_13.setColumns(10); | |
textField_14 = new JTextField(); | |
textField_14.setEditable(false); | |
GridBagConstraints gbc_textField_14 = new GridBagConstraints(); | |
gbc_textField_14.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_14.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_14.gridx = 2; | |
gbc_textField_14.gridy = 5; | |
mainPanel.add(textField_14, gbc_textField_14); | |
textField_14.setColumns(10); | |
textField_15 = new JTextField(); | |
textField_15.setEditable(false); | |
GridBagConstraints gbc_textField_15 = new GridBagConstraints(); | |
gbc_textField_15.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_15.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_15.gridx = 3; | |
gbc_textField_15.gridy = 5; | |
mainPanel.add(textField_15, gbc_textField_15); | |
textField_15.setColumns(10); | |
textField_16 = new JTextField(); | |
textField_16.setEditable(false); | |
GridBagConstraints gbc_textField_16 = new GridBagConstraints(); | |
gbc_textField_16.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_16.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_16.gridx = 4; | |
gbc_textField_16.gridy = 5; | |
mainPanel.add(textField_16, gbc_textField_16); | |
textField_16.setColumns(10); | |
textField_17 = new JTextField(); | |
textField_17.setEditable(false); | |
GridBagConstraints gbc_textField_17 = new GridBagConstraints(); | |
gbc_textField_17.insets = new Insets(0, 0, 5, 0); | |
gbc_textField_17.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_17.gridx = 5; | |
gbc_textField_17.gridy = 5; | |
mainPanel.add(textField_17, gbc_textField_17); | |
textField_17.setColumns(10); | |
textField_18 = new JTextField(); | |
textField_18.setEditable(false); | |
textField_18.setText("4"); | |
GridBagConstraints gbc_textField_18 = new GridBagConstraints(); | |
gbc_textField_18.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_18.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_18.gridx = 0; | |
gbc_textField_18.gridy = 6; | |
mainPanel.add(textField_18, gbc_textField_18); | |
textField_18.setColumns(10); | |
textField_19 = new JTextField(); | |
textField_19.setEditable(false); | |
GridBagConstraints gbc_textField_19 = new GridBagConstraints(); | |
gbc_textField_19.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_19.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_19.gridx = 1; | |
gbc_textField_19.gridy = 6; | |
mainPanel.add(textField_19, gbc_textField_19); | |
textField_19.setColumns(10); | |
textField_20 = new JTextField(); | |
textField_20.setEditable(false); | |
GridBagConstraints gbc_textField_20 = new GridBagConstraints(); | |
gbc_textField_20.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_20.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_20.gridx = 2; | |
gbc_textField_20.gridy = 6; | |
mainPanel.add(textField_20, gbc_textField_20); | |
textField_20.setColumns(10); | |
textField_21 = new JTextField(); | |
textField_21.setEditable(false); | |
GridBagConstraints gbc_textField_21 = new GridBagConstraints(); | |
gbc_textField_21.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_21.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_21.gridx = 3; | |
gbc_textField_21.gridy = 6; | |
mainPanel.add(textField_21, gbc_textField_21); | |
textField_21.setColumns(10); | |
textField_22 = new JTextField(); | |
textField_22.setEditable(false); | |
GridBagConstraints gbc_textField_22 = new GridBagConstraints(); | |
gbc_textField_22.insets = new Insets(0, 0, 5, 5); | |
gbc_textField_22.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_22.gridx = 4; | |
gbc_textField_22.gridy = 6; | |
mainPanel.add(textField_22, gbc_textField_22); | |
textField_22.setColumns(10); | |
textField_23 = new JTextField(); | |
textField_23.setEditable(false); | |
GridBagConstraints gbc_textField_23 = new GridBagConstraints(); | |
gbc_textField_23.insets = new Insets(0, 0, 5, 0); | |
gbc_textField_23.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_23.gridx = 5; | |
gbc_textField_23.gridy = 6; | |
mainPanel.add(textField_23, gbc_textField_23); | |
textField_23.setColumns(10); | |
JLabel lblSumme = new JLabel("Summe"); | |
GridBagConstraints gbc_lblSumme = new GridBagConstraints(); | |
gbc_lblSumme.insets = new Insets(0, 0, 5, 5); | |
gbc_lblSumme.gridx = 0; | |
gbc_lblSumme.gridy = 7; | |
mainPanel.add(lblSumme, gbc_lblSumme); | |
JLabel lblSu = new JLabel("SU"); | |
GridBagConstraints gbc_lblSu = new GridBagConstraints(); | |
gbc_lblSu.insets = new Insets(0, 0, 5, 5); | |
gbc_lblSu.gridx = 0; | |
gbc_lblSu.gridy = 8; | |
mainPanel.add(lblSu, gbc_lblSu); | |
JLabel labelSumGerman = new JLabel("0.0"); | |
GridBagConstraints gbc_labelSumGerman = new GridBagConstraints(); | |
gbc_labelSumGerman.insets = new Insets(0, 0, 5, 5); | |
gbc_labelSumGerman.gridx = 1; | |
gbc_labelSumGerman.gridy = 8; | |
mainPanel.add(labelSumGerman, gbc_labelSumGerman); | |
label_1 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_1 = new GridBagConstraints(); | |
gbc_label_1.insets = new Insets(0, 0, 5, 5); | |
gbc_label_1.gridx = 2; | |
gbc_label_1.gridy = 8; | |
mainPanel.add(label_1, gbc_label_1); | |
label_2 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_2 = new GridBagConstraints(); | |
gbc_label_2.insets = new Insets(0, 0, 5, 5); | |
gbc_label_2.gridx = 3; | |
gbc_label_2.gridy = 8; | |
mainPanel.add(label_2, gbc_label_2); | |
label_3 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_3 = new GridBagConstraints(); | |
gbc_label_3.insets = new Insets(0, 0, 5, 5); | |
gbc_label_3.gridx = 4; | |
gbc_label_3.gridy = 8; | |
mainPanel.add(label_3, gbc_label_3); | |
label_4 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_4 = new GridBagConstraints(); | |
gbc_label_4.insets = new Insets(0, 0, 5, 0); | |
gbc_label_4.gridx = 5; | |
gbc_label_4.gridy = 8; | |
mainPanel.add(label_4, gbc_label_4); | |
lblDurchschnitt = new JLabel("Durchschnitt"); | |
GridBagConstraints gbc_lblDurchschnitt = new GridBagConstraints(); | |
gbc_lblDurchschnitt.insets = new Insets(0, 0, 5, 5); | |
gbc_lblDurchschnitt.gridx = 0; | |
gbc_lblDurchschnitt.gridy = 9; | |
mainPanel.add(lblDurchschnitt, gbc_lblDurchschnitt); | |
lblDs = new JLabel("DS"); | |
GridBagConstraints gbc_lblDs = new GridBagConstraints(); | |
gbc_lblDs.insets = new Insets(0, 0, 0, 5); | |
gbc_lblDs.gridx = 0; | |
gbc_lblDs.gridy = 10; | |
mainPanel.add(lblDs, gbc_lblDs); | |
labelAverageGerman = new JLabel("0.0"); | |
GridBagConstraints gbc_labelAverageGerman = new GridBagConstraints(); | |
gbc_labelAverageGerman.insets = new Insets(0, 0, 0, 5); | |
gbc_labelAverageGerman.gridx = 1; | |
gbc_labelAverageGerman.gridy = 10; | |
mainPanel.add(labelAverageGerman, gbc_labelAverageGerman); | |
label_6 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_6 = new GridBagConstraints(); | |
gbc_label_6.insets = new Insets(0, 0, 0, 5); | |
gbc_label_6.gridx = 2; | |
gbc_label_6.gridy = 10; | |
mainPanel.add(label_6, gbc_label_6); | |
label_7 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_7 = new GridBagConstraints(); | |
gbc_label_7.insets = new Insets(0, 0, 0, 5); | |
gbc_label_7.gridx = 3; | |
gbc_label_7.gridy = 10; | |
mainPanel.add(label_7, gbc_label_7); | |
label_8 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_8 = new GridBagConstraints(); | |
gbc_label_8.insets = new Insets(0, 0, 0, 5); | |
gbc_label_8.gridx = 4; | |
gbc_label_8.gridy = 10; | |
mainPanel.add(label_8, gbc_label_8); | |
label_9 = new JLabel("0.0"); | |
GridBagConstraints gbc_label_9 = new GridBagConstraints(); | |
gbc_label_9.gridx = 5; | |
gbc_label_9.gridy = 10; | |
mainPanel.add(label_9, gbc_label_9); | |
JPanel buttonsPanel = new JPanel(); | |
buttonsPanel.setBackground(Color.GRAY); | |
contentPane.add(buttonsPanel, BorderLayout.SOUTH); | |
GridBagLayout gbl_buttonsPanel = new GridBagLayout(); | |
gbl_buttonsPanel.columnWidths = new int[]{0, 0, 0, 0, 0}; | |
gbl_buttonsPanel.rowHeights = new int[]{0, 0}; | |
gbl_buttonsPanel.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE}; | |
gbl_buttonsPanel.rowWeights = new double[]{1.0, Double.MIN_VALUE}; | |
buttonsPanel.setLayout(gbl_buttonsPanel); | |
btnSpeichern = new JButton("Speichern"); | |
btnSpeichern.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent e) { | |
String semester = txtSemester.getText(); | |
String german = txtGerman.getText(); | |
String maths = txtMaths.getText(); | |
String language = txtLanguage.getText(); | |
String mainSubject4 = txtMainSubject4.getText(); | |
String mainSubject5 = txtMainSubject5.getText(); | |
switch (semester) { | |
case "1": | |
textField_1.setText(german); | |
textField_2.setText(maths); | |
textField_3.setText(language); | |
textField_4.setText(mainSubject4); | |
textField_5.setText(mainSubject5); | |
break; | |
case "2": | |
textField_7.setText(german); | |
textField_8.setText(maths); | |
textField_9.setText(language); | |
textField_10.setText(mainSubject4); | |
textField_11.setText(mainSubject5); | |
break; | |
case "3": | |
textField_13.setText(german); | |
textField_14.setText(maths); | |
textField_15.setText(language); | |
textField_16.setText(mainSubject4); | |
textField_17.setText(mainSubject5); | |
break; | |
case "4": | |
textField_19.setText(german); | |
textField_20.setText(maths); | |
textField_21.setText(language); | |
textField_22.setText(mainSubject4); | |
textField_23.setText(mainSubject5); | |
break; | |
default: | |
System.out.println("Error"); | |
} | |
} | |
}); | |
btnSpeichern.setBackground(Color.WHITE); | |
GridBagConstraints gbc_btnSpeichern = new GridBagConstraints(); | |
gbc_btnSpeichern.fill = GridBagConstraints.HORIZONTAL; | |
gbc_btnSpeichern.insets = new Insets(0, 0, 0, 5); | |
gbc_btnSpeichern.gridx = 0; | |
gbc_btnSpeichern.gridy = 0; | |
buttonsPanel.add(btnSpeichern, gbc_btnSpeichern); | |
btnSummieren = new JButton("Summieren"); | |
btnSummieren.setBackground(Color.WHITE); | |
btnSummieren.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent e) { | |
int sumGerman = getSum(textField_1.getText(), textField_7.getText(), textField_13.getText(), textField_19.getText()); | |
labelSumGerman.setText(String.valueOf(sumGerman)); | |
} | |
}); | |
GridBagConstraints gbc_btnSummieren = new GridBagConstraints(); | |
gbc_btnSummieren.fill = GridBagConstraints.HORIZONTAL; | |
gbc_btnSummieren.insets = new Insets(0, 0, 0, 5); | |
gbc_btnSummieren.gridx = 1; | |
gbc_btnSummieren.gridy = 0; | |
buttonsPanel.add(btnSummieren, gbc_btnSummieren); | |
btnDurchschnitte = new JButton("Durchschnitte"); | |
btnDurchschnitte.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent e) { | |
double sumGerman = getSum(textField_1.getText(), textField_7.getText(), textField_13.getText(), textField_19.getText()); | |
double averageGerman = sumGerman / 4; | |
labelAverageGerman.setText(String.valueOf(averageGerman)); | |
} | |
}); | |
btnDurchschnitte.setBackground(Color.WHITE); | |
GridBagConstraints gbc_btnDurchschnitte = new GridBagConstraints(); | |
gbc_btnDurchschnitte.fill = GridBagConstraints.HORIZONTAL; | |
gbc_btnDurchschnitte.insets = new Insets(0, 0, 0, 5); | |
gbc_btnDurchschnitte.gridx = 2; | |
gbc_btnDurchschnitte.gridy = 0; | |
buttonsPanel.add(btnDurchschnitte, gbc_btnDurchschnitte); | |
btnBeenden = new JButton("Beenden"); | |
btnBeenden.setBackground(Color.WHITE); | |
GridBagConstraints gbc_btnBeenden = new GridBagConstraints(); | |
gbc_btnBeenden.fill = GridBagConstraints.HORIZONTAL; | |
gbc_btnBeenden.gridx = 3; | |
gbc_btnBeenden.gridy = 0; | |
buttonsPanel.add(btnBeenden, gbc_btnBeenden); | |
panel_1 = new JPanel(); | |
panel_1.setBackground(Color.DARK_GRAY); | |
contentPane.add(panel_1, BorderLayout.NORTH); | |
lblNotenverwaltungOberstufe = new JLabel("Notenverwaltung Oberstufe"); | |
lblNotenverwaltungOberstufe.setForeground(Color.WHITE); | |
panel_1.add(lblNotenverwaltungOberstufe); | |
} | |
private int getSum(String first, String second, String third, String fourth) { | |
return parseIntOrNull(first) + parseIntOrNull(second) + parseIntOrNull(third) + parseIntOrNull(fourth); | |
} | |
private int parseIntOrNull(String number) { | |
try { | |
return Integer.parseInt(number); | |
} catch (java.lang.NumberFormatException e) { | |
return 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment