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
|
public class Planning extends JApplet implements ActionListener, MouseListener, MouseMotionListener
{
private static final long serialVersionUID = 160819700001L;
public void update(Graphics g) {
super.paint(g);
}
public void paintComponent(Graphics g)
{
super.paintComponents(g);
}
public class MyButton extends JButton
{
public String date;
public String time;
public String path;
public MyButton()
{
super();
repaint();
}
public void update(Graphics g)
{
super.paint(g);
super.repaint();
}
};
public void paint(Graphics g) {
super.paint(g);
Toolkit.getDefaultToolkit().sync();
}
MyButton cases[];
public void init()
{
String color = getParameter("color");
String names = getParameter("names");
...
this.setLayout(new BorderLayout());
this.setSize(new Dimension(700,500));
JPanel upper_panel = new JPanel();
this.add(upper_panel,"North");
...
JButton refresh_button;
refresh_button = new JButton();
refresh_button.setText("Redessiner");
JPanel bottom_panel = new JPanel();
this.add(bottom_panel,"South");
refresh_button.setEnabled(true);
refresh_button.addMouseListener(this);
bottom_panel.add(refresh_button, "center");
Panel central_panel = new Panel();
central_panel.setLayout(new GridLayout(15, 8));
this.add(central_panel, "Center");
Font policeTime = new Font("Calibri", Font.PLAIN, 15);
cases = new MyButton[120];
days = new String[7];
days_tmp = new String[7];
days[0] = "Lundi"; days[1] = "Mardi"; days[2] = "Mercredi"; days[3] = "Jeudi"; days[4] = "Vendredi";
days[5] = "Samedi"; days[6] = "Dimanche";
...
for(i = 0; i < 120; i++)
{
cases[i]= new MyButton();
cases[i].setForeground(Color.blue);
tooltip = ""+i;
cases[i].setToolTipText(tooltip);
if (i<8)
{
if (i==0)
{
cases[i].setBackground(upper_panel.getBackground());
}
else
{
cases[i].setLayout(new BorderLayout());
JLabel label1 = new JLabel(days[i-1]);
label1.setFont(policeApplet12);
JLabel label2 = new JLabel(dates[i-1]);
label2.setFont(policeApplet12);
cases[i].add(BorderLayout.NORTH, label1);
cases[i].add(BorderLayout.SOUTH, label2);
cases[i].setToolTipText("MonTexte");
}
cases[i].canBeColored = false;
}
else
{
cases[i].setBackground(mycolor_libre);
cases[i].canBeColored = true;
}
cases[i].addActionListener(this);
cases[i].addMouseListener(this);
cases[i].addMouseListener(this);
cases[i].addMouseListener(new MouseAdapter(){public void mousePressed(MouseEvent me){}});
cases[i].addMouseMotionListener(new MouseAdapter(){public void mouseMovedRL(MouseEvent me){}});
central_panel.add(cases[i]);
cases[i].setEnabled(true);
}
j = 0;
for(i = 8; i <= 112; i = i + 8)
{
cases[i].setFont(policeTime); cases[i].setBackground(mycolor_hours);
cases[i].setForeground(mycolor_white); cases[i].setText(mytime[j].exttime);
cases[i].canBeColored = false;
cases[i].setToolTipText(mytime[j].exttime);
j = j + 1;
}
int[] tab_cases = {9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44,
45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 81,
82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 97, 98, 99, 100, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 113, 114,
115, 116, 117, 118, 119};
j = 0; k = 0; current_time = mytime[0].stime;
for(i = 0; i < 98; i++)
{
if (color.substring(i,i+1).equals("1"))
{
cases[tab_cases[i]].isReserved = true;
cases[tab_cases[i]].setBackground(my_reserved_color);
cases[tab_cases[i]].setFont(policePlayers);
cases[tab_cases[i]].setLayout(new BorderLayout(0,0));
setFont(new Font("Helvetica",Font.PLAIN,30));
String[] players_name = null;
cases[tab_cases[i]].add(BorderLayout.NORTH, "OK");
cases[tab_cases[i]].add(BorderLayout.SOUTH, "HELLO");
cases[tab_cases[i]].setToolTipText("<html>" + players_name[0] + "<br>" + name[1] + "</html>");
cases[tab_cases[i]].setHorizontalAlignment(AbstractButton.LEFT);
cases[tab_cases[i]].setMargin(new Insets(0,0,0,0));
}
}
}
public void start(){
}
public void stop(){
}
/* public void paint(java.awt.Graphics contexteGraphique)
{
contexteGraphique.drawString("Bonjour Monde !", 200, 300);
}
*/
public void UpdateButtons()
{
for(i = 0; i < 120; i++)
{
cases[i].repaint();
}
}
public void actionPerformed(ActionEvent event)
{
super.repaint();
}
public void mousePressed(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
if (!e.getSource().getClass().getName().equals("javax.swing.JButton"))
{
MyButton leBouton = (MyButton) e.getSource();
if (leBouton.canBeColored)
{
if (!leBouton.isReserved)
leBouton.setBackground(mycolor_yellow);
}
}
else
UpdateButtons();
}
public void mouseExited(MouseEvent e)
{
if (!e.getSource().getClass().getName().equals("javax.swing.JButton"))
{
MyButton leBouton = (MyButton) e.getSource();
if (leBouton.canBeColored)
{
if (!leBouton.isReserved)
leBouton.setBackground(mycolor_libre);
}
}
else
UpdateButtons();
}
public Planning() {
super();
repaint();
}
} |