-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathyoussef.gui
466 lines (402 loc) · 18.7 KB
/
youssef.gui
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
package com.example.myjavafx;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.event.ActionEvent;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.OverrunStyle;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
public class HelloController {
public static User user;
public ArrayList<Movie> movies = new ArrayList<Movie>();
@FXML
HBox allMovies;
@FXML
HBox hbox;
@FXML
HBox hbox2;
@FXML
private ScrollPane scrollpane;
@FXML
ImageView first;
@FXML
Stage stage = new Stage();
@FXML
public void jo(ActionEvent event) {
try
{
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("yy.fxml")));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
System.out.println("yah");
} catch (IOException e) {
e.printStackTrace(); // You might want to log the exception or handle it appropriately.
}
}
@FXML
public void joo(ActionEvent event) {
try {
//user.Set_record(user.getID(),movie);
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("watchrecord.fxml")));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
} catch (IOException e) {
e.printStackTrace(); // You might want to log the exception or handle it appropriately.
}
}
@FXML
private void initializee() {
Image img=new Image("file:/C:/Users/www/IdeaProjects/myjavafx/src/main/resources/com/example/myjavafx/13164157_5171295.jpg");
first.setImage(img);
scrollpane.setStyle("-fx-background-color: transparent; -fx-background-insets: 0;");
}
//**********************************************
public void set(User uss)
{
user=uss;
}
//***************************************************************
public void getData(){
Movie movie = new Movie(),movie2=new Movie(),movie3=new Movie();
movie.setTitle("Day shift(2022) Dual for narrow");
movie.setPoster_path("file:/C:/Users/www/IdeaProjects/myjavafx/src/main/resources/com/example/myjavafx/13164157_5171295.jpg");
movie2.setTitle("Day shift(2022) Dual for narrow2");
movie2.setPoster_path("file:/C:/Users/www/IdeaProjects/myjavafx/src/main/resources/com/example/myjavafx/16380264_5741281.jpg");
movie3.setTitle("Day shift(2022) Dual for narrow3");
movie3.setPoster_path("file:/C:/Users/www/IdeaProjects/myjavafx/src/main/resources/com/example/myjavafx/13271619_5177053.jpg");
movies.add(movie);
movies.add(movie2);
movies.add(movie3);
movies.add(movie);
movies.add(movie2);
movies.add(movie3);
}
@FXML
private void initialize(){
getData();
for(Movie movie:movies){
addToGUI(movie);
//addToGUI2(movie);
}
for(int c=6-1;c>=0;c--)
{
addToGUI2(movies.get(c));
}
}
public int useridd(int n)
{
return n;
}
private void addToGUI(Movie movie){
VBox movieContainer = new VBox(1);
movieContainer.setPrefWidth(180);
movieContainer.setPrefHeight(180);
Image image = new Image(movie.getposter_path());
ImageView imageView = new ImageView(image);
imageView.setFitHeight(270);
imageView.setFitWidth(270);
Label label = new Label(movie.getTitle());
label.setTextFill(Color.WHITE);
label.setTextOverrun(OverrunStyle.CLIP);
movieContainer.setAlignment(Pos.CENTER);
movieContainer.getChildren().addAll(imageView, label);
hbox.getChildren().addAll(movieContainer);
movieContainer.setOnMouseClicked(event -> handleVBoxClick(label.getText()));
}
private void handleVBoxClick(String labelText) {
String movietitle=labelText;
Movie mov=new Movie();
for(int c=0;c<movies.size();c++)
{
if(movies.get(c).getTitle()==movietitle)
{
mov=movies.get(c);
break;
}
}
user.Set_record(user.getID(),mov);
System.out.println("i clicked");
user.Display_Watched_Movie();
System.out.println(user.getUser_Name());
System.out.println(user.getFirst_Name());
}
private void addToGUI2(Movie movie){
VBox movieContainer = new VBox(1);
movieContainer.setPrefWidth(180);
movieContainer.setPrefHeight(180);
Image image = new Image(movie.getposter_path());
ImageView imageView = new ImageView(image);
imageView.setFitHeight(270);
imageView.setFitWidth(270);
Label label = new Label(movie.getTitle());
label.setTextFill(Color.WHITE);
label.setTextOverrun(OverrunStyle.CLIP);
movieContainer.setAlignment(Pos.CENTER);
movieContainer.getChildren().addAll(imageView, label);
hbox2.getChildren().addAll(movieContainer);
}
}
********
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="793.0" prefWidth="1353.0" style="-fx-background-color: black;" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.myjavafx.HelloController">
<TextField layoutX="308.0" layoutY="24.0" prefHeight="30.0" prefWidth="459.0" promptText="Search movies..." style="-fx-prompt-text-fill: #ffffff; -fx-background-radius: 30; -fx-text-inner-color: white; -fx-background-color: black;">
<effect>
<DropShadow blurType="ONE_PASS_BOX" height="28.02" radius="12.34" width="23.34">
<color>
<Color red="0.9157894849777222" green="0.8852631449699402" blue="0.8852631449699402" />
</color>
</DropShadow>
</effect>
<font>
<Font name="Bodoni MT" size="11.0" />
</font>
</TextField>
<Button layoutX="786.0" layoutY="24.0" onAction="#jo" style="-fx-background-color: FFC107; -fx-background-radius: 20; -fx-text-fill: #ffffff;" text="Search">
<font>
<Font size="14.0" />
</font>
</Button>
<Pane layoutX="26.0" layoutY="80.0" prefHeight="611.0" prefWidth="244.0" style="-fx-background-color: black; -fx-background-radius: 10;">
<children>
<Label layoutX="8.0" prefHeight="43.0" prefWidth="130.0" text="Follow Watch it on" textFill="WHITE">
<font>
<Font name="Arial Narrow" size="17.0" />
</font>
</Label>
<Label layoutX="10.0" layoutY="232.0" prefHeight="43.0" prefWidth="160.0" style="-fx-background-color: 4764FF; -fx-background-radius: 10;" text=" Common in Watch it" textFill="WHITE">
<font>
<Font name="Agency FB Bold" size="20.0" />
</font>
<effect>
<Lighting diffuseConstant="1.66">
<light>
<Light.Distant />
</light>
<bumpInput>
<Bloom />
</bumpInput>
</Lighting>
</effect>
</Label>
<Label layoutX="14.0" layoutY="275.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text="Watching movie Spy" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="293.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text=" 2018" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="13.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="340.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text="Watching movie mech" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="358.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text=" anic 2016" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="13.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="403.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text="Watching movie mech" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="421.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text=" anic 2016" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="13.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="43.0" opacity="0.77" prefHeight="36.0" prefWidth="119.0" text="Twitter.com" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="16.0" />
</font>
</Label>
<Pane layoutX="157.0" layoutY="43.0" prefHeight="36.0" prefWidth="35.0" style="-fx-background-color: E2F7EB; -fx-background-radius: 50;" />
<Label layoutX="14.0" layoutY="86.0" opacity="0.72" prefHeight="36.0" prefWidth="119.0" text="Facebook.com" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="16.0" />
</font>
</Label>
<Pane layoutX="157.0" layoutY="86.0" prefHeight="36.0" prefWidth="35.0" style="-fx-background-color: E2F7EB; -fx-background-radius: 50;" />
<Label layoutX="14.0" layoutY="129.0" opacity="0.74" prefHeight="36.0" prefWidth="119.0" text="Telegram.com" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="16.0" />
</font>
</Label>
<Pane layoutX="157.0" layoutY="129.0" prefHeight="36.0" prefWidth="35.0" style="-fx-background-color: E2F7EB; -fx-background-radius: 50;" />
<Label fx:id="watchRecords" accessibleRole="BUTTON" layoutX="10.0" layoutY="187.0" opacity="0.8" prefHeight="36.0" prefWidth="193.0" style="-fx-background-color: #001f2f; -fx-background-radius: 10;" text=" Watching Record(0)" textFill="WHITE">
<font>
<Font name="Bodoni MT Bold" size="14.0" />
</font>
<effect>
<Lighting diffuseConstant="1.66">
<light>
<Light.Distant />
</light>
<bumpInput>
<Bloom />
</bumpInput>
</Lighting>
</effect>
</Label>
<Separator layoutX="9.0" layoutY="174.0" opacity="0.4" prefWidth="200.0" style="-fx-background-color: FFC107;" />
<Separator layoutX="9.0" layoutY="230.0" opacity="0.3" prefHeight="3.0" prefWidth="200.0" style="-fx-background-color: FFC107;">
<effect>
<DropShadow radius="45.8375" width="164.35">
<color>
<Color red="0.3069785535335541" green="0.6526315808296204" blue="0.6123054027557373" />
</color>
</DropShadow>
</effect>
</Separator>
<Label layoutX="14.0" layoutY="469.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text="Watching movie Spy" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="487.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text=" 2018" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="13.0" />
</font>
</Label>
<Label layoutX="16.0" layoutY="531.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text="Watching movie Spy" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="14.0" />
</font>
</Label>
<Label layoutX="16.0" layoutY="549.0" opacity="0.91" prefHeight="36.0" prefWidth="152.0" text=" 2018" textFill="WHITE" textOverrun="CLIP">
<font>
<Font name="Bodoni MT" size="13.0" />
</font>
</Label>
</children>
</Pane>
<Label layoutX="308.0" layoutY="89.0" prefHeight="43.0" prefWidth="147.0" text="Top Watched Movies" textFill="WHITE">
<font>
<Font name="Arial Narrow" size="17.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="308.0" layoutY="68.0" prefHeight="24.0" prefWidth="68.0" style="-fx-background-color: black; -fx-background-radius: 25; -fx-border-color: white; -fx-border-radius: 25;" text="All" textFill="WHITE">
<font>
<Font name="System Bold" size="11.0" />
</font></Label>
<Label fx:id="Action" alignment="CENTER" layoutX="392.0" layoutY="68.0" onMouseClicked="#jo" prefHeight="24.0" prefWidth="68.0" style="-fx-background-color: 565661; -fx-background-radius: 25;" text="Action" textFill="#fafafa">
<font>
<Font name="System Bold" size="11.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="482.0" layoutY="68.0" prefHeight="24.0" prefWidth="68.0" style="-fx-background-color: 565661; -fx-background-radius: 25;" text="Comedy" textFill="WHITE">
<font>
<Font name="System Bold" size="11.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="46.0" layoutY="28.0" prefHeight="43.0" prefWidth="119.0" style="-fx-background-color: FFC107; -fx-background-radius: 20;" text="Watch" textFill="WHITE">
<font>
<Font name="Arial Narrow Bold" size="27.0" />
</font>
</Label>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="146.0" layoutY="28.0" prefHeight="43.0" prefWidth="68.0" style="-fx-background-color: black; -fx-background-radius: 25;" text="IT" textFill="WHITE">
<font>
<Font name="Arial Narrow Bold" size="27.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="567.0" layoutY="68.0" prefHeight="24.0" prefWidth="68.0" style="-fx-background-color: 565661; -fx-background-radius: 25;" text="Drama" textFill="WHITE">
<font>
<Font name="System Bold" size="11.0" />
</font>
</Label>
<Label layoutX="307.0" layoutY="400.0" prefHeight="43.0" prefWidth="152.0" text="Recent movies" textFill="WHITE">
<font>
<Font name="Arial Narrow" size="17.0" />
</font>
</Label>
<Pane layoutX="305.0" layoutY="425.0" style="-fx-background-color: black; -fx-background-radius: 15;" />
<ScrollPane fx:id="scrollpane" hbarPolicy="AS_NEEDED" layoutX="307.0" layoutY="123.0" prefHeight="300.0" prefWidth="925.0" style="-fx-background-color: black; -fx-opacity: zero; -fx-background-color: transparent;" stylesheets="file:/C:/Users/www/IdeaProjects/myjavafx/src/main/style.css" vbarPolicy="NEVER">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="286.0" prefWidth="1088.0" style="-fx-background-color: black;">
<children>
<HBox fx:id="hbox" layoutY="-6.0" prefHeight="291.0" prefWidth="1059.0" spacing="10" style="-fx-background-color: black;" />
</children>
</AnchorPane>
</content>
</ScrollPane>
<ScrollPane fx:id="scrollpane2" layoutX="304.0" layoutY="432.0" prefHeight="315.0" prefWidth="934.0" style="-fx-background-color: black;" stylesheets="file:/C:/Users/www/IdeaProjects/myjavafx/src/main/style.css" vbarPolicy="NEVER">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="301.0" prefWidth="1071.0" style="-fx-background-color: black;">
<children>
<HBox fx:id="hbox2" layoutX="2.0" layoutY="2.0" prefHeight="300.0" prefWidth="1070.0" spacing="10" style="-fx-background-color: black;">
<children>
</children>
</HBox>
</children>
</AnchorPane>
</content>
</ScrollPane>
</Pane>
*************
package com.example.myjavafx;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class HelloApplication extends Application {
Stage stage= new Stage();
public static int page = 0;
@Override
public void start(Stage stage) throws IOException {
List<User> users = new ArrayList<>();
User usere = new User(1, "john_doe", "Doe", "John", "john.doe@example.com", "securePassword123");
HelloController.user=usere;
this.stage = stage;
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hellow-view2.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setScene(scene);
stage.setFullScreen(true);
System.out.println("dgd");
stage.show();
}
public void switchScenes(Scene scene) throws IOException
{
/* Parent root = FXMLLoader.load(HelloApplication.class.getResource(fxml));
Scene scene = new Scene(root,320,240);
*/
stage.setScene(scene);
stage.setFullScreen(true);
stage.show();
}
public static void main(String[] args) {
launch();
}
}