-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlikeNshow.java
More file actions
183 lines (128 loc) · 4.41 KB
/
Copy pathlikeNshow.java
File metadata and controls
183 lines (128 loc) · 4.41 KB
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
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.script.Bindings;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.sun.glass.ui.CommonDialogs.ExtensionFilter;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.control.ToggleButton;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.layout.StackPaneBuilder;
import javafx.stage.Stage;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.stage.FileChooser;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.RowConstraints;
/**
* @author zizhao zhang ,Jianbo Huang,Yijing Li
* @pid: A92121287, A91082706, A99108545
* @compile: javac likeNshow.java
* @run: java likeNshow
* the class to pass in all the variables into the parameter of the myButton
* in order to create four buttons; On the other initialized the gridpane,
* scenes, and stages to perform the display of the javafx effect.
*
*/
public class likeNshow extends Application{
//launching the stage to show
public static void main(String[] args) {
Application.launch(args);
}
//declaring all the global variables
public Image Upload;
public GridPane pane;
public Stage stage;
public MyButton dislike;
public Label label1;
public MyButton upload;
public File file;
public MyButton like;
public MyButton edit;
public String filePath;
public Image base;
public ImageView IM;
public double imgX = 0;
public double imgY = 0;
public double initTranslateX = 0;
public double initTranslateY = 0;
//initializing the stage , scene, and gridpane
/**
* @param : The stage for displaying all the elements
* the method assign appropriate variables to the call the method
* Mybutton in order to create elements on the stage.
*/
public void start(Stage stage) throws Exception {
try{
//showing the image
//setting up the file choosers
FileChooser fileChooser = new FileChooser();
//Declaring local pictures for all the buttons and backgrounds.
Image unlike= new Image("./img/DISLIKE2.jpg");
Image Like = new Image("./img/LIKE2.jpg");
Image edit2 = new Image("./img/editLast.jpg");
Image background1 = new Image("./img/smartphone1_meitu_2.jpg");
Image start= new Image("./img/instagram-512.jpg");
//set up the button for dislike
dislike = new MyButton(unlike,MyButton.BUTTON_DISLIKE,this);
//set up the button for like
like= new MyButton(Like ,MyButton.BUTTON_LIKE,this);
//setting up the button for upload
upload = new MyButton(start, MyButton.BUTTON_UPLOAD,this);
//setting up the button for edit
edit= new MyButton(edit2, MyButton.BUTTON_EDIT,this);
//set up the gridPane to stage the button onto
pane = new GridPane();
//setting the constraints of the gridpane
for (int i = 0; i < 8; i++) {
ColumnConstraints column = new ColumnConstraints(35);
pane.getColumnConstraints().add(column);
}
//ratio 1:2
for(int j = 0; j < 16; j++){
RowConstraints row = new RowConstraints(35);
pane.getRowConstraints().add(row);
}
//setting back ground pictures for display
ImageView imageView1 = new ImageView();
imageView1.setImage(background1);
//setting buttons onto the gridpane and adjust layout
pane.setPrefSize(25, 35);
//adding all the buttons onto the gridpane
pane.add(imageView1,0 ,8);
pane.add(upload,3,1);
pane.add(dislike,6 ,15);
pane.add(like, 1, 15);
pane.add(edit, 3, 15);
pane.setPadding(new Insets(10, 12, 40, 12));
//makes the color black for gridPane and the edges of buttons
pane.setStyle("-fx-background-color: #000000;");
dislike.setStyle("-fx-background-color: #000000;");
upload.setStyle("-fx-background-color: #000000;");
like.setStyle("-fx-background-color: #000000;");
edit.setStyle("-fx-background-color: #000000;");
Scene scene = new Scene(pane);
stage.setScene(scene);
stage.setHeight(900);
stage.setWidth(1600);
stage.sizeToScene();
stage.show();
//allow the stage to show
}
catch(Exception e1){
//catch the exception
System.out.println("something went wrong");
}
}
}