Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package klient1_gui;
- public class GUI extends javax.swing.JFrame {
- Thread send;
- Thread receive = new Thread(new ReceiveTheMessage());
- String message;
- /*public void sTM() {
- SendTheMessage call = new SendTheMessage();
- call.getTheString(message);
- }*/
- public GUI() {
- }
- public GUI(String message) {
- send = new Thread(new SendTheMessage());
- this.message = message;
- initComponents();
- receive.start();
- }
- public String getThisText() {
- message = getTheText.getText();
- System.out.println("Text: " + message);
- return message;
- }
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jPanel1 = new javax.swing.JPanel();
- sendButton = new javax.swing.JButton();
- getTheText = new javax.swing.JTextField();
- jLabel1 = new javax.swing.JLabel();
- jScrollPane2 = new javax.swing.JScrollPane();
- displayText = new javax.swing.JTextArea();
- jLabel2 = new javax.swing.JLabel();
- exitButtom = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- sendButton.setText("Send The Message!");
- sendButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- sendButtonActionPerformed(evt);
- }
- });
- getTheText.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- getTheTextMouseClicked(evt);
- }
- });
- getTheText.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- getTheTextActionPerformed(evt);
- }
- });
- jLabel1.setText("Witam w komunikatorze kliencie 1");
- displayText.setEditable(false);
- displayText.setColumns(20);
- displayText.setRows(5);
- jScrollPane2.setViewportView(displayText);
- displayText.getAccessibleContext().setAccessibleParent(this);
- jLabel2.setText("Write something to your Friend");
- exitButtom.setText("Wyjscie");
- exitButtom.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- exitButtomActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(sendButton, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addComponent(jLabel2)
- .addGap(0, 0, Short.MAX_VALUE)))
- .addContainerGap())
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addGap(0, 182, Short.MAX_VALUE)
- .addComponent(jLabel1)
- .addGap(85, 85, 85)
- .addComponent(exitButtom))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(getTheText)
- .addComponent(jScrollPane2))
- .addContainerGap())))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(exitButtom)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(47, 47, 47)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(getTheText, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(sendButton)
- .addContainerGap())
- );
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- );
- pack();
- }// </editor-fold>
- private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {
- send.start();
- }
- private void getTheTextActionPerformed(java.awt.event.ActionEvent evt) {
- getTheText.getText();
- }
- private void getTheTextMouseClicked(java.awt.event.MouseEvent evt) {
- getTheText.setText("");
- }
- private void exitButtomActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- System.exit(0);
- }
- // Variables declaration - do not modify
- public javax.swing.JTextArea displayText;
- private javax.swing.JButton exitButtom;
- protected static javax.swing.JTextField getTheText;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JScrollPane jScrollPane2;
- public javax.swing.JButton sendButton;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment