rendered paste bodypublic class pnb2 extends JFrame {
private JPanel painel;
private JLabel label;
private JButton bot;
pnb2() {
this.setLayout(new GridLayout(1,1));
painel = new JPanel();
label = new JLabel("label");
bot = new JButton("button");
bot.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pressedButton(evt);
}
});
painel.setLayout(new GridLayout(2,1));
painel.setAlignmentY(painel.CENTER_ALIGNMENT);
this.add(painel);
painel.add(label);
painel.add(bot);
this.pack();
}
public void pressedButton(ActionEvent e) {
pnb lala = new pnb();
this.remove(painel);
painel = lala.getPainel();
this.add(painel);
}
public static void main(String[] args) {
new pnb2().setVisible(true);
}
}