I'm trying to add these two panels to my frame. I want my mainPanel1 to be in the top of my frame and mainPanel2 to be in the bottom. Therefore I thought I'm suppose to set layout to border layout like a did. A frame does display on my screen but there is nothing in it. I tried creating a border line and title thinking that I needed to make the panels visible some way but it's still not working. However, it seems to compile fine without any errors. Any ideas?
import javax.swing.*; import java.awt.*; import javax.swing.border.Border; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class resistortests extends javax.swing.JFrame { public resistortests() { JPanel mainPanel1 = new JPanel(new BorderLayout()); //mainPanel1.setLayout(new BorderLayout()); mainPanel1.setBorder(new TitledBorder("mainPanel1")); JPanel mainPanel2 = new JPanel(new GridLayout()); //mainPanel2.setLayout(new GridLayout(0,5)); mainPanel2.setBorder(new TitledBorder("mainPanel2")); Font largeFont = new Font("TimesRoman", Font.BOLD, 20); Border lineBorder = new LineBorder(Color.BLACK,2); setLayout(new BorderLayout(0,5)); add(mainPanel1, BorderLayout.NORTH); add(mainPanel2, BorderLayout.SOUTH); } public static void main(String args[]) { JFrame resFrame = new JFrame("Resistor Lookup"); resFrame.setSize(500, 500); resFrame.setLocationRelativeTo(null); resFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); resFrame.setVisible(true); } }