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
| class frame extends JFrame{
public frame(){
setSize(800,800);
JLabel lab=new JLabel(new ImageIcon("c:\\icon.PNG"));
Image img=null;
JPanel panneau=new JPanel();
JPanel processeurPan=new JPanel();
JPanel commandePan =new JPanel();
JPanel processusPan =new JPanel();
commandePan.setLayout(new GridLayout(4,1));
JPanel processusinfo=new JPanel();
panneau.setLayout(new BorderLayout());
proPan ps=new proPan();
Vector vect=new Vector();
vect.addElement(ps);
JList liste=new JList();
Dimension min=new Dimension();
min.height=100;
min.width=400;
liste.setPreferredSize(min);
liste.setListData(vect);
liste.setLayoutOrientation(JList.HORIZONTAL_WRAP);
liste.setVisibleRowCount(1);
processusPan.setLayout(new FlowLayout());
processusPan.add(liste);
JPanel buttonPan =new JPanel();
JPanel reg1=new JPanel();
JPanel reg2=new JPanel();
button ajout=new button("ajouter processus");
button demarrer=new button("DEMARRER");
button stop=new button("STOP");
JLabel registre1=new JLabel("registre1");
JLabel registre2=new JLabel("registre2");
JLabel registre3=new JLabel("registre3");
JLabel registre4=new JLabel("registre4");
JLabel registre5=new JLabel("registre5");
JLabel registre6=new JLabel("registre6");
JTextField regt1=new JTextField(10);
JTextField regt2=new JTextField(10);
JTextField regt3=new JTextField(10);
JTextField regt4=new JTextField(10);
JTextField regt5=new JTextField(10);
JTextField regt6=new JTextField(10);
reg1.setLayout(new GridLayout(6,1));
reg2.setLayout(new GridLayout(6,1));
buttonPan.add(ajout);
buttonPan.add(demarrer);
buttonPan.add(stop);
reg1.add(registre1);
reg1.add(regt1);
reg1.add(registre2);
reg1.add(regt2);
reg1.add(registre3);
reg1.add(regt3);
reg2.add(registre4);
reg2.add(regt4);
reg2.add(registre5);
reg2.add(regt5);
reg2.add(registre6);
reg2.add(regt6);
commandePan.add(processusinfo);
commandePan.add(buttonPan);
processeurPan.add(reg1,BorderLayout.WEST);
processeurPan.add(reg2,BorderLayout.EAST);
panneau.add(processusPan,BorderLayout.NORTH);
panneau.add(processeurPan,BorderLayout.EAST);
panneau.add(commandePan,BorderLayout.SOUTH);
add(panneau);
}
class proPan extends JPanel{
public void paintComponent(Graphics g)
{
Image img=null;
try {
img = ImageIO.read(new File("c:\\icon.PNG"));
} catch (IOException ex) {
ex.printStackTrace();
}
Dimension d=new Dimension();
d.height=70;
d.width=70;
setPreferredSize(d);
Graphics2D g2=(Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
Graphics2D g2d = (Graphics2D)img.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setFont(new Font("Bold",Font.PLAIN,20));
g2d.setColor(Color.BLACK);
g2d.drawString("P1",25,40);
FontMetrics fontMetrics = g2d.getFontMetrics();
int longueur = fontMetrics.stringWidth("P1");
int hauteur = fontMetrics.getHeight();
g2.drawImage(img, 0, 0, 50, 50, this);
}
} |
Partager