I have a Applet question.
I faced a problem when I try to call a Java method through the javascript.
When I click "Change", the applet can change the background colour (from BLUE to WHITE).
However, the background colour will be change back to BLUE after it is covered by other windows. Can anyone help me to solve this problems?
I am using JRE 1.6.0 Update 1 and I.E. 6.
Thank you.
The Java code:
The HTML code:Code:import java.awt.*; import javax.swing.*; public class PanelSwitch extends JApplet { // Instance variables JPanel p1; JPanel p2; // Constructor public PanelSwitch(){ p1 = new JPanel(); p2 = new JPanel(); p1.setBackground(java.awt.Color.BLUE); p2.setBackground(java.awt.Color.WHITE); setContentPane(p1); } // Action public void changePanel () { setContentPane(p2); validate(); } }
Code:<html> <applet code=PanelSwitch.class name=PanelSwitch width="200" height="200"></applet> <script LANGUAGE="JavaScript"> function load() { document.PanelSwitch.changePanel() } </script> <a HREF="javascript:void(0)" onclick="load()">Change</a> </html>


Reply With Quote


Bookmarks