diff options
author | Ben Burwell <ben.burwell@trifecta.com> | 2016-11-17 22:02:28 -0500 |
---|---|---|
committer | Ben Burwell <ben.burwell@trifecta.com> | 2016-11-17 22:02:28 -0500 |
commit | 347fce362672f458a71da542895f38f17109e460 (patch) | |
tree | 3f44b1ced72aeec61a8556f1a9ab2d75991591ff /src/com/benburwell | |
parent | b632e590f94dbef1a4415100456528772f7014f8 (diff) |
Actually prompt for TCP connection options
Diffstat (limited to 'src/com/benburwell')
-rw-r--r-- | src/com/benburwell/planes/gui/Main1090.java | 6 | ||||
-rw-r--r-- | src/com/benburwell/planes/gui/TCPConnectionOptionDialog.java | 45 |
2 files changed, 49 insertions, 2 deletions
diff --git a/src/com/benburwell/planes/gui/Main1090.java b/src/com/benburwell/planes/gui/Main1090.java index 5b446c6..490e3e6 100644 --- a/src/com/benburwell/planes/gui/Main1090.java +++ b/src/com/benburwell/planes/gui/Main1090.java @@ -25,7 +25,7 @@ public class Main1090 extends JFrame { this.createMenuBar(); this.setTitle("1090"); - this.setSize(100, 100); + this.setSize(600, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); @@ -48,7 +48,9 @@ public class Main1090 extends JFrame { provider.getDataConnectItem().addActionListener((ActionEvent event) -> { if (this.currentTcpConnection == 0) { - this.currentTcpConnection = this.addTcpSource("10.0.0.111", 30003); + TCPConnectionOptionDialog dialog = new TCPConnectionOptionDialog(); + JOptionPane.showMessageDialog(this, dialog.getComponent(), "New Network Data Source", JOptionPane.PLAIN_MESSAGE); + this.currentTcpConnection = this.addTcpSource(dialog.getHost(), dialog.getPort()); provider.getDataConnectItem().setEnabled(false); provider.getDataDisconnectItem().setEnabled(true); } diff --git a/src/com/benburwell/planes/gui/TCPConnectionOptionDialog.java b/src/com/benburwell/planes/gui/TCPConnectionOptionDialog.java new file mode 100644 index 0000000..609a70a --- /dev/null +++ b/src/com/benburwell/planes/gui/TCPConnectionOptionDialog.java @@ -0,0 +1,45 @@ +package com.benburwell.planes.gui; + +import javax.swing.*; + +/** + * Created by ben on 11/17/16. + */ +public class TCPConnectionOptionDialog implements ViewComponent { + public static final String DEFAULT_HOSTNAME = "10.0.0.111"; + public static final int DEFAULT_TCP_PORT = 30003; + + private JPanel dialog = new JPanel(); + private JTextField hostField = new JTextField(10); + private JTextField portField = new JTextField(5); + private JLabel descriptionLabel = new JLabel("Add a network data source that provides data in the SBS-1 format"); + + @Override + public JComponent getComponent() { + // set properties + hostField.setText(DEFAULT_HOSTNAME); + hostField.setToolTipText("Hostname or IP address"); + + portField.setText(String.valueOf(DEFAULT_TCP_PORT)); + portField.setToolTipText("Port number"); + + // create layout + dialog.add(descriptionLabel); + dialog.add(hostField); + dialog.add(portField); + + return dialog; + } + + public String getHost() { + return this.hostField.getText(); + } + + public int getPort() { + try { + return Integer.valueOf(this.portField.getText()); + } catch (NumberFormatException e) { + return DEFAULT_TCP_PORT; + } + } +} |