public class Stop_Convert implements ActionListener {
public void actionPerformed(ActionEvent e) {
private Thread myStopThread;
public void run() {
{
Thread stopThread = myStopThread;
myStopThread = null;
if (stopThread == null) {
stopThread.interrupt();
}
}
}
}
}
}
public class Convert_Test_File implements ActionListener {
public void actionPerformed(ActionEvent e) {
public void run() {
{
refreshTab.setVisible(false);
about.setVisible(false);
try {
if (Test_File_Directory.getText().trim().length() == 0) {
JOptionPane.showMessageDialog(null, "\t\tTest molecule file not selected!", "Missing File",
JOptionPane.WARNING_MESSAGE);
} else if (Save_Test_Directory.getText().trim().length() == 0) {
JOptionPane.showMessageDialog(null, "\t\tPlease select a directory to save the Fingerprints!", "Missing Directory",
JOptionPane.WARNING_MESSAGE);
} else if (Test_File_Directory.getText().trim().length() == 0 && Save_Test_Directory.getText().trim().length() == 0) {
JOptionPane.showMessageDialog(null, "\t\tFile not selected!", "Missing File",
JOptionPane.WARNING_MESSAGE);
} else if (testfile.length() != 0) {
openTestFile.setEnabled(false);
saveTestFile.setEnabled(false);
FileWriter writer = new FileWriter(testfile);
br = new BufferedReader(new FileReader(testFile));
IteratingSMILESReader iteratingSMILESReader = new IteratingSMILESReader(br, DefaultChemObjectBuilder.getInstance());
if (iteratingSMILESReader.hasNext()) {
IAtomContainer molecule = (IAtomContainer) iteratingSMILESReader.next();
int maxFingerprints = 1024;
String[] descriptorValues_ = new String[maxFingerprints];
for (int i = 0; i < maxFingerprints; ++i) {
descriptorValues_[i] = "";
}
BitSet fingerprint = new Fingerprinter().getFingerprint(molecule);
writer.append(testFile.getName());
Test_Ready.setText("Processing : " + testFile.getName() + " ...");
for (int i = 0; i < maxFingerprints; ++i) {
if (fingerprint.get(i) == true) {
writer.append("1");
writer.flush();
} else if (fingerprint.get(i) == false) {
writer.append("0");
writer.flush();
}
// progressBar.setValue(i);
// progressBar.repaint();
}
}
writer.close();
Test_Ready.setText("Process Completed!");
JOptionPane.showMessageDialog(null, "\t\tProcess Completed!", "Completed",
JOptionPane.INFORMATION_MESSAGE);
openTestFile.setEnabled(true);
saveTestFile.setEnabled(true);
refreshTab.setVisible(true);
about.setVisible(true);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
}
I had create a stop button to and try to stop the program once I click on it. But how can I implement the Stop_Convert actionlistener to my convert actionlistener ?


Sign In
Create Account


Back to top













