以下代码方便地创建了一个框布局,但我遇到的问题是文本字段占据了整行。这应该假定它被指定的参数长度。
public void makeControlpanel(){
JPanel controlpanel = new JPanel();
//SET PANEL LAYOUT MANAGERS
controlpanel.setLayout(new BoxLayout(controlpanel,BoxLayout.PAGE_AXIS));
controlpanel.setBorder(BorderFactory.createTitledBorder("Create Control file"));
filenameC = new JLabel("Filename");
filenameBad = new JLabel("Bad Filename");
filenameDis = new JLabel("Discard Filename");
// fields
fileField = new JTextField(1);
badfileField = new JTextField(7);
discardfileField = new JTextField(7);