89 lines
2.3 KiB
Java
89 lines
2.3 KiB
Java
package View;
|
|
|
|
import javax.swing.*;
|
|
import javax.swing.border.TitledBorder;
|
|
import java.awt.*;
|
|
|
|
/**
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
*
|
|
* @Author: Armin Wolf
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
* @Date: 02.06.2017.
|
|
*/
|
|
public class SidePanel extends JPanel {
|
|
|
|
|
|
private JLabel[] labels;
|
|
private JTextField[] input;
|
|
private JButton startButton;
|
|
private JPanel continer;
|
|
private GridBagConstraints gbc;
|
|
|
|
public SidePanel(){
|
|
this.setBorder(new TitledBorder("Eingabefelder"));
|
|
this.labels = new JLabel[10];
|
|
this.input = new JTextField[10];
|
|
this.setLayout(new BorderLayout());
|
|
this.continer = new JPanel();
|
|
continer.setLayout(new GridBagLayout());;
|
|
gbc = new GridBagConstraints();
|
|
gbc.anchor = GridBagConstraints.NORTH;
|
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
addTextfieldAndInput(0, "Konstante", 1.0);
|
|
addTextfieldAndInput(1, "Fehler", 0.005);
|
|
|
|
startButton = new JButton("start");
|
|
addButton(2, startButton);
|
|
this.add(continer, BorderLayout.NORTH);
|
|
}
|
|
|
|
|
|
private void addTextfieldAndInput(int row, String name, Double value){
|
|
this.labels[row] = new JLabel(name);
|
|
this.input[row] = new JTextField();
|
|
this.input[row].setText(""+value);
|
|
|
|
gbc.insets = new Insets(0, 5,0,0);
|
|
gbc.gridx = 0;
|
|
gbc.gridy = row;
|
|
gbc.weightx = 0.05;
|
|
gbc.weighty = 0.05;
|
|
continer.add(this.labels[row], gbc);
|
|
|
|
gbc.gridx = 1;
|
|
gbc.gridy = row;
|
|
gbc.weightx = 0.9;
|
|
gbc.weighty = 0.05;
|
|
gbc.insets = new Insets(0, 0,0,5);
|
|
continer.add(this.input[row], gbc);
|
|
}
|
|
|
|
private void addButton(int row, JButton button){
|
|
|
|
gbc.insets = new Insets(30, 5,0,0);
|
|
gbc.gridx = 0;
|
|
gbc.gridy = row;
|
|
gbc.weightx = 0.05;
|
|
gbc.weighty = 0.05;
|
|
|
|
continer.add(button, gbc);
|
|
}
|
|
|
|
public JButton getStartButton() {
|
|
return startButton;
|
|
}
|
|
|
|
public String[] getInput() {
|
|
String[] input = new String[3];
|
|
input[0] = this.input[0].getText();
|
|
input[1] = this.input[1].getText();
|
|
return input;
|
|
}
|
|
|
|
public void setInput(JTextField[] input) {
|
|
this.input = input;
|
|
}
|
|
}
|