
-----------------------------------
Flashkicks
Wed Jun 02, 2004 8:37 am

About the graphics; In Applets
-----------------------------------
Hi!  This is kinda like an add-On to the original post about graphisc..  I have werked around with it some and came across this problem- i can load up the pic; but NOT in an applet..   Here is my applet and wutnot- could you or anybody please take a look at it and see what is going on??..  I think it has to do something about the toolkit thingy..  Bcuz if i comment it out- my proggy crashes and then I cant type anything in it. So i assume the toolkit is NEEDED..  PLEASE HELP...
// The "CosineLaw" class.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.*;

public class CosineLaw121 extends Applet implements MouseListener
{
    int choice = 0;

    //delay method
    public static void delay (int milliseconds)
    {
        try
        {
            Thread.sleep (milliseconds);
        }


        catch (InterruptedException e)
        {
        }
    }


    public void init ()
    {
        setSize (640, 400);
        setBackground (new Color (0, 0, 0));
        addMouseListener (this);

        JFrame frame = new JFrame ();
        MyPanel panel = new MyPanel ("triangles.jpg");

        frame.setContentPane (panel);
        frame.setDefaultCloseOperation (3);
        frame.setBounds (new Rectangle (500, 500));
        frame.setVisible (true);

        panel.repaint ();
    }


    public void paint (Graphics g)
    {
        if (choice == 0)
        {
            int i;
            for (i = 0 ; i < 25 ; i++)
            {
                g.setColor (Color.black);
                g.fillRect (0, 0, 1000, 1000);
                g.setFont (new Font ("Ravie", 3, 20));
                g.setColor (Color.red);
                g.drawString ("Question One", 230, 0 + i);
            }

            delay (300);
            g.setFont (new Font ("Times New Roman", 3, 15));
            g.drawString ("These diagrams represent 3 problems.  A strategy for each problem", 160, 40);
            g.drawString ("is listed, but not in the correct order.", 160, 60);
            g.drawString ("  1) Match each diagram to a strategy.  Explain your reasoning.", 160, 80);
            g.drawString ("  2) Apply each strategy to the matched diagram. (Calculate)", 160, 100);
            delay (1000);

            g.setFont (new Font ("Times New Roman", 3, 12));
            g.setColor (Color.red);
            g.drawString ("a)Notice that the", 100, 310);
            g.drawString ("triangle has a right", 100, 320);
            g.drawString ("angle.  Use either", 100, 330);
            g.drawString ("the sine or cosine", 100, 340);
            g.drawString ("ratio.", 100, 350);

            g.drawString ("b)Use the sine rule", 250, 310);
            g.drawString ("with 2 angles and ", 250, 320);
            g.drawString ("there opposite sides.", 250, 330);
            g.drawString ("Solve the resulting", 250, 340);
            g.drawString ("equation for the unknown.", 250, 350);

            g.drawString ("c)Use the cosine rule", 400, 310);
            g.drawString ("with 1 angle and 2 sides", 400, 320);
            g.drawString ("to find the remaining", 400, 330);
            g.drawString ("sides.", 400, 340);


            g.setColor (Color.white);
            g.fillRect (305, 360, 50, 20);
            g.setColor (Color.black);
            g.drawString ("NEXT", 310, 373);
        }
        else if (choice == 1)
        {
            int i;
            for (i = 0 ; i < 50 ; i++)
            {
                g.setColor (Color.black);
                g.fillRect (0, 0, 1000, 1000);
                g.setFont (new Font ("Ravie", 3, 20));
                g.setColor (Color.red);
                g.drawString ("Example", 230, 0 + i);
            }

            //triangle image
            g.setColor (Color.red);
            delay (100);
            g.drawLine (150, 250, 300, 250);
            delay (100);
            g.drawLine (150, 250, 120, 100);
            delay (100);
            g.drawLine (120, 100, 300, 250);
            delay (100);
            g.setFont (new Font ("Times New Roman", 3, 15));
            g.setColor (Color.yellow);
            g.drawString ("A", 115, 95);
            delay (100);
            g.drawString ("B", 140, 265);
            delay (100);
            g.drawString ("C", 305, 255);
            delay (100);
            g.setColor (Color.orange);
            g.drawString ("a", 220, 265);
            delay (100);
            g.drawString ("b", 215, 170);
            delay (100);
            g.drawString ("c", 125, 180);
            delay (100);

            //question
            g.setColor (Color.red);
            g.drawString ("Find side 'a' to the nearest whole number", 100, 300);
            g.drawString ("Find angles B and C to the nearest degrees", 100, 320);
            delay (100);
            g.drawString ("A = 21 degrees", 100, 340);
            g.drawString ("b = 27", 100, 360);
            g.drawString ("c = 20", 100, 380);
            delay (100);
            g.drawString ("Try to solve it yourself", 100, 400);
            delay (100);
            g.drawString ("You can check your answer afterwards, just click the solution button", 100, 420);

            delay (700);

            //solution button
            g.setColor (Color.white);
            g.fillRect (450, 350, 100, 40);
            g.setColor (Color.black);
            g.drawRect (455, 355, 90, 30);
            g.drawString ("Solution", 475, 375);
        }
        else if (choice == 2)
        {
            int i;
            for (i = 0 ; i < 50 ; i++)
            {
                g.setColor (Color.black);
                g.fillRect (0, 0, 1000, 1000);
                g.setFont (new Font ("Ravie", 3, 20));
                g.setColor (Color.red);
                g.drawString ("Solution", 250, 0 + i);
            }

            g.setFont (new Font ("Times New Roman", 3, 10));
            g.drawString ("2           2           2", 110, 133);
            g.drawString ("2           2           2", 117, 211);

            g.setFont (new Font ("Times New Roman", 3, 15));
            g.drawString ("Answer:", 100, 100);
            delay (200);
            g.drawString ("b = 27     c = 20     