I am not very good with Swings please help me out. senario: I am trying to add a new Jbutton with in the same frame, while clicking an existing Jbutton, but it was not working.
Thanks in Advance.
I am using below code
JButton addAnotherButton = new JButton("Add New Button");
addAnotherButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (event.getSource() == addAnotherButton) {
JButton newButton = new JButton("New born Button");
newButton.addActionListener(this);
}
}
});
addAnotherButton.setFont(new Font("Times New Roman", Font.BOLD, 12));
addAnotherButton.setBounds(276, 222, 137, 29);
contentPane.add(addAnotherButton);