1

Im currently working with JFrames and JPanels.

JFrame - Window with buttons etc. JPanel - Area to be used for paintComponent etc.

I have my mainWindow and a subWindow

mainWindow is a JFrame that calls subWindow which is a JFrame with a JPanel on it.

subWindow uses setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); as i do not want to close everything when i close subWindow

mainWindow calls subWindow via new subWindow();

When i close subWindow and re-open another instance of it, the old paintComponent stuff are still in the JPanel. i.e If i print a circle the first time it will still be there in the new instance of the subWindow.

I've noticed that when subWindow is re-opened the old variables used are still present instead of well, being new.

How can i manually dump everything when i exit subWindow? And why is it so when i called a new instance of subWindow the old variables still remain?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
natchan
  • 138
  • 1
  • 1
  • 12
  • 1
    Multiple JFrames, bad. http://stackoverflow.com/a/9554657/300257 – Gilbert Le Blanc Apr 03 '13 at 16:39
  • Do you assign the instance of subWindow to null before reopening it? – hd1 Apr 03 '13 at 18:05
  • @GilbertLeBlanc Thanks for the heads up Well using multiple JFrames is bad however, it still doesnt answer the question of why the old variables in subWindow still remain although i call new subWindow() each time – natchan Apr 03 '13 at 21:41
  • @hd1 Yes but that should be irrelevant since i am calling newSubwindow() no? – natchan Apr 03 '13 at 21:41

0 Answers0