senthil12345 0 Newbie Poster

Hi,

I’ve embedded applet in a jsp page. Initially appearance of applet is coming well. After some time during the process of applet , when the browser window is minimized and restored or if we are switching to any other window and coming back to the applet embedded jsp page, the things whatever displayed in applet are vanished because of which behavior of applet could not be recognized.

I’ll explain the applet process flow briefly. My applet is for transferring files from local machine to server through FTP concept. To show the progress of file transfer I’ve used progress bar with percentage displayed on it. As the files are transferred, progress bar status varies and also the percentage displayed.

Because of the above mentioned problem, the end user could not see the progress bar or anything else displayed in the applet. Problem is with applet behavior only.

Can any body suggest me how to rectify this problem?

Following is the fraction of applet code I’ve used.

public class UploadFolderApplet extends javax.swing.JApplet {
 
	private javax.swing.JProgressBar jPB_Progress;
	private javax.swing.JPanel jPanel;
	private javax.swing.JLabel msglabel;
 
    public void init() {	
	try 
		{
            initComponents();
      
        } 
		catch (Exception ex) 
		{
            ex.printStackTrace();
        }
    }
    
	public void start()
	{
	System.out.println("start()");	
	}
 
	public void stop()
	{
		try
		{
		System.gc();
		System.out.println("stop()");			
		}
		catch (Exception ee)
		{
			System.out.println("The Exception is at line 214 is ===>"+ee);
		}
	}
 
	public void destroy()
	{
		try
		{
		System.gc();
		System.out.println("destroy()");			
		}
		catch (Exception ee)
		{
			System.out.println("The Exception is at line 214 is ===>"+ee);
		}
	}
 
	private void initComponents() {
        
	jPanel = new javax.swing.JPanel();
        msglabel = new javax.swing.JLabel();
        jPB_Progress = new javax.swing.JProgressBar();
 
        getContentPane().setLayout(null);
 
        jPanel.setLayout(null);
 
        jPanel.setBackground(new java.awt.Color(235, 235, 235));
        msglabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel.add(msglabel);
        msglabel.setBounds(20, 40, 830, 270);
 
        jPanel.add(jPB_Progress);
        jPB_Progress.setBounds(280, 10, 280, 20);
 
        getContentPane().add(jPanel);
        jPanel.setBounds(0, 0, 870, 320);		
		
	jPB_Progress.setVisible(false);
	jPB_Progress.setBackground(new java.awt.Color(255, 255, 255));
        jPB_Progress.setForeground(new java.awt.Color(153, 227,155));
 
    }
 
 
public void pageLoad(String projid01,String clientname01,String projectname01,String isbnno01,String isbnext01,String projtype01,String username01)
{
 
		SwingWorker sw = new SwingWorker() {
		protected Object doInBackground() throws Exception {
		
		// this part is executed when user clicks button in jsp page 
		
		return null;
		}};
 
//		sw.execute();
		Thread th = new Thread(sw);
		th.start();
		th = null;
		if(sw.isDone()){
		sw = null;
	}
 
}
 
}

Following code explains how the applet is embedded in JSP.

<html>
<head
//some script code 
<script language='javascript'>
function subForm(clientname,projectname,projid,isbnno,isbnext,projtype)
{
	document.applets.fmsupload.init();	
	document.applets.fmsupload.start();	
	document.applets.fmsupload.pageLoad(projid,clientname,projectname,isbnno,isbnext,projtype,uname);
}		
}
</script>
</head>
<body>
 
//here some jsp code 
 
<input class="but" name="b" type="button" value="UploadFiles" onclick="return subForm('<%=clientname%>','<%=projectname.toUpperCase()%>','<%=projid%>','<%=isbnno%>','<%=isbnextn%>','<%=projtype%>');"  style="font-family: Verdana; font-size: 10pt; font-weight: bold">
	
<applet  name="fmsupload" archive="fmstest.jar" type="applet"  code="UploadFolderApplet.class" codebase="./fms/uploadfolders"  height="320" width="870">
</body>
</html>

is there any possible then modify this code and add paint() or repaint() or update() methods. can any one please give me the solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.