Mam problem z powielaniem się elementów graficznych.
Chodzi o to, że mam guzik1 powoduje wyświetlenie się guzika2.
Gdy klikam kilka razy na guzik1 mam kilka guzików2. Jak temu zapobiec ? Oto kod listenera
public class ButtonClientListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
JLabel label = new JLabel("Zarządzanie klientami");
JButton showClientsButton = new JButton("Lista klinetów");
JButton showAddClientButton = new JButton("Dodaj klienta");
showClientsButton.addActionListener(new ShowClientsButtonListener());
showAddClientButton.addActionListener(new ShowAddClientListener());
topPanel.add(label);
rightPanel.add(showClientsButton);
rightPanel.add(showAddClientButton);
frame.getContentPane().add(topPanel, BorderLayout.NORTH);
frame.getContentPane().add(rightPanel, BorderLayout.EAST);
frame.validate();
}
}
kod guzika1
JButton button = new JButton("guzik 1");
leftPanel.add(button);
frame.getContentPane().add(leftPanel, BorderLayout.WEST);