first gui

This commit is contained in:
Jakub Adamski 2019-11-07 21:22:20 +01:00
parent 80f6635036
commit a061c2dafd

View File

@ -1,11 +1,63 @@
package Projekt;
import java.io.*;
import java.net.*;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;
public class App
{
public static void main(String[] args) {
JFrame frame = new JFrame("Messages");
JTextField ipText, portText, messageT;
JButton connectB, mSendB, fSendB;
JLabel usersL;
JComboBox<String> usersC;
JList<String> messagesL;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(320,400);
ipText = new JTextField("Server IP");
ipText.setBounds(10,10, 200,30);
portText = new JTextField("Port");
portText.setBounds(210, 10, 100, 30);
connectB = new JButton("Connect");
connectB.setBounds(110, 50, 100, 30);
usersL = new JLabel("Choose user:");
usersL.setBounds(10, 90, 200, 30);
String users[] = {"Tomus", "Piotrus"};
usersC = new JComboBox<>(users);
usersC.setBounds(210, 90, 100, 30);
DefaultListModel<String> messages = new DefaultListModel<>();
messages.addElement("<USER> Elo");
messages.addElement("<YOU> No siema");
messagesL = new JList<String>(messages);
messagesL.setBounds(10, 130, 300, 150);
messageT = new JTextField("Message");
messageT.setBounds(10, 290, 300, 30);
mSendB = new JButton("Send");
mSendB.setBounds(55, 330, 100, 30);
fSendB = new JButton("File");
fSendB.setBounds(165, 330, 100, 30);
frame.add(ipText);
frame.add(portText);
frame.add(connectB);
frame.add(usersL);
frame.add(usersC);
frame.add(messagesL);
frame.add(messageT);
frame.add(mSendB);
frame.add(fSendB);
frame.setLayout(null);
frame.setVisible(true);
/*
try {
// USTALAMY adres serwera i port - trzeba wpisac to co wyrzuca po uruchomieniu serwer
InetAddress addr = InetAddress.getByName("0.0.0.0");
@ -37,5 +89,6 @@ public class App
e.printStackTrace();
}
System.out.println("Klient zakonczyl dzialanie");
*/
}
}