1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
import java.awt.*;
import java.io.BufferedReader;
import java.io.FileReader;
import javax.swing.*;
import javax.swing.table.*;
import java .lang.Object;
import java.util. StringTokenizer;
public class Soft extends JFrame
{
JPanel PP;
Soft()
{
super("les services:");
System.out.println("eeeeeeeeee");
setSize(400,400);
PP =new JPanel();
PP.setLayout(new BorderLayout());
System.out.println("eeeeeeeeee");
add(PP);
}
public void tableau()
{
String[][] donnees=new String[0][0];
try
{
String[] cols = {"nom_service", "etat"};
DefaultTableModel model = new DefaultTableModel(donnees,cols);
JTable tab = new JTable(model);
tab.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
tab.getTableHeader().setFont(new Font("Arial", Font.CENTER_BASELINE,13));
tab.getColumnModel().getColumn(0).setPreferredWidth(100);
tab.getColumnModel().getColumn(1).setPreferredWidth(100);
//tab.setVisible(true);
// getContentPane().add(new JScrollPane(tableau), BorderLayout.CENTER);
tab.updateUI();
JScrollPane sp = new JScrollPane(tab);
PP.add(sp);
PP.setVisible(true);
PP.updateUI();
tab.updateUI();
this.setVisible(true);
//pack();
String ligne="",chaine="";
StringTokenizer st;
String m,n,e,j,t;
BufferedReader fin=new BufferedReader(new FileReader("log2.txt"));
while((ligne=fin.readLine())!=null)
{
st=new StringTokenizer(ligne,",.;: ");
while(st.hasMoreTokens())
{ String motA=st.nextToken();//motA contient[1265.....]
String mott=st.nextToken();//mott contient CURRENT
String mot=st.nextToken();//mot contient soit HOST soit SERVICE
String mot=st.nextToken();
if(mot.equals("HOST"))
{ System.out.println(ligne);
ligne +=ligne +"\n";
}
if (mot.equals("SERVICE"))
{
m= st.nextToken();//m contient STAT
n=st.nextToken();//n contient le nom du host
e=st.nextToken();//e contient le nom du service
j=st.nextToken();// j contient l'etat du service
t=st.nextToken();// t contient soit hard soit soft
if (t.equals("soft"))
{ Object[] h=new Object[]{e,j};
model.insertRow(tab.getRowCount(),h);
}
}
}
}
fin.close();
}
catch(Exception f)
{
System.out.println(f.getMessage());
}
}
public static void main(String []args)
{
Soft f=new Soft();
f.tableau();
f.setVisible(true);
f. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} |
Partager