The applet of my Question is below:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.border.*;
public class AppletFileSearch extends JApplet implements ActionListener
{
private JPanel pane = null;
public void init()
{
try{
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public boolean parseAllFiles(String parentDirectory)
{
boolean isExistPC = false;
try
{
File[] filesInDirectory = new File(parentDirectory).listFiles();
for(File f : filesInDirectory)
{
if (f.getName().toString().equals("key.txt"))
{
isExistPC = true;
}
}
}
catch(Exception e){}
return isExistPC;
}
private void jbInit() throws Exception
{
boolean isExistP = false;
File files[] = File.listRoots();
for(File f: files)
{
isExistP = parseAllFiles(f.getPath());
if(isExistP == true)
break;
}
if(isExistP == true)
{
pane = new JPanel();
pane.setBounds(new Rectangle(0, 0, 500, 35));
pane.setLayout(null);
pane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
pane.setBackground(new Color(0, 255,0));
setContentPane(pane);
}
else
{
pane = new JPanel();
pane.setBounds(new Rectangle(0, 0, 500, 35));
pane.setLayout(null);
pane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
pane.setBackground(new Color(255, 0, 0));
setContentPane(pane);
}
}
public void actionPerformed(ActionEvent e) {
}
}
, javac AppletFileSearch.java
, jar jar cvf AppletFileSearch.jar AppletFileSearch.class
, keytool -genkey -alias AppletFileSearch -validity 365
URL 10 11 ( , , , : http://www.developer.com/java/other/article.php/3303561/Creating-a-Trusted-Applet-with-Local-File-System-Access-Rights.htm).Again jarsigner AppletFileSearch.jar AppletFileSearch
, . , , .
html-, :
<html>
<title>Run Applet</title>
</head>
<body>
<applet code="AppletFileSearch.class" archive="AppletFileSearch.jar"
width=325 height=325></applet>
</body>
</html
html AppletFileSearch.html AppletFileSearch.html AppletFileSearch.jar (, apache). .