import java.awt.*;

public class more extends Frame
{
    Image nPic, nPic2;
    Component parent;
    String nName, nCom, nName2, nCom2;
    int test=0;

    public more(Component par, String newPicName, Image newPic, String NewPicCom, String newPicName2, Image newPic2, String NewPicCom2)
    {
        parent = par;
        nName = newPicName;
        nPic = newPic;
        nCom = NewPicCom;
        nName2 = newPicName2;
        nPic2 = newPic2;
        nCom2 = NewPicCom2;
    }

    public void paint(Graphics g)
    {
        int partCounter=0;
        int partCounter2=0;
        String[] part, part2;
        String endText ="";
        String endText2 ="";

        MediaTracker Tracker = new MediaTracker(this);
        if (nName == null);
        else
        {
            Tracker.addImage(nPic, 0);
        }
        if (nName2 == null);
        else
        {
            Tracker.addImage(nPic2, 1);
        }

        try
        {
            Tracker.waitForAll();
        }
        catch(InterruptedException e)
        {
            return;
        }

        if (nName == null);
        else
        {
            g.drawImage(nPic, 15, 0, this);
        }
        if (nName2 == null);
        else
        {
            g.drawImage(nPic2, 215, 0, this);
        }
        Panel p = new Panel();
        p.add(new Button("Close"));
        add("South",p);


        if (test == 0)
        {
            if(nCom == null);
            else                //Look at window.java for explanation.
            {
                int ComLeng = nCom.length();
                String akut = nCom;
                if (ComLeng > 28)
                {
                    int parts = (ComLeng / 28);
                    part = new String[parts];
                    for (int ph = 0; ph < parts; ph++)
                    {
                        for (int pp = 27; pp > -1;pp--)
                        {
                            if (akut.length()>27)
                            {
                                char te[] = new char[1];
                                te[0] = akut.charAt(pp);
                                String pos_str = new String(te);
                                if( pos_str.equals(" "))
                                {
                                    part[ph] = akut.substring(0 , pp);
                                    String temp = akut.substring(pp+1);
                                    akut = temp;
                                    pp=-1;
                                    partCounter++;
                                }
                            }
                        }
                    }

                    TextArea PictureCom = new TextArea(30, 5);
                    for (int c=0; c < partCounter; c++)
                    {
                        endText = endText + part[c] + '\n';
                    }
                    PictureCom.setText(endText + akut);
                    PictureCom.setEditable(false);
                    add(PictureCom);
                    PictureCom.reshape(0,165,165,115);


                }

                else
                {
                    TextArea PictureCom = new TextArea(30, 5);
                    PictureCom.setText(nCom);
                    PictureCom.setEditable(false);
                    add(PictureCom);
                    PictureCom.reshape(0,165,165,115);
                }



            }

            if (nCom2 == null);
        else
        {
            int ComLeng2 = nCom2.length();
            String akut2 = nCom2;
            if (ComLeng2 > 28)
            {
                int parts2 = (ComLeng2 / 28);
                part2 = new String[parts2];
                for (int ph2 = 0; ph2 < parts2; ph2++)
                {
                    for (int pp2 = 27; pp2 > -1;pp2--)
                    {
                        if (akut2.length()>27)
                        {
                            char te2[] = new char[1];
                            te2[0] = akut2.charAt(pp2);
                            String pos_str2 = new String(te2);
                            if( pos_str2.equals(" "))
                            {
                                part2[ph2] = akut2.substring(0 , pp2);
                                String temp2 = akut2.substring(pp2+1);
                                akut2 = temp2;
                                pp2=-1;
                                partCounter2++;
                            }
                        }
                    }
                }


                TextArea Com = new TextArea(30, 5);
                for (int c2=0; c2 < partCounter2; c2++)
                {
                    endText2 = endText2 + part2[c2] + '\n';
                }
                Com.setText(endText2 + akut2);
                Com.setEditable(false);
                add(Com);
                Com.reshape(200,165,165,115);
            }
            else
            {
                TextArea Com = new TextArea(30, 5);
                Com.setText(nCom2);
                Com.setEditable(false);
                add(Com);
                Com.reshape(200,165,165,115);
            }
        }
        test++;

        }
        show();
    }




    public boolean handleEvent(Event event)
    {

    	if (event.id == Event.WINDOW_DESTROY)
    	{
            hide();       // hide the Frame
            dispose();    // telling System to free resources
            return true;
    	}
    	return super.handleEvent(event);
    }

    public boolean action(Event event, Object arg)
    {
        if (arg.equals("Close"))
        {
            hide();
            dispose();
            return true;
        }
        return super.action(event, arg);
    }

    public void show()
    {
        super.show();
        parent.disable();
    }

    public void hide()
    {
        super.hide();
        parent.enable();
    }


}
