-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathConnectFrame.java
72 lines (57 loc) · 1.78 KB
/
ConnectFrame.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
package com.zacharyfox.rmonitor.leaderboard.frames;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import net.miginfocom.swing.MigLayout;
public class ConnectFrame extends JFrame
{
public JButton connectButton;
public JTextField ip;
public JTextField port;
private final JLabel ipLabel;
private final JLabel portLabel;
private static ConnectFrame instance;
private static final long serialVersionUID = 3848021032174790659L;
private ConnectFrame(MainFrame mainFrame)
{
getContentPane().setLayout(new MigLayout("", "[][grow]", "[][][]"));
ipLabel = new JLabel("Scoreboard IP:");
ipLabel.setHorizontalAlignment(SwingConstants.RIGHT);
getContentPane().add(ipLabel, "cell 0 0,alignx trailing");
setBounds(100, 100, 400, 150);
ip = new JTextField();
ip.setText("127.0.0.1");
getContentPane().add(ip, "cell 1 0,growx");
ip.setColumns(10);
portLabel = new JLabel("Scoreboard Port:");
portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
getContentPane().add(portLabel, "cell 0 1,alignx trailing");
port = new JTextField();
port.setText("50000");
getContentPane().add(port, "cell 1 1,growx");
port.setColumns(10);
connectButton = new JButton("Connect");
connectButton.setHorizontalAlignment(SwingConstants.RIGHT);
connectButton.addActionListener(mainFrame);
getContentPane().add(connectButton, "cell 1 2,alignx right");
}
public String getIP()
{
return ip.getText();
}
public Integer getPort()
{
return Integer.parseInt(port.getText());
}
public static ConnectFrame getInstance(MainFrame mainFrame)
{
if (instance == null) {
instance = new ConnectFrame(mainFrame);
}
return instance;
}
}