I am working on a program using a JPanel to show a block of text,buttons,etc. and I am trying to set a JPanel equal to another one that i created but its not doing anything. Ignore my buttons and crap.
I have the panel declared publicly
public JPanel panel;
And Here is its stuff...
panel = new JPanel();
panel.setBackground(PanelColor);
panel.setBounds(0, 93, 594, 478);
contentPane.add(panel);
panel.setLayout(null);
I want to make it so when i hit a button (in this case: btnKinematics) it changes a the panel to a different class i have called KinematicsPanel.java
btnKinematics = new JButton("Kinematics");
btnKinematics.setFont(ButtonFont);
btnKinematics.setFocusPainted(false);
btnKinematics.setBorder(compound);
btnKinematics.setBackground(Color.WHITE);
btnKinematics.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
highlite(btnKinematics);
panel = new KinematicsPanel();
panel.setBackground(Color.WHITE);
}
});
btnKinematics.setBounds(14, 60, 130, 23);
contentPane.add(btnKinematics);
Thanks
UPDATE: FIXED
I made some changes and this worked
contentPane.remove(panel);
contentPane.add(new KinematicsPanel());
contentPane.repaint();
thanks