From 205f059ec5df1a24daa87f8563d2bbb99344ecf9 Mon Sep 17 00:00:00 2001 From: tspitzer Date: Tue, 17 Sep 2013 15:38:08 +0200 Subject: g --- Dozentenmodul/src/GUI/AddOS.java | 145 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 Dozentenmodul/src/GUI/AddOS.java (limited to 'Dozentenmodul/src/GUI/AddOS.java') diff --git a/Dozentenmodul/src/GUI/AddOS.java b/Dozentenmodul/src/GUI/AddOS.java new file mode 100644 index 00000000..5039a4e1 --- /dev/null +++ b/Dozentenmodul/src/GUI/AddOS.java @@ -0,0 +1,145 @@ +package GUI; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import sql.sql; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JTextField; +import javax.swing.JComboBox; +import javax.swing.JCheckBox; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.sql.Connection; +import javax.swing.DefaultComboBoxModel; + +@SuppressWarnings("serial") +public class AddOS extends JDialog { + + private final JPanel contentPanel = new JPanel(); + private JTextField textField; + private JTextField textField_1; + private JTextField textField_2; + @SuppressWarnings("rawtypes") + JComboBox comboBox; + JCheckBox checkBox; + sql sql=new sql(); + /** + * Launch the application. + */ + public static void main(String[] args) { + try { + AddOS dialog = new AddOS(); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Create the dialog. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public AddOS() { + setTitle("Dozentenmodul"); + setBounds(100, 100, 288, 300); + getContentPane().setLayout(new BorderLayout()); + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + getContentPane().add(contentPanel, BorderLayout.CENTER); + contentPanel.setLayout(null); + { + JLabel lblNewLabel = new JLabel("Betriebssystem hinzuf\u00FCgen"); + lblNewLabel.setFont(new Font("Dialog", Font.PLAIN, 14)); + lblNewLabel.setBounds(10, 11, 194, 25); + contentPanel.add(lblNewLabel); + } + { + JLabel lblHersteller = new JLabel("Hersteller:"); + lblHersteller.setBounds(10, 47, 100, 20); + contentPanel.add(lblHersteller); + } + { + textField = new JTextField(); + textField.setBounds(120, 47, 125, 20); + contentPanel.add(textField); + textField.setColumns(10); + } + { + JLabel lblNewLabel_1 = new JLabel("Name:"); + lblNewLabel_1.setBounds(10, 78, 100, 20); + contentPanel.add(lblNewLabel_1); + } + { + textField_1 = new JTextField(); + textField_1.setColumns(10); + textField_1.setBounds(120, 78, 125, 20); + contentPanel.add(textField_1); + } + { + JLabel lblVersion = new JLabel("Version:"); + lblVersion.setBounds(10, 109, 100, 20); + contentPanel.add(lblVersion); + } + { + textField_2 = new JTextField(); + textField_2.setColumns(10); + textField_2.setBounds(120, 109, 125, 20); + contentPanel.add(textField_2); + } + { + JLabel lblArchitektur = new JLabel("Architektur:"); + lblArchitektur.setBounds(10, 140, 100, 20); + contentPanel.add(lblArchitektur); + } + + comboBox = new JComboBox(); + comboBox.setModel(new DefaultComboBoxModel(new String[] {"32-bit", "64-bit"})); + comboBox.setBounds(120, 140, 125, 20); + contentPanel.add(comboBox); + + JLabel lblLizenzpflichtig = new JLabel("Lizenzpflichtig:"); + lblLizenzpflichtig.setBounds(10, 171, 100, 20); + contentPanel.add(lblLizenzpflichtig); + + checkBox = new JCheckBox(""); + checkBox.setBounds(120, 167, 97, 23); + contentPanel.add(checkBox); + { + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); + getContentPane().add(buttonPane, BorderLayout.SOUTH); + { + JButton okButton = new JButton("OK"); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int Kosten=0; + if(checkBox.isSelected()==true) + { + Kosten=1; + } + Connection con=sql.getConnection(); + sql.AddOS(con, textField_1.getText().toString(), textField_2.getText().toString(), comboBox.getSelectedItem().toString(), Kosten, textField.getText().toString()); + } + }); + okButton.setActionCommand("OK"); + buttonPane.add(okButton); + getRootPane().setDefaultButton(okButton); + } + { + JButton cancelButton = new JButton("Zur\u00FCck"); + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + cancelButton.setActionCommand("Cancel"); + buttonPane.add(cancelButton); + } + } + } +} -- cgit v1.2.3-55-g7522