import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Engr.Ali Raza
*/
public class control extends javax.swing.JFrame {
/**
* Creates new form control
*/
public control() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel7 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(700, 550));
getContentPane().setLayout(null);
jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/umer sab.png"))); // NOI18N
getContentPane().add(jLabel7);
jLabel7.setBounds(170, 200, 320, 34);
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/names.png"))); // NOI18N
getContentPane().add(jLabel5);
jLabel5.setBounds(170, 120, 370, 30);
jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sup.png"))); // NOI18N
getContentPane().add(jLabel6);
jLabel6.setBounds(160, 160, 290, 30);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/group members.png"))); // NOI18N
getContentPane().add(jLabel4);
jLabel4.setBounds(160, 80, 300, 40);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pu (2).png"))); // NOI18N
getContentPane().add(jLabel3);
jLabel3.setBounds(150, 10, 500, 60);
jButton1.setBackground(new java.awt.Color(204, 51, 0));
jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton1.setForeground(new java.awt.Color(255, 255, 51));
jButton1.setText("Moving Up");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(40, 310, 130, 60);
jButton2.setBackground(new java.awt.Color(204, 51, 0));
jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton2.setForeground(new java.awt.Color(255, 255, 51));
jButton2.setText("Fire ");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(270, 440, 130, 60);
jButton3.setBackground(new java.awt.Color(204, 51, 0));
jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton3.setForeground(new java.awt.Color(255, 255, 102));
jButton3.setText("Stop");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3);
jButton3.setBounds(270, 310, 130, 60);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Punjab-University-Logo-or-Monogram.png"))); // NOI18N
jLabel1.setText("jLabel1");
getContentPane().add(jLabel1);
jLabel1.setBounds(10, 10, 130, 160);
jButton4.setBackground(new java.awt.Color(204, 51, 0));
jButton4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton4.setForeground(new java.awt.Color(255, 255, 51));
jButton4.setText("Moving Down");
jButton4.setMargin(new java.awt.Insets(2, 8, 2, 8));
jButton4.setMaximumSize(new java.awt.Dimension(120, 50));
jButton4.setPreferredSize(new java.awt.Dimension(150, 50));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
getContentPane().add(jButton4);
jButton4.setBounds(510, 310, 140, 60);
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/world-best-army-picture-and-wallpaper.jpg"))); // NOI18N
jLabel2.setMaximumSize(new java.awt.Dimension(2000, 2000));
jLabel2.setPreferredSize(new java.awt.Dimension(800, 700));
getContentPane().add(jLabel2);
jLabel2.setBounds(0, 0, 800, 563);
getContentPane().add(filler1);
filler1.setBounds(0, 238, 0, 0);
pack();
}// </editor-fold>
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
Socket clientSocket = null;
try {
clientSocket = new Socket("ALIRAZA-HP",6789);
} catch (UnknownHostException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
DataOutputStream outToServer = null;
try {
outToServer = new DataOutputStream(clientSocket.getOutputStream());
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
try {
outToServer.writeBytes("d");
clientSocket.close();
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
Socket clientSocket = null;
try {
clientSocket = new Socket("ALIRAZA-HP",6789);
} catch (UnknownHostException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
DataOutputStream outToServer = null;
try {
outToServer = new DataOutputStream(clientSocket.getOutputStream());
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
try {
outToServer.writeBytes("s");
clientSocket.close();
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Socket clientSocket = null;
try {
clientSocket = new Socket("ALIRAZA-HP",6789);
} catch (UnknownHostException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
DataOutputStream outToServer = null;
try {
outToServer = new DataOutputStream(clientSocket.getOutputStream());
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
try {
outToServer.writeBytes("u");
clientSocket.close();
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Socket clientSocket = null;
try {
clientSocket = new Socket("ALIRAZA-HP",6789);
} catch (UnknownHostException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
DataOutputStream outToServer = null;
try {
outToServer = new DataOutputStream(clientSocket.getOutputStream());
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
try {
outToServer.writeBytes("f");
clientSocket.close();
} catch (IOException ex) {
Logger.getLogger(control.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see [url=http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html]How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)[/url]
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(control.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(control.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(control.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(control.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new control().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.Box.Filler filler1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
// End of variables declaration
}