-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.java
245 lines (168 loc) · 7.81 KB
/
main.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
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
package com.example.project;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import javafx.scene.paint.Color;
import javax.swing.JFrame;
import javax.sound.sampled.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyListener;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class main extends Application {
@Override
public void start(Stage primaryStage) throws LineUnavailableException, InterruptedException {
primaryStage.setTitle("Game Room 2");
Group root = new Group();
TextArea ta = new TextArea();
ta.setBorder(new Border(new BorderStroke(Color.GREY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
TextArea userList = new TextArea();
Scene scene = new Scene(root, 640, 480);
scene.setFill(Color.LIGHTGRAY);
TextArea ta2 = new TextArea();
try {
AudioFormat format = new AudioFormat(1600, 8, 2, true, true); //adjusting bitrate and sound quality
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); // We need a line to listen in on.
} catch (Exception e) {
System.out.println(e);
}
final String[][] Categories = {{"Games"},{"Game Room: 1", "Game Room: 2"},{"Television"},{"International"}};
/*
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Tree tree = new Tree();
tree.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tree.setTitle("Join Room");
tree.setLayout(new BorderLayout());
TreeSecond mytree2 = new TreeSecond(Categories);
tree.add(mytree2.getJPanel(), "Center");
tree.setVisible(true);
tree.pack();
}
});
*/
ComboBox<String> fontBox = new ComboBox<>();
fontBox.getItems().addAll("Arial","Comic-Sans","Times New Roman");
fontBox.setStyle("-fx-color: #FFFFFF");
ComboBox<String> fontSize = new ComboBox<>();
fontSize.getItems().addAll("8","10","12","20","22","34");
fontSize.setStyle("-fx-color: #FFFFFF");
BorderPane paneForComboBox = new BorderPane();
paneForComboBox.setCenter(fontBox);
paneForComboBox.setPrefSize(160,200);
paneForComboBox.setLayoutX(280);
paneForComboBox.setLayoutY(240);
BorderPane paneForComboBoxTwo = new BorderPane();
paneForComboBoxTwo.setCenter(fontSize);
paneForComboBoxTwo.setPrefSize(170, 200);
paneForComboBoxTwo.setLayoutX(80);
paneForComboBoxTwo.setLayoutY(240);
System.out.println("Ended sound test");
ta2.setEditable(false);
String name = "Chase";
userList.setPrefSize(170, 300);
userList.setLayoutX(460);
userList.setLayoutY(20);
userList.setEditable(false);
userList.appendText(name + "\n");
userList.appendText("Tommy" + "\n");
Button sendBtn = new Button("Send");
Button webcamBtn = new Button("Webcam");
Button fileBtn = new Button("File");
Button emojiBtn = new Button("Emoji");
Button micBtn = new Button("Talk");
ta.setPrefSize(360, 100); // resize the box itself
ta.prefWidthProperty();
ta.setLayoutX(20); // x axis positioning
ta.setLayoutY(360); // y axis positioning
ta.setFont(new Font("Comic-Sans", 16));
ta.getText();
ta2.setLayoutX(20);
ta2.setLayoutY(20);
ta2.setPrefSize(360, 300);
micBtn.setLayoutX(200);
micBtn.setLayoutY(325);
micBtn.setPrefSize(70,30);
micBtn.setStyle("-fx-background-color:#32CD32");
micBtn.setBorder(new Border((new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT))));
micBtn.setFont(Font.font("Aerial", FontWeight.BOLD, FontPosture.REGULAR, 14)); // Trying to mimic the font look of Yahoo Messenger's talk button
EventHandler handler2 = new EventHandler() {
@Override
public void handle(Event event) {
System.out.println("Based");
}
};
micBtn.setOnMouseReleased(handler2);
Image image = new Image("C:\\Users\\Wojak\\IdeaProjects\\project\\target\\classes\\com\\example\\project\\smiley.png");
ImageView imageView = new ImageView(image);
//imageView.setLayoutX();
imageView.setLayoutY(-10);
sendBtn.setPrefSize(60, 60); // resize the box itself
sendBtn.setLayoutX(470); // x axis positioning
sendBtn.setLayoutY(350); // y axis positioning
// When microphone button is pressed, it will begin recording voice.
micBtn.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
System.out.println("Yes");
// record stuff here
}
});
ta.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent j) {
if(j.getCode().equals(KeyCode.ENTER)) {
String str = ta.getText();
// this will append text to the chat box above
ta2.appendText(name + ": " + str + "\n");
}
}
});
sendBtn.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent k) {
if(k.getCode().equals(KeyCode.ENTER)){
String str = ta.getText();
// this will append text to the chat box above
ta2.appendText(str + "\n");
}
}
});
root.getChildren().add(userList);
root.getChildren().add(sendBtn);
root.getChildren().add(ta);
root.getChildren().add(micBtn);
root.getChildren().add(ta2);
root.getChildren().add(paneForComboBox);
root.getChildren().add(paneForComboBoxTwo);
root.getChildren().add(imageView);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) throws LineUnavailableException, InterruptedException {
Application.launch(args); // will launch javaFX
}
}