diff options
author | cirakg <ciraboxkg@gmail.com> | 2022-12-30 07:27:32 +0100 |
---|---|---|
committer | cirakg <ciraboxkg@gmail.com> | 2022-12-30 07:27:32 +0100 |
commit | e5476a4f36551f11db0dc33e972a906adf0e0b5b (patch) | |
tree | cdc05bf1a3098f926188be0a3ae58a0399074dfa /src/main/java/ui/OpponentConfirmation.java | |
parent | 8d493c16f4bcfcb5c9f9754c999915ad00e650dd (diff) |
Omoguceno slanje zahteva za igru. Omoguceno accept i refuse zahteva(TODO ISPRAVITI).
Diffstat (limited to 'src/main/java/ui/OpponentConfirmation.java')
-rw-r--r-- | src/main/java/ui/OpponentConfirmation.java | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/main/java/ui/OpponentConfirmation.java b/src/main/java/ui/OpponentConfirmation.java new file mode 100644 index 0000000..d0c2a95 --- /dev/null +++ b/src/main/java/ui/OpponentConfirmation.java @@ -0,0 +1,93 @@ +package ui; + +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import models.ComboBoxUser; +import models.User; + +import javax.swing.JLabel; +import javax.swing.JButton; +import java.awt.event.ActionListener; +import java.nio.ByteBuffer; +import java.nio.channels.SocketChannel; +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; + +public class OpponentConfirmation extends JPanel { + public JLabel lblNewLabel; + public JButton btnAccept; + public JButton btnRefuse; + public long opponentId; + + public OpponentConfirmation() { + setLayout(null); + + lblNewLabel = new JLabel("New label"); + lblNewLabel.setBounds(95, 66, 208, 98); + add(lblNewLabel); + + btnAccept = new JButton("Accept"); + btnAccept.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String msg="ACCEPTOPPONENT:"+opponentId; + ByteBuffer bb=ByteBuffer.wrap(msg.getBytes()); + MainFrame topFrame=(MainFrame) SwingUtilities.getAncestorOfClass(MainFrame.class, OpponentConfirmation.this); + try { + SocketChannel client=topFrame.getClient(); + client.write(bb); + SwingUtilities.updateComponentTreeUI(topFrame); + } catch (Exception e1) { + e1.printStackTrace(); + } + + + } + }); + btnAccept.setBounds(92, 194, 89, 23); + add(btnAccept); + + btnRefuse = new JButton("Refuse"); + btnRefuse.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String msg="REFUSEOPPONENT:"+opponentId; + ByteBuffer bb=ByteBuffer.wrap(msg.getBytes()); + MainFrame topFrame=(MainFrame) SwingUtilities.getAncestorOfClass(MainFrame.class, OpponentConfirmation.this); + try { + SocketChannel client=topFrame.getClient(); + client.write(bb); + SwingUtilities.updateComponentTreeUI(topFrame); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + btnRefuse.setBounds(214, 194, 89, 23); + add(btnRefuse); + + } + public long getOpponentId() { + return opponentId; + } + public void setOpponentId(long opponentId) { + this.opponentId = opponentId; + } + public JLabel getLblNewLabel() { + return lblNewLabel; + } + public void setLblNewLabel(JLabel lblNewLabel) { + this.lblNewLabel = lblNewLabel; + } + public JButton getBtnAccept() { + return btnAccept; + } + public void setBtnAccept(JButton btnAccept) { + this.btnAccept = btnAccept; + } + public JButton getBtnRefuse() { + return btnRefuse; + } + public void setBtnRefuse(JButton btnRefuse) { + this.btnRefuse = btnRefuse; + } +} |