History source code

//History.java
//Michael E. Shultz
//Java Programming
//J374 #3

import java.applet.*;
import java.awt.*;

class History extends Applet
{
//GUI elements
CardLayout cardlayout = new CardLayout();
Panel myCards = new Panel();

//Init method
public void init()
{
//Adding the north panel to hold the title
Panel TitlePanel = new Panel();
TitlePanel = SetTitlePanel(TitlePanel);
add("North",TitlePanel);
//Setting up the cards
Panel Agrade = new Panel();
Agrade = SetAgrade(Agrade);
Panel Bgrade = new Panel();
Bgrade = SetBgrade(Bgrade);
Panel Cgrade = new Panel();
Cgrade = SetCgrade(Cgrade);
Panel Dgrade = new Panel();
Dgrade = SetDgrade(Dgrade);
//Putting all the panels together to make the "deck"
MakeDeck(Agrade,Bgrade,Cgrade,Dgrade);
//Adding the south panel to hold the movement buttons
Panel ButtonPanel = new Panel();
ButtonPanel = SetButtonPanel(ButtonPanel);
add("South",ButtonPanel);
}

//Action method
public boolean action (Event thisEvent, Object arg)
{
//Testing action events and triggering the right response

//Moving between cards?
if (("A".equals(arg) ) || ("First".equals(arg) ))
//Clicked A or First?
{
cardlayout.first(myCards);
return true;
}
else if ("B".equals(arg) ) //Clicked B?
{
cardlayout.show(myCards, (String)arg);
return true;
}
else if ("C".equals(arg) ) //Clicked C?
{
cardlayout.show(myCards, (String)arg);
return true;
}
else if (("D".equals(arg) ) || ("Last".equals(arg) ))
//Clicked D or Last?
{
cardlayout.last(myCards);
return true;
}

return false;
}

//Panel creation methods: SetAgrade, SetBgrade,
//SetCgrade, SetDgrade, MakeDeck
public Panel SetAgrade(Panel p)
{
//Creating the Agrade Panel
p.setLayout(new GridLayout(1,1) );
TextArea Areq = new TextArea(5,50);
p.add(Areq);
Areq.setText("30 page research paper" + "\n");
Areq.appendText("10 minute oral presentation" +"\n");
Areq.appendText("Web page with 3 images and 10 links" + "\n");
Areq.appendText("Average grade of 87% or higher on all quizzes and tests" + "\n");
Areq.setEditable(false);
return p;
}

public Panel SetBgrade(Panel p)
{
//Creating the Bgrade Panel
p.setLayout(new GridLayout(1,1) );
TextArea Breq = new TextArea(5,50);
p.add(Breq);
Breq.setText("20 page research paper" + "\n");
Breq.appendText("5 minute oral presentation" +"\n");
Breq.appendText("Web page with 2 images and 8 links" +"\n");
Breq.appendText("Average grade of 77% to 86% on all quizzes and tests" +"\n");
Breq.setEditable(false);
return p;
}

public Panel SetCgrade(Panel p)
{
//Creating the Cgrade Panel
p.setLayout(new GridLayout(1,1) );
TextArea Creq = new TextArea(5,50);
p.add(Creq);
Creq.setText("15 page research paper" + "\n");
Creq.appendText("No oral presentation" + "\n");
Creq.appendText("Web page with 1 image and 5 links" + "\n");
Creq.appendText("Average grade of 67% to 76% on all quizzes and tests" + "\n");
return p;
}

public Panel SetDgrade(Panel p)
{
//Creating the Dgrade Panel
p.setLayout(new GridLayout(1,1) );
TextArea Dreq = new TextArea(5,50);
p.add(Dreq);
Dreq.setText("10 page research paper" + "\n");
Dreq.appendText("No oral presentation" + "\n");
Dreq.appendText("Web page with 7 links" + "\n");
Dreq.appendText("Average grade of 57% to 66% on all quizzes and tests" + "\n");
Dreq.setEditable(false);
return p;
}

public void MakeDeck(Panel p1, Panel p2, Panel p3, Panel p4)
{
myCards.setLayout(cardlayout);
myCards.add("A", p1);
myCards.add("B", p2);
myCards.add("C", p3);
myCards.add("D", p4);
add("Center", myCards);
}

public Panel SetButtonPanel(Panel p)
{
//Creating the South buttons panel to access the cards
p.setLayout(new GridLayout(1,6) );
p.add(new Button ("First") );
p.add(new Button ("A") );
p.add(new Button ("B") );
p.add(new Button ("C") );
p.add(new Button ("D") );
p.add(new Button ("Last") );
return p;
}

public Panel SetTitlePanel(Panel p)
{
//Creating the North title panel
p.setLayout(new GridLayout(2,1) );
p.add(new Label("History of Technology") );
p.add(new Label("Grade Requirements") );
return p;
}
}

Back to History

Top

© Copyright 2001 by Michael E. Shultz, All rights reserved