简体   繁体   中英

How do I refresh a java applet?

I have a java applet that has a JButton in it. However, I'm displaying a chart in this applet and want to refresh the applet when that button is pushed. Is there something that does this?

I've already tried to add this:

setVisible(false);
//function that call a method
setVisible(true);

but it didn't work

Make the necessary changes to the chart and call the component's repaint() method.

Chart c = new Chart(); // Chart extends Component (I assume)
// Call your update methods to make necessary changes
c.repaint(); // Forces the chart to be repainted

Edit: You may instead need to call the validate() method; I'm not completely sure and cannot test this right now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM