Can't add a JButton to a JPanel while running?

Your code is correct for standard Swing JComponents.

Your code is correct for standard Swing JComponents, 1) is totalPane initialized 2) is totalPane added to the Container 3) is totalPane visible in the Container 4) is there BorderLayout defined for totalPane, othervise is there FlowLayout by default you can simply to test it by add Borders (totalPane. SetBorder(BorderFactory. CreateLineBorder(Color.

Red));) to the totalPane.

Your code for adding the button is correct, although your call to repaint() won't achieve anything - revalidate() is enough. My guess is that your sendmessageButtonActionPerformed-method is never invoked. It does not look like any method that is part of ActionListener or any other listener.

How have you set up the ActionListener on the button that triggers the add?

Please debug your code and check whether your method is executed. If it isn't, then we know the problem and you must make sure your method is executed. Note that there is an alternative to your approach, you can create your button at initialize time and set its visibility to false.

When you need it you can make it visible. However, your approach should work.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions