-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetwork.java
58 lines (42 loc) · 1.61 KB
/
Network.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
import java.io.IOException;
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class Network{
private final JFrame connect = new JFrame("Connections");
private final JPanel panel1 = new JPanel();
public JPanel getPanel1(){
return panel1;
}
static public void main(String[] args) throws IOException {
Network net = new Network();
net.panel1.setLayout(new FlowLayout());
ImageIcon routerImage= new ImageIcon(Objects.requireNonNull(Network.class.getResource("router.jpg")));
JLabel label = new JLabel(routerImage);
label.setBounds(1000, 1000, routerImage.getIconWidth(), routerImage.getIconHeight());
net.connect.add(label);
Scanner scan = new Scanner(System.in);
int connections, devices;
System.out.println("What is the number of WI-FI Connections?");
connections = scan.nextInt();
Router router = new Router(connections);
System.out.println("What is the number of devices Clients want to connect?");
devices = scan.nextInt();
ArrayList<Device> inputDevices = new ArrayList<>(devices);
for(int i = 0 ; i < devices ;i++){
System.out.print("Enter Device name and type: ");
String name = scan.next();
String type = scan.next();
Device device = new Device(name, type, router, net);
inputDevices.add(device);
}
for (Device inputDevice : inputDevices) {
inputDevice.start();
}
net.connect.setSize(1650, 1000);
net.connect.getContentPane().add(net.panel1, "North");
net.connect.setVisible(true);
net.connect.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
scan.close();
}
}