Search code examples
javaswingjtablejframejinternalframe

table generation runtime


Hello to all Stackoverflow developers thanks for helping me . I am working on a swing project .In which , i have to add a jinternal frame on jframe . i am adding the jinternal frame by calling method

Container.add(jinternalframe1);

the internalframe is being added but its moving , i want to disable the movement of the jinternalframe. on clicking a button on jinternalframe i want to add a JList and JTable on the previous frame window

I am calling the method

frame1.cp.add(list1);
frame1.cp.add(table1);

while clicking on jlist the table should be removed and new table should be generated. I am writing the following code for it

ms.cp.remove(table);
table= new JTable(String title, Object obj[][]);
add(table);

by doing so jtable is not being removed from container plz suggest me whats wrong in my code


Solution

    1. It sounds like your Container is using a layout manager which is deciding on how the internal frame should be displayed. JInternalFrame is designed to work with containers that don't have a layout manager, most notably, the JDesktopPane. For information check out How to Use Internal Frames
    2. It sounds like you actually want to use a dialog instead of a internal frame
    3. Why are reconstructing the table from scratch? Simply update the model. Besides, you remove the table from ms.cp using ms.cp.remove(table) and then add it to something else, no wonder it never shows up. See How to use Tables for more information.