I am trying to replace components in jpanel
using replace()
in GroupLayout
but it didn't worked. I tried to google it but didn't found any helpful solution. Can any one please tell me where do I making mistake?
Here is my code:
contentPanelLayout.setHorizontalGroup(
contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(contentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
contentPanelLayout.setVerticalGroup(
contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(contentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
I am trying to replace the panel with another panel on button click
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
contentPanelLayout.replace(contentPanel,anotherPanel);
}
});
I've read the java docs, but not found any helpful.