Ich will dort ein Textfeld generieren doch bei mir kommt der Fehler das es dann auf der gleichen Zeile ist.
Code:
import javax.swing.*;
import java.awt.*;
/**
* Creates the complexer elements and simpler ones with specified data/configurations
*/
public abstract class Builder extends Elements {
public JPanel mainPanel() {
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
mainPanel.setBackground(Color.gray);
return mainPanel;
}
/**
* Creates a usage panel
* @param testRowNumber Number of the testRow, for which a panel will be created
* @Return (usage) panel element
*/
public JPanel panel(int testRowNumber) {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
panel.add(label("Testreihe: " + testRowNumber + " "));
String[] dropDownValuesFixed = {"MP 2", "MP 3", "MP 4", "MP 5", "MP 6", "MP 8", "MP 9"};
panel.add(dropDownMenu(dropDownValuesFixed));
panel.add(label(" Portangabe "));
JTextField textField = textField(7);
ElementsHandler.setTextField(textField, testRowNumber);
panel.add(textField);
JButton button = button("Bestätigen");
ElementsHandler.setButton(button, testRowNumber);
panel.add(button);
return panel;
}
}
Code:
import javax.swing.*;
import java.awt.*;
/**
* Creates the complexer elements and simpler ones with specified data/configurations
*/
public abstract class Builder extends Elements {
public JPanel mainPanel() {
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
mainPanel.setBackground(Color.gray);
return mainPanel;
}
/**
* Creates a usage panel
* @param testRowNumber Number of the testRow, for which a panel will be created
* @Return (usage) panel element
*/
public JPanel panel(int testRowNumber) {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
panel.add(label("Testreihe: " + testRowNumber + " "));
String[] dropDownValuesFixed = {"MP 2", "MP 3", "MP 4", "MP 5", "MP 6", "MP 8", "MP 9"};
panel.add(dropDownMenu(dropDownValuesFixed));
panel.add(label(" Portangabe "));
JTextField textField = textField(7);
ElementsHandler.setTextField(textField, testRowNumber);
panel.add(textField);
JButton button = button("Bestätigen");
ElementsHandler.setButton(button, testRowNumber);
panel.add(button);
return panel;
}
}