I am having a form built up in netbeans and want to add or remove a component with an actionperformed event of a button or a combobox is it possible?
if yes, how?
I am having a form built up in netbeans and want to add or remove a component with an actionperformed event of a button or a combobox is it possible?
if yes, how?
You can add components at run time, but you have to call paint() method of jframe to show the added component.
Create a JPanel where you want to add dynamic components and then use add/remove and setLayout() methods to control components on it.
The general code for adding components at runtime is:
panel.add( someComponent );
panel.revalidate();
panel.repaint();
However, I believe NetBeans uses the GroupLayout which will cause a problem. You need to understand how all the constraints work and then specify the proper constraints when using the add(...) method.
So my suggestion is to NOT use NetBeans to design your form and to learn to use LayoutManagers on your own, then you will be in full control of the layout and adding components will be as easy as the code above.