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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
| public class Appel extends JFrame implements ActionListener,MouseMotionListener,MouseListener
{
String choisi="";
JPanel c = new JPanel();
Panel p1;
MenuItem pc;
MenuItem routeur;
MenuItem switcheur;
Appel(String s)
{
super(s);
setSize(600,600);
MenuBar b= new MenuBar();
Menu n=new Menu("Nouveau");
Menu commande=new Menu("les commande");
pc=new MenuItem("pc");
routeur=new MenuItem("routeur");
switcheur=new MenuItem("switch");
n.add(pc);
n.add(routeur);
n.add(switcheur);
b.add(n);
setMenuBar(b);
c.setSize(400,400);
Panel p=new Panel();
Panel l=new Panel();
p.setLayout(new FlowLayout(FlowLayout.CENTER));
l.setLayout(new FlowLayout(FlowLayout.CENTER));
c.setLayout(new FlowLayout());
Button x=new Button("enregistrer le Map");
Button x1=new Button("ajouter un hostgroup");
Button x2=new Button("ajouter un contact");
Button x3=new Button("ajouter une commande");
Button x4=new Button("effacer une hote");
Button x6=new Button("service pour hostgroup");
Button x5=new Button("Demarrer");
p.add(x);
l.add(x1);
l.add(x2);
l.add(x3);
l.add(x6);
p.add(x5);
p.add(x4);
c.setBackground(Color.black);
p.setBackground(Color.black);
l.setBackground(Color.black);
x.setBackground(Color.magenta);
x1.setBackground(Color.magenta);
x2.setBackground(Color.magenta);
x3.setBackground(Color.magenta);
x4.setBackground(Color.magenta);
x5.setBackground(Color.magenta);
x6.setBackground(Color.magenta);
add(p,"South");
add(c,"Center");
add(l,"North");
//pack();
n.addActionListener(this);
x.addActionListener(this);
x1.addActionListener(this);
x2.addActionListener(this);
x3.addActionListener(this);
x4.addActionListener(this);
x5.addActionListener(this);
x6.addActionListener(this);
pc.addActionListener(this);
routeur.addActionListener(this);
switcheur.addActionListener(this);
c.addMouseListener(this);
c.addMouseMotionListener(this);
}
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseDragged(MouseEvent e){}
Button x3;
Button x1;
Button x2;
private int id=0;
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == pc)
{
try{
Thread iu=new Thread(new FrameA(id));
id++;
iu.start();
//c. add(iu);
}
catch(Exception ee){}
}
/* else
{if((Button)e.getSource() == x3)
{
Commandee u=new Commandee();
u.setVisible(true);
//c. add(iu);
}
else
{
if((Button)e.getSource() == x1)
{
Hostgroup u1=new Hostgroup ();
u1.setVisible(true);
}
else
{if((Button)e.getSource() == x1)
{
Contact u2=new Contact();
u2.setVisible(true);
//c. add(iu);
}
}
}
}*/
}
public void mouseMoved(MouseEvent e){}
public static void main(String args[])
{
Appel f=new Appel("Mon parc informatique");
f.setVisible(true);
}
}
public class FrameA extends JFrame implements Runnable {
private static final long serialVersionUID = 4983727800375272097L;
int g=0;
int id=0;
BufferedImage img = null;
public FrameA(int id) {
this.id=id;
System.out.println(id);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(800, 600);
setLocationRelativeTo(null);
}
public void run()
{
try {
img = ImageIO.read(new File("c:/pc.jpeg"));
} catch (IOException e) {
e.printStackTrace();
}
setContentPane(new MyCanvas(img));
setVisible(true);
}
public static void main(String[] args) {
new FrameA(9);
}
private class MyCanvas extends JComponent implements MouseListener {
private static final long serialVersionUID = 8845913940083986438L;
private BufferedImage buff = null;
private Raster data = null;
public MyCanvas(BufferedImage img) {
this.addMouseListener(this);
this.buff = img;
this.data = img.getData();
}
public void paintComponent(Graphics g) {
g.drawImage(buff, 0, 0, buff.getWidth(), buff.getHeight(), this);
}
private void testLocation(Point mouse, String text) {
if(data.getBounds().contains(mouse))
{
//Thread po=new Thread(new Interfacepc(id));
System.out.println("image"+id);
//po.start();
g++;
//po.setVisible(true);
}
}
public void mouseClicked(MouseEvent e) {
Point p = e.getPoint();
testLocation(p, "mouseClicked");
}
public void mousePressed(MouseEvent e) {
Point p = e.getPoint();
testLocation(p, "mousePressed");
}
public void mouseReleased(MouseEvent e) {
Point p = e.getPoint();
testLocation(p, "mouseReleased");
}
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
}
} |