import java.awt.*; import javax.swing.*; import java.util.Random; /** * Class aforisme - write a description of the class here * * @author (Eugeni Alonso) * @version (0.1) */ public class aforisme extends JApplet { // variables d'instància- reemplaceu el següent exemple per les // vostres variables en aquest cas els aforismes amb què "jugareu" private int x; private String[] frases = { "Cal no oblidar que tota política que no fem nosaltres "+ "serà feta contra nosaltres", "La decisió cristiana de trobar el món lleig i dolent, "+ "ha fet lleig i dolent em món.Nietzsche", "Si en aquest món hi ha una cosa intrínsecament dolenta "+ "és, sens dubte, l'Estat", "El millor govern, quin pot ser? Aquell que ens ensenya "+ "a governar-nos nosaltres mateixos", "Ningú no crida més reclamant la llibertat de premsa "+ "que aquell qui vol abusar-ne", "No hi ha res més monstruós que una ignorància activa", "El qui actua no té mai consciència; només en té el "+ "qui medita", "L´amor a la veritat es mostra sabent trobar i apreciar "+ "la bondat a tot arreu", "Els aforismes –els meus com els de tothom- són "+ "sempre falsos, intrinsecament falsos. I aquest també", "Alguns no arriben a pensadors perquè tenen massa bona "+ "memoria. Nietzsche", "Forma part d’una bona educació saber en quantes "+ "ocasions cal ser maleducat", "De tota manera, és aconsellable que "+ "envelleixis simultaniament amb el teu cos" }; /** * Called by the browser or applet viewer to inform this JApplet that it * has been loaded into the system. It is always called before the first * time that the start method is called. */ public void init() { // this is a workaround for a security conflict with some browsers // including some versions of Netscape & Internet Explorer which do // not allow access to the AWT system event queue which JApplets do // on startup to check access. May not be necessary with your browser. JRootPane rootPane = this.getRootPane(); rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); // provide any initialisation necessary for your JApplet } /** * Called by the browser or applet viewer to inform this JApplet that it * should start its execution. It is called after the init method and * each time the JApplet is revisited in a Web page. */ public void start() { // provide any code requred to run each time // web page is visited } /** * Called by the browser or applet viewer to inform this JApplet that * it should stop its execution. It is called when the Web page that * contains this JApplet has been replaced by another page, and also * just before the JApplet is to be destroyed. */ public void stop() { // provide any code that needs to be run when page // is replaced by another page or before JApplet is destroyed } /** * Paint method for applet. * * @param g the Graphics object for this applet */ public void paint(Graphics g) { // simple text displayed on applet g.setColor(Color.white); g.fillRect(0, 0, 200, 100); g.setColor(Color.black); g.setColor(Color.blue); Random rand = new Random(); int n = 11; int i = rand.nextInt(n+1); g.drawString( frases[i],25,20 ) ; } /** * Called by the browser or applet viewer to inform this JApplet that it * is being reclaimed and that it should destroy any resources that it * has allocated. The stop method will always be called before destroy. */ public void destroy() { // provide code to be run when JApplet is about to be destroyed. } /** * Returns information about this applet. * An applet should override this method to return a String containing * information about the author, version, and copyright of the JApplet. * * @return a String representation of information about this JApplet */ public String getAppletInfo() { // provide information about the applet return "Title: \nAuthor: \nA simple applet example description. "; } /** * Returns parameter information about this JApplet. * Returns information about the parameters than are understood by this JApplet. * An applet should override this method to return an array of Strings * describing these parameters. * Each element of the array should be a set of three Strings containing * the name, the type, and a description. * * @return a String[] representation of parameter information about this JApplet */ public String[][] getParameterInfo() { // provide parameter information about the applet String paramInfo[][] = { {"firstParameter", "1-10", "description of first parameter"}, {"status", "boolean", "description of second parameter"}, {"images", "url", "description of third parameter"} }; return paramInfo; } }