Skip to content

Instantly share code, notes, and snippets.

@LucasHild
Created November 25, 2019 17:55
Show Gist options
  • Save LucasHild/519d1755ae746855ca5e50fc08e3e28c to your computer and use it in GitHub Desktop.
Save LucasHild/519d1755ae746855ca5e50fc08e3e28c to your computer and use it in GitHub Desktop.
package com.lucas.figures;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
public class Window {
public Window() {
JFrame frame = new JFrame("Körper");
frame.setSize(400, 500);
frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS));
GridBagConstraints constraints = new GridBagConstraints();
JLabel heading = new JLabel("Umrechnung von Körperdaten");
frame.add(heading);
JPanel chooseFigurePane = new JPanel(new FlowLayout());
chooseFigurePane.setBorder(new TitledBorder("Körperwahl"));
// TODO: Add form group
frame.add(chooseFigurePane);
JRadioButton cubeRadioButton = new JRadioButton("Würfel", true);
chooseFigurePane.add(cubeRadioButton);
JRadioButton sphereRadioButton = new JRadioButton("Kugel", false);
chooseFigurePane.add(sphereRadioButton);
JPanel centerPane = new JPanel(new GridBagLayout());
frame.add(centerPane);
JPanel inputTypePane = new JPanel();
inputTypePane.setLayout(new BoxLayout(inputTypePane, BoxLayout.Y_AXIS));
inputTypePane.setBorder(new TitledBorder("Eingabe"));
centerPane.add(inputTypePane);
JRadioButton edgeRadioButton = new JRadioButton("Kante/Radius", true);
inputTypePane.add(edgeRadioButton);
JRadioButton surfaceRadioButton = new JRadioButton("Oberfläche", false);
inputTypePane.add(surfaceRadioButton);
JRadioButton volumeRadioButton = new JRadioButton("Volumen", false);
inputTypePane.add(volumeRadioButton);
JPanel inputButtonPane = new JPanel();
inputButtonPane.setLayout(new BoxLayout(inputButtonPane, BoxLayout.Y_AXIS));
centerPane.add(inputButtonPane);
JTextField inputField = new JTextField("");
constraints.insets = new Insets(20, 20, 10, 10);
inputButtonPane.add(inputField, constraints);
constraints.insets = new Insets(0, 0, 0, 0);
JButton calculateButton = new JButton("Berechne");
inputButtonPane.add(calculateButton);
JPanel outputPane = new JPanel(new GridBagLayout());
outputPane.setBorder(new TitledBorder("Ausgabe"));
frame.add(outputPane);
JLabel edgeLabel = new JLabel("Kante");
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 0;
constraints.gridy = 0;
outputPane.add(edgeLabel, constraints);
JTextField edgeOutputField = new JTextField("Kante");
constraints.gridx = 1;
constraints.gridy = 0;
outputPane.add(edgeOutputField, constraints);
JLabel surfaceLabel = new JLabel("Oberfläche");
constraints.gridx = 0;
constraints.gridy = 1;
outputPane.add(surfaceLabel, constraints);
JTextField surfaceOutputField = new JTextField("Oberfäche");
constraints.gridx = 1;
constraints.gridy = 1;
outputPane.add(surfaceOutputField, constraints);
JLabel volumeLabel = new JLabel("Volumen");
constraints.gridx = 0;
constraints.gridy = 2;
outputPane.add(volumeLabel, constraints);
JTextField volumeOutputField = new JTextField("Volumen");
constraints.gridx = 1;
constraints.gridy = 2;
outputPane.add(volumeOutputField, constraints);
frame.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment