Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: Applet

Tuesday, September 10, 2013

Applet

This Java code simply display a "Quote" on the Applet. Here is the snapshot.
 

import java.awt.*;
import java.applet.*;
/*
<applet code="AppletQuote" width=900 height=80>
</applet>
*/
public class AppletQuote extends Applet
    {
    public void init()
        {
        setBackground(Color.cyan);
        }
    public void paint(Graphics g)
        {
        Quotes qts = new Quotes();
            int n = (int)(Math.random()*10);
              g.drawString(qts.getQuote(n),30,30);   
            }
        }
class Quotes
    {
    Quotes()
        {
        }
    public String getQuote(int n)
        {
        return (quotes[n]);
        }
    private static String quotes[]={"I like mathematics because it is not human and has nothing particular to do with this planet or with the whole accidental universe                         - because like Spinoza's God, it won't love us in return.  ~Bertrand Russell",
                    "If there is a God, he's a great mathematician.  ~Paul Dirac",
                    "Do not worry about your problems with mathematics, I assure you mine are far greater. ~Albert Einstein",
                    "There are things which seem incredible to most men who have not studied mathematics. ~ Aristotle",
                    "Mathematics is a game played according to certain simple rules with meaningless marks on paper. ~ David Hilbert",
                    "Go down deep enough into anything and you will find mathematics~ Dean Schlicter",
                    " Life is good for only two things, discovering mathematics and teaching mathematics. ~ Simeon Poisson",
                    "In mathematics you don't understand things. You just get used to them. ~ Johann von Neumann",
                    " Medicine makes people ill, mathematics make them sad and theology makes them sinful. ~ Martin Luther",
                    "A man whose mind has gone astray should study mathematics. ~ Francis Bacon"};
    }

No comments:

Post a Comment