Скачиваний:
12
Добавлен:
10.02.2020
Размер:
3.27 Кб
Скачать
import javax.swing.*;
import java.awt.*;
import java.lang.String.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
public class Main {
public static JTextField textField1;
public static JTextField textField;
public static JProgressBar progressBar;
public static JLabel label;
public static JTextArea ta,ta1;
public static  JScrollPane sp,sp1;
public static JFrame frame;
public static File file1,file;
public static void main(String[] args) {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(200, 200, 615, 410);
frame.setLayout(null);
frame.setName("Антивірусний сканер");
JButton button = new JButton("Обрати базу даних");
button.setBounds(0, 0, 180, 30);
JButton button1 = new JButton("Обрати файл ");
button1.setBounds(0, 30, 180, 30);
JButton button2 = new JButton("Сканувати");
button2.setBounds(0, 90, 600, 30);
frame.add(button);
frame.add(button1);
frame.add(button2);
progressBar = new JProgressBar(0, 100);
progressBar.setBounds(0, 60, 600, 30);
progressBar.setBorderPainted(true);
progressBar.setBackground(Color.white);
progressBar.setValue(0);
frame.add(progressBar);
textField = new JTextField();
textField.setBounds(180, 0, 420, 30);
textField1 = new JTextField();
textField1.setBounds(180, 30, 420, 30);
textField.setText("BD.txt");
file = new File(textField.getText());
textField.setEditable(false);
textField1.setText("C:\\Users\\");
file1 = new File(textField1.getText());
textField1.setEditable(false);
frame.add(textField);
frame.add(textField1);
progressBar.setStringPainted(true);
sp = new JScrollPane();
sp.setBounds(0, 120, 350, 250);
ta = new JTextArea("");
ta.setBounds(0, 120, 350, 250);
ta.setEditable(false);
ta.setFont(new Font("Century Gothic", Font.PLAIN,14));
frame.add(ta);
frame.add(sp);
sp.setViewportView(ta);

sp1 = new JScrollPane();
sp1.setBounds(350, 120, 250, 250);
sp1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
ta1 = new JTextArea("Можемо починати!)");
ta1.setBounds(350, 120, 250, 250);
ta1.setEditable(false);
ta1.setLineWrap(true);
ta1.setWrapStyleWord(true);
ta1.setFont(new Font("Century Gothic", Font.PLAIN,14));
frame.add(ta1);
frame.add(sp1);
sp1.setViewportView(ta1);
frame.setVisible(true);

button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
public void run() {
	Scaner.Scaner(frame,file1,file,ta,ta1,progressBar);}
}).start();

}
});
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.showOpenDialog(frame);
file1 = fileChooser.getSelectedFile();
textField1.setText(fileChooser.getSelectedFile().toString());
}
});
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.showOpenDialog(frame);
file = fileChooser.getSelectedFile();
textField.setText(fileChooser.getSelectedFile().toString());
}
});
}
}
Соседние файлы в папке src