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
|
package appletcalendar;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import com.toedter.calendar.JCalendar;
import java.net.URL;
import java.text.DateFormat;
import java.util.Date;
public class CalendarApplet extends JApplet implements ActionListener
{
private javax.swing.JButton jButton1;
private com.toedter.calendar.JCalendar jCalendar1;
/** Initializes the applet CalendarApplet */
@Override
public void init()
{
jCalendar1 = new com.toedter.calendar.JCalendar();
jCalendar1.setSize(new Dimension(50,50));
jButton1 = new javax.swing.JButton();
jButton1.setSize(new Dimension(50,50));
// Liens d'ecoute
jButton1.addActionListener(this);
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout());
contentPane.add(jCalendar1);
contentPane.add(jButton1);
this.setContentPane(contentPane);
}
// affichage
@Override
public void paint(Graphics g)
{
super.paint(g);
}
// methode qui reagit aux evenements
public void actionPerformed (ActionEvent e)
{
repaint();
}
public void aller_au_jour()
{
try
{
/*Date date = this.jCalendar1.getDate();
this.getAppletContext().showDocument(new URL("www.google.fr"));*/
this.jCalendar1.setDate(new Date());
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
} |
Partager