package Input;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
public class ProgramEditor2 {
JFrame frame;
JPanel contactListPanel;
ArrayList<JButton> program;
public ProgramEditor2() {
initialize();
}
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
LineEditor.main((JButton) arg0.getSource(),program,contactListPanel);
}
};
public void initialize() {
frame = new JFrame();
frame.setSize(471, 298);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setVisible(true);
frame.getContentPane().setLayout(new BorderLayout());
program = new ArrayList<JButton>();
// Set layout for contactListPane
contactListPanel = new JPanel();
contactListPanel.setLayout(new GridLayout(15, 1)); // 15 rows, 1 column
contactListPanel.setMinimumSize(new Dimension(471, 298));
contactListPanel.setPreferredSize(new Dimension(471, 298));
contactListPanel.setMaximumSize(new Dimension(471, 298));
for (int i = 0; i < 1; i++) {
JButton button = new JButton();
button.addActionListener(al);
contactListPanel.add(button);
}
JScrollPane scrollPane = new JScrollPane(contactListPanel);
scrollPane
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
}
public static void main(String[] args) {
new ProgramEditor2();
}
}
I am trying to add a JLabel above the scrollpanel, and two JButtons below it.I believe the issue is the fact that I am setting the frame layout to BorderLayout at line 57. How can I got about fixing this problem?