I have a JFrame and a few JPanels that are displayed depending on where the user goes (to login, homepage etc), is there a way to set all JPanels to the same size without having to manually specify?
public mainApp() { main = new JFrame("Application"); main.setSize(640, 480); main.setVisible(true); } private JPanel loginScreen() { login = new JPanel(null); login.setSize(640, 480); login.setVisible(true); } For example I have 5 different JPanels, and have to specify the size in each, is there a way to set a default size that is the same as the JFrame?
CardLayout. All panels will be sized to the size of the largest panel added. See the Swing tutorial o How to Use CardLayout for more information and working examples. Keep a link to the tutorial handy for all Swing basics.