I've got MyJPanel(extends JPanel). Each MyJPanel object has method GetID(). When I create it I set ID with constructor(but also there is method SetID()), set size and then create Jscrollpane and add it to JInternalFrame. All frames are in ArrayList<JInternalFrame> arr
.
JInternalFrame frame = new JInternalFrame("Inner frame",true,true,true,true);
final MyJPanel panel = new MyJPanel(f.getAbsolutePath(),count);
panel.setSize(panel.getWidth()/6,panel.getHeight()/6);
JScrollPane pane = new JScrollPane(panel);
pane.setPreferredSize(new Dimension(theDesktop.getWidth() / 2, theDesktop.getHeight() / 2));
frame.getContentPane().add(pane, BorderLayout.CENTER);
To delete frame I add add FrameListener and method internalFrameClosing method
public void internalFrameClosing(InternalFrameEvent e) {
int index = panel.GetID();//get index of panel окна
if (index == arr.size())
arr.remove(index);//remove last element
else{
//reset all indexes of JInternalFrames' MyJPanel
}
}
But I don't know how to reset values for MyJPanels in array of JInternalFrames when one of the frames was deleted because
1)MyJPanel is in JScrollPane. method SetID
2)JScrollPane is in JInternalFrame
3)JInternalFrame is in the array. No method SetID() in arr.get(i)
.