-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain_Window.java
139 lines (98 loc) · 4.26 KB
/
Main_Window.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package focus;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TextArea;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
*
* @author rakesh
*/
public class Main_Window extends Application {
static String keywords_text=null;
@Override
public void start(Stage stage) {
TextArea counter = new TextArea();
TextArea keywords = new TextArea();
Button crawl = new Button("Start");
TextArea progress_text=new TextArea();
//progress_text.setStyle("-fx-background-color: transparent;");
Label label = new Label("Enter Keyword");
Label label_counter = new Label("Counter");
progress_text.setEditable(false);
ProgressIndicator progress=new ProgressIndicator();
progress.setVisible(false);
progress_text.setPrefColumnCount(50); //Width
progress_text.setPrefRowCount(50); //Height
keywords.setPrefColumnCount(8); //Width
keywords.setPrefRowCount(5); //Height
counter.setPrefColumnCount(1); //Width
counter.setPrefRowCount(1); //Height
HBox horizontal_layout = new HBox();
VBox vertical_layout = new VBox();
horizontal_layout.setStyle("-fx-background-color: transparent;");
//vertical_layout.setStyle("-fx-background-color: transparent;");
vertical_layout.setAlignment(Pos.CENTER); // To align nodes (Button,SearchBox,ProgressIndicator) in center
vertical_layout.setSpacing(30);
HBox.setMargin(vertical_layout, new Insets(20, 20, 20, 20));
HBox.setMargin(progress_text, new Insets(20, 20, 20, 20));
ObservableList list_v=vertical_layout.getChildren();
list_v.addAll(label,keywords,crawl,progress,label_counter,counter);
ObservableList list_h = horizontal_layout.getChildren();
list_h.addAll(vertical_layout,progress_text);
Scene scene = new Scene(horizontal_layout,1000,1000);
Platform.setImplicitExit(true); // Closes Windows Instead Of Hinding It
stage.setOnCloseRequest((ae) -> { // SO, Exit application along with all backgroud threads
Platform.exit();
System.exit(0);
});
//scene.setFill(Color.TRANSPARENT);
//scene.setFill(null);
stage.setTitle("Main Window");
stage.setScene(scene);
stage.show();
Start_Crawling startcrawl=new Start_Crawling();
EventHandler<MouseEvent> eventHandler = (MouseEvent e) -> {
keywords_text=keywords.getText();
System.out.println(keywords_text);
new Thread(
() -> {
try {
progress.setVisible(true); //display progressbar
startcrawl.start(progress_text,counter);
progress.setVisible(false); //hide progressbar
} catch (IOException ex) {
Logger.getLogger(FOCUS.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(Main_Window.class.getName()).log(Level.SEVERE, null, ex);
}
}).start();
};
crawl.addEventFilter(MouseEvent.MOUSE_CLICKED, eventHandler);
}
/**
*
*/
public void start(){
launch();
}
}