• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Deleting/removing JPanel

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a mortgage caculator that calculates a monthly mortgage payment and displays the mortgage's amortization table(when/if the user presses the table button). I also have a clear button that clears all the fields and removes the JPanel that my JTable is on.

My problem is this. When I click the Clear button, The JPanel is removed with the following code(it does what i want it to do):


getContentPane().remove(amortTablePanel);
getContentPane().repaint();



My problem is that when i calculate another mortgage and click the Amortization Table button, both the first and the second tables show up.

How can I completely remove the table when i click the Clear button?

Thanks in advance.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getContentPane().remove(amortTablePanel);
getContentPane().validate();//<--------should do it
getContentPane().repaint();

but why do you need to remove the table/panel?

clear the table, then reset the tableModel, would be much simpler
 
I can't take it! You are too smart for me! Here is the tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic