/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package netbeansguitest;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Leonard
*/
public class guiLeitstelle extends javax.swing.JFrame {
/**
* Creates new form guiLeitstelle
*/
public guiLeitstelle() {
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() {
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
buttonGroup1 = new javax.swing.ButtonGroup();
jLabel1 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jRadioButton3 = new javax.swing.JRadioButton();
jRadioButton4 = new javax.swing.JRadioButton();
jRadioButton5 = new javax.swing.JRadioButton();
jRadioButton6 = new javax.swing.JRadioButton();
jRadioButton7 = new javax.swing.JRadioButton();
jRadioButton8 = new javax.swing.JRadioButton();
jRadioButton9 = new javax.swing.JRadioButton();
jRadioButton10 = new javax.swing.JRadioButton();
jRadioButton11 = new javax.swing.JRadioButton();
jRadioButton12 = new javax.swing.JRadioButton();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jCheckBox1 = new javax.swing.JCheckBox();
jLabel5 = new javax.swing.JLabel();
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Leitstelle - Funkspiel Steinfurt");
jLabel1.setText("Funkspiel Steinfurt LEITSTELLE");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"Feuerwehr", "HO, HO", "ELW", null},
{"Feuerwehr", "HO, HO", "LF-20/16", null},
{"Feuerwehr", "HO, HO", "LF-16 TS", null},
{"Feuerwehr", "HO, HO", "GW-L", null},
{"Feuerwehr", "HO, HO", "MTW", null},
{"Feuerwehr", "HO, LE", "TLF-16/25", null},
{"Feuerwehr", "HO, LE", "LF-8", null},
{"Feuerwehr", "HO, LE", "MTW", null},
{"Feuerwehr", "HO, LE", "LF-16 TS", null},
{"Feuerwehr", "ST, BO", "DLK-23/12", null},
{"Rettungsdienst", "ST, BO", "NEF", null},
{"Rettungsdienst", "ST, BF", "RTW", null}
},
new String [] {
"FW / RD", "FW + LZ", "Fahrzeug", "Funk-Status"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, true
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTable1.setRowHeight(23);
jScrollPane2.setViewportView(jTable1);
jTable1.getColumnModel().getColumn(0).setResizable(false);
jTable1.getColumnModel().getColumn(1).setResizable(false);
jTable1.getColumnModel().getColumn(2).setResizable(false);
jTable1.getColumnModel().getColumn(3).setResizable(false);
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText("Auswählen");
jRadioButton1.setName("");
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("Auswählen");
buttonGroup1.add(jRadioButton3);
jRadioButton3.setText("Auswählen");
buttonGroup1.add(jRadioButton4);
jRadioButton4.setText("Auswählen");
buttonGroup1.add(jRadioButton5);
jRadioButton5.setText("Auswählen");
buttonGroup1.add(jRadioButton6);
jRadioButton6.setText("Auswählen");
buttonGroup1.add(jRadioButton7);
jRadioButton7.setText("Auswählen");
buttonGroup1.add(jRadioButton8);
jRadioButton8.setText("Auswählen");
buttonGroup1.add(jRadioButton9);
jRadioButton9.setText("Auswählen");
buttonGroup1.add(jRadioButton10);
jRadioButton10.setText("Auswählen");
buttonGroup1.add(jRadioButton11);
jRadioButton11.setText("Auswählen");
buttonGroup1.add(jRadioButton12);
jRadioButton12.setText("Auswählen");
jLabel2.setText("Stichwort");
jLabel3.setText("Ort");
jLabel4.setText("Beschreibung");
jButton1.setText("Alarmieren!");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jCheckBox1.setText("Sonderrechte");
jLabel5.setText("©17.04.2012 Leonard Bienbeck");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 763, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRadioButton2)
.addComponent(jRadioButton1)
.addComponent(jRadioButton3)
.addComponent(jRadioButton4)
.addComponent(jRadioButton5)
.addComponent(jRadioButton6)
.addComponent(jRadioButton7)
.addComponent(jRadioButton8)
.addComponent(jRadioButton9)
.addComponent(jRadioButton10)
.addComponent(jRadioButton11)
.addComponent(jRadioButton12)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(184, 184, 184)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(11, 11, 11))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField2)
.addComponent(jTextField1)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1)
.addGap(18, 18, 18)
.addComponent(jButton1))))
.addComponent(jLabel1))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jRadioButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jRadioButton11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton12))
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 306, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel5)))
.addContainerGap())
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(evt.getSource() == jButton1){
ServerSocket server = null;
try {
server = new ServerSocket(8112);
} catch (IOException ex) { Logger.getLogger(guiLeitstelle.class.getName()).log(Level.SEVERE, null, ex); }
while(true){
Socket client = null;
try{
client = server.accept();
Scanner in = new Scanner(client.getInputStream());
PrintWriter out = new PrintWriter(client.getOutputStream(), true);
//Alarm-Daten
String _stw = jTextField1.getText();
String _ort = jTextField2.getText();
String _bes = jTextField3.getText();
//RADIO BUTTIN No1 (ELW HO-HO)
if(jRadioButton1.isSelected()){
if(in.nextLine() == "jRadioButton1"){
if(jCheckBox1.isSelected()){
new sendAlarmMessage(_stw, _ort, _bes, "Ja", in, out);
} else {
new sendAlarmMessage(_stw, _ort, _bes, "Nein", in, out);
}
break;
}
}
//RADIO BUTTIN No2 (LF-20/16 HO-HO)
if(jRadioButton2.isSelected()){
if(in.nextLine() == "jRadioButton2"){
}
}
//RADIO BUTTIN No3 (LF-16 TS HO-HO)
if(jRadioButton3.isSelected()){
if(in.nextLine() == "jRadioButton3"){
}
}
//RADIO BUTTIN No4 (GW-L HO-HO)
if(jRadioButton4.isSelected()){
if(in.nextLine() == "jRadioButton4"){
}
}
//RADIO BUTTIN No5 (MTW HO-HO)
if(jRadioButton5.isSelected()){
if(in.nextLine() == "jRadioButton5"){
}
}
//RADIO BUTTIN No6 (TLF-16/25 HO-LE)
if(jRadioButton6.isSelected()){
if(in.nextLine() == "jRadioButton6"){
}
}
//RADIO BUTTIN No7 (LF-8 HO-LE)
if(jRadioButton7.isSelected()){
if(in.nextLine() == "jRadioButton7"){
}
}
//RADIO BUTTIN No8 (MTW HO-LE)
if(jRadioButton8.isSelected()){
if(in.nextLine() == "jRadioButton8"){
}
}
//RADIO BUTTIN No9 (LF-16 TS HO-LE)
if(jRadioButton9.isSelected()){
if(in.nextLine() == "jRadioButton9"){
}
}
//RADIO BUTTIN No10 (DLK-23/12 ST-BO)
if(jRadioButton10.isSelected()){
if(in.nextLine() == "jRadioButton10"){
}
}
//RADIO BUTTIN No11 (NEF ST-BO)
if(jRadioButton11.isSelected()){
if(in.nextLine() == "jRadioButton11"){
}
}
//RADIO BUTTIN No12 (RTW ST-BF)
if(jRadioButton12.isSelected()){
if(in.nextLine() == "jRadioButton12"){
}
}
} catch (IOException e){ e.printStackTrace(); }
finally { if(client != null) { try { client.close();} catch (IOException e){ e.printStackTrace();} } }
break;
}}
}
/**
* @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(guiLeitstelle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(guiLeitstelle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(guiLeitstelle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(guiLeitstelle.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 guiLeitstelle().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JCheckBox jCheckBox1;
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.JList jList1;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton10;
private javax.swing.JRadioButton jRadioButton11;
private javax.swing.JRadioButton jRadioButton12;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton jRadioButton4;
private javax.swing.JRadioButton jRadioButton5;
private javax.swing.JRadioButton jRadioButton6;
private javax.swing.JRadioButton jRadioButton7;
private javax.swing.JRadioButton jRadioButton8;
private javax.swing.JRadioButton jRadioButton9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration
}