Created
November 25, 2019 17:54
-
-
Save LucasHild/c2ff63d8aa80bec96cbdf5d098ca86ce 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 java.awt.GridBagLayout; | |
import javax.swing.JLabel; | |
import java.awt.GridBagConstraints; | |
import java.awt.Insets; | |
import javax.swing.border.TitledBorder; | |
import javax.swing.JRadioButton; | |
import javax.swing.JTextField; | |
import javax.swing.JButton; | |
import javax.swing.BoxLayout; | |
import javax.swing.SwingConstants; | |
public class Window extends JFrame { | |
private JPanel contentPane; | |
private JTextField textField; | |
private JTextField textField_1; | |
private JTextField textField_2; | |
private JTextField textField_3; | |
/** | |
* Launch the application. | |
*/ | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
try { | |
Window frame = new Window(); | |
frame.setVisible(true); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
/** | |
* Create the frame. | |
*/ | |
public Window() { | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setBounds(100, 100, 300, 450); | |
contentPane = new JPanel(); | |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); | |
setContentPane(contentPane); | |
contentPane.setLayout(new BorderLayout(0, 0)); | |
JPanel panel = new JPanel(); | |
contentPane.add(panel, BorderLayout.CENTER); | |
GridBagLayout gbl_panel = new GridBagLayout(); | |
gbl_panel.columnWidths = new int[]{0, 0, 0}; | |
gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
gbl_panel.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE}; | |
gbl_panel.rowWeights = new double[]{1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE}; | |
panel.setLayout(gbl_panel); | |
JLabel lblUmrechnungVonKrperdaten = new JLabel("Umrechnung von Körperdaten"); | |
GridBagConstraints gbc_lblUmrechnungVonKrperdaten = new GridBagConstraints(); | |
gbc_lblUmrechnungVonKrperdaten.gridwidth = 2; | |
gbc_lblUmrechnungVonKrperdaten.insets = new Insets(0, 0, 5, 0); | |
gbc_lblUmrechnungVonKrperdaten.gridx = 0; | |
gbc_lblUmrechnungVonKrperdaten.gridy = 0; | |
panel.add(lblUmrechnungVonKrperdaten, gbc_lblUmrechnungVonKrperdaten); | |
JPanel panel_1 = new JPanel(); | |
panel_1.setBorder(new TitledBorder(null, "K\u00F6rperwahl", TitledBorder.LEADING, TitledBorder.TOP, null, null)); | |
GridBagConstraints gbc_panel_1 = new GridBagConstraints(); | |
gbc_panel_1.gridwidth = 2; | |
gbc_panel_1.insets = new Insets(0, 0, 5, 0); | |
gbc_panel_1.fill = GridBagConstraints.BOTH; | |
gbc_panel_1.gridx = 0; | |
gbc_panel_1.gridy = 1; | |
panel.add(panel_1, gbc_panel_1); | |
JRadioButton rdbtnWrfel = new JRadioButton("Würfel"); | |
panel_1.add(rdbtnWrfel); | |
JRadioButton rdbtnKugel = new JRadioButton("Kugel"); | |
panel_1.add(rdbtnKugel); | |
JPanel panel_2 = new JPanel(); | |
panel_2.setBorder(new TitledBorder(null, "Eingabe", TitledBorder.LEADING, TitledBorder.TOP, null, null)); | |
GridBagConstraints gbc_panel_2 = new GridBagConstraints(); | |
gbc_panel_2.gridheight = 2; | |
gbc_panel_2.insets = new Insets(0, 0, 5, 5); | |
gbc_panel_2.fill = GridBagConstraints.BOTH; | |
gbc_panel_2.gridx = 0; | |
gbc_panel_2.gridy = 2; | |
panel.add(panel_2, gbc_panel_2); | |
panel_2.setLayout(new BoxLayout(panel_2, BoxLayout.Y_AXIS)); | |
JRadioButton rdbtnKanteradius = new JRadioButton("Kante/Radius"); | |
panel_2.add(rdbtnKanteradius); | |
JRadioButton rdbtnOberflche = new JRadioButton("Oberfläche"); | |
panel_2.add(rdbtnOberflche); | |
JRadioButton rdbtnVolumen = new JRadioButton("Volumen"); | |
panel_2.add(rdbtnVolumen); | |
textField = new JTextField(); | |
GridBagConstraints gbc_textField = new GridBagConstraints(); | |
gbc_textField.insets = new Insets(0, 0, 5, 0); | |
gbc_textField.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField.gridx = 1; | |
gbc_textField.gridy = 2; | |
panel.add(textField, gbc_textField); | |
textField.setColumns(10); | |
JButton btnBerechne = new JButton("Berechne"); | |
GridBagConstraints gbc_btnBerechne = new GridBagConstraints(); | |
gbc_btnBerechne.insets = new Insets(0, 0, 5, 0); | |
gbc_btnBerechne.gridx = 1; | |
gbc_btnBerechne.gridy = 3; | |
panel.add(btnBerechne, gbc_btnBerechne); | |
btnBerechne.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
System.out.println(evt); | |
} | |
}); | |
JLabel lblAusgabe = new JLabel("Ausgabe"); | |
GridBagConstraints gbc_lblAusgabe = new GridBagConstraints(); | |
gbc_lblAusgabe.insets = new Insets(0, 0, 5, 5); | |
gbc_lblAusgabe.gridx = 0; | |
gbc_lblAusgabe.gridy = 4; | |
panel.add(lblAusgabe, gbc_lblAusgabe); | |
JLabel lblKante = new JLabel("Kante"); | |
GridBagConstraints gbc_lblKante = new GridBagConstraints(); | |
gbc_lblKante.anchor = GridBagConstraints.EAST; | |
gbc_lblKante.insets = new Insets(0, 0, 5, 5); | |
gbc_lblKante.gridx = 0; | |
gbc_lblKante.gridy = 5; | |
panel.add(lblKante, gbc_lblKante); | |
textField_1 = new JTextField(); | |
GridBagConstraints gbc_textField_1 = new GridBagConstraints(); | |
gbc_textField_1.insets = new Insets(0, 0, 5, 0); | |
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_1.gridx = 1; | |
gbc_textField_1.gridy = 5; | |
panel.add(textField_1, gbc_textField_1); | |
textField_1.setColumns(10); | |
JLabel lblWrfeloberflche = new JLabel("Würfel-Oberfläche"); | |
GridBagConstraints gbc_lblWrfeloberflche = new GridBagConstraints(); | |
gbc_lblWrfeloberflche.anchor = GridBagConstraints.EAST; | |
gbc_lblWrfeloberflche.insets = new Insets(0, 0, 5, 5); | |
gbc_lblWrfeloberflche.gridx = 0; | |
gbc_lblWrfeloberflche.gridy = 6; | |
panel.add(lblWrfeloberflche, gbc_lblWrfeloberflche); | |
textField_2 = new JTextField(); | |
GridBagConstraints gbc_textField_2 = new GridBagConstraints(); | |
gbc_textField_2.insets = new Insets(0, 0, 5, 0); | |
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_2.gridx = 1; | |
gbc_textField_2.gridy = 6; | |
panel.add(textField_2, gbc_textField_2); | |
textField_2.setColumns(10); | |
JLabel lblWrfelvolumen = new JLabel("Würfel-Volumen"); | |
GridBagConstraints gbc_lblWrfelvolumen = new GridBagConstraints(); | |
gbc_lblWrfelvolumen.anchor = GridBagConstraints.EAST; | |
gbc_lblWrfelvolumen.insets = new Insets(0, 0, 0, 5); | |
gbc_lblWrfelvolumen.gridx = 0; | |
gbc_lblWrfelvolumen.gridy = 7; | |
panel.add(lblWrfelvolumen, gbc_lblWrfelvolumen); | |
textField_3 = new JTextField(); | |
GridBagConstraints gbc_textField_3 = new GridBagConstraints(); | |
gbc_textField_3.fill = GridBagConstraints.HORIZONTAL; | |
gbc_textField_3.gridx = 1; | |
gbc_textField_3.gridy = 7; | |
panel.add(textField_3, gbc_textField_3); | |
textField_3.setColumns(10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment