You are on page 1of 5

import java.awt.

Color;
import java.awt.EventQueue;
import java.awt.*;
import java.util.*;
import java.util.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

public class Compliance extends JFrame {

private JPanel contentPane;


private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Compliance frame = new Compliance();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public Compliance() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 828, 476);
contentPane = new JPanel();
contentPane.setBackground(Color.LIGHT_GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabel lblNewLabel = new JLabel("Magnus");


lblNewLabel.setBounds(705, 11, 46, 14);
contentPane.add(lblNewLabel);

JLabel lblUsSanctionsList = new JLabel("US sanctions list:");


lblUsSanctionsList.setBounds(23, 103, 129, 19);
contentPane.add(lblUsSanctionsList);

JButton btnUpload = new JButton("Start screening");

btnUpload.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
File ff;
PDFManager pdfManager = new PDFManager();
JFileChooser jf = new JFileChooser();
int aa = jf.showOpenDialog(null);
if(aa==JFileChooser.APPROVE_OPTION) {
ff=jf.getSelectedFile();
textField.setText(ff.getAbsolutePath());
String filePath = ff.getAbsolutePath();
pdfManager.setFilePath(filePath);

ExcelReader excel = new


ExcelReader("D:\\Users\\Bull's Eye\\eclipse-
workspace\\ExcelDemosWithPOI\\ExcelDemosWithPOI\\howtodoinjava_demo.xlsx");
ArrayList word = excel.names();
String[] nameToSearch = new
String[word.size()];
for (int i = 0; i < word.size(); i++) {
nameToSearch[i] = word.get(i).toString();
}

try (Writer writer = new BufferedWriter(new


OutputStreamWriter(
new FileOutputStream("D:\\file.txt"),
"utf-8"))) {
writer.write(pdfManager.ToText());
} catch (UnsupportedEncodingException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (FileNotFoundException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}

FileReader fr;
try {
for(String name : nameToSearch) {

fr = new FileReader("D:\\file.txt");
BufferedReader br=new BufferedReader(fr);
String s;
String line1;
String line2;
String line3;
String searchID = "QDi";
int linecount=0;
String line;
//String words[]=new String[500];

while ((s=br.readLine())!=null)
{
linecount++;
int
indexfound=s.toLowerCase().indexOf(name.toLowerCase());
if (indexfound>-
1)
{

//System.out.println("\n");

//System.out.println("Word was found at position::" +indexfound+ "::on


line"+linecount);

System.out.println("\n");
line=s;

System.out.println(line);
line1 =
br.readLine();
line2 =
br.readLine();
line3 =
br.readLine();

if(line1.toLowerCase().indexOf(searchID.toLowerCase()) != -1 ) {

System.out.println(line1);
}

System.out.println(line2);

System.out.println(line3);

//
int idx=0;
//
StringTokenizer st= new StringTokenizer(line);
//
tokencount= st.countTokens();
//
System.out.println("\n");
//
System.out.println("Number of tokens found" +tokencount);
//
System.out.println("\n");
//
for (idx=0;idx<tokencount;idx++)
//
{
//
words[idx]=st.nextToken();
//
System.out.println(words[idx]);
//
}
}

fr.close();
}

} catch (FileNotFoundException e1) {


// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

System.out.println("DONE");
}
}
});
btnUpload.setBounds(128, 195, 383, 23);
contentPane.add(btnUpload);

JLabel lblMagnusList = new JLabel("Magnus' list:");


lblMagnusList.setBounds(23, 139, 67, 14);
contentPane.add(lblMagnusList);

JButton btnUpload_1 = new JButton("Update");


btnUpload_1.setBounds(554, 132, 122, 23);
contentPane.add(btnUpload_1);

JButton btnStartScreening = new JButton("Update");


btnStartScreening.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
btnStartScreening.setBounds(554, 101, 122, 23);
contentPane.add(btnStartScreening);

textField = new JTextField();


textField.setBounds(128, 102, 383, 20);
contentPane.add(textField);
textField.setColumns(10);

textField_1 = new JTextField();


textField_1.setBounds(128, 133, 383, 20);
contentPane.add(textField_1);
textField_1.setColumns(10);

JTextArea textArea = new JTextArea();


textArea.setBounds(23, 229, 728, 172);
contentPane.add(textArea);

textField_2 = new JTextField();


textField_2.setBounds(128, 164, 383, 20);
contentPane.add(textField_2);
textField_2.setColumns(10);

JLabel lblTemporaryFolder = new JLabel("Temporary folder:");


lblTemporaryFolder.setBounds(23, 167, 95, 14);
contentPane.add(lblTemporaryFolder);

JButton button = new JButton("Update");


button.setBounds(554, 163, 122, 23);
contentPane.add(button);
}
}

You might also like