Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

build a program

  Asked By: Magenta    Date: Sep 22    Category: Java    Views: 620
  

am trying to build a program which allows
students to build their schedual. Once they have completed the
questions on the first page, they can move on to the next one
[classlist.java] by clicking the create sched button. This is
exactly where i block !! I have no idea how to call my next
application !!
-----------------------------------------------------------
//GUInterface.java

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

public class GUInterface extends Applet implements ItemListener
{
Panel firstRow = new Panel();
Panel secondRow = new Panel();
Panel thirdRow = new Panel();
Panel fourthRow = new Panel();
Panel fifthRow = new Panel();
Panel buttonRow = new Panel();
Label companyName = new Label("Enter Your Company
Here",Label.CENTER);
Label studentID = new Label("Enter Your Student ID: ");
TextField studentField = new TextField(10);
Label lblSemester = new Label("Which Semester are you registering
for ?");
Choice semesterBox = new Choice();
Label numClasses = new Label("How many classes would you like to
register ?");
Choice classesNum = new Choice();
Button CreateButton = new Button("Create Schedual");
Button PreviousButton = new Button("Previous");
Button NextButton = new Button("Next");

public void init()
{
setBackground(Color.gray);
setLayout(new BorderLayout());
Panel requestPad = new Panel(new GridLayout(9,1));
FlowLayout rowSetup = new FlowLayout
(FlowLayout.LEFT,5,2);
CreateButton.addActionListener(new
SchedButtonHandler(this));
firstRow.add(companyName);
secondRow.add(studentID);
secondRow.add(studentField);
thirdRow.add(lblSemester);
thirdRow.add(semesterBox);
semesterBox.add("Winter");
semesterBox.add("Fall");
fourthRow.add(numClasses);
fourthRow.add(classesNum);
classesNum.add("1");
classesNum.add("2");
classesNum.add("3");
classesNum.add("4");
classesNum.add("5");
classesNum.add("6");
fifthRow.add(CreateButton);
buttonRow.add(PreviousButton);
buttonRow.add(NextButton);

requestPad.add(firstRow);
requestPad.add(secondRow);
requestPad.add(thirdRow);
requestPad.add(fourthRow);
requestPad.add(fifthRow);
requestPad.add(buttonRow);
add(requestPad);


}
public void itemStateChanged(ItemEvent choice)
{
}

class SchedButtonHandler implements ActionListener
{
Applet applet;
public SchedButtonHandler(Applet a)
{
applet = a;
}

public void actionPerformed (ActionEvent e)
{
applet.showStatus("You Pressed: " +
e.paramString());

}
}
}
-----------------------------------------------------------
This is the second code which I would like to be inter-
related by the create sched button ! :) ClassList.java
-----------------------------------------------------------
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ClassList extends Applet implements ActionListener
{
private List classLst, copyLst;
private Button copy, remove;
private String classNames[] =
{
"COEN 311", "COEN 312", "COEN 243",
"COEN 417", "ELEC 311"
};

public void init()
{
classLst = new List(5, false);

for( int i = 0; i < classNames.length; i++)
classLst.add( classNames[i] );

add(classLst);

copy = new Button("Copy >>>");
copy.addActionListener(this);
add(copy);

remove = new Button("Remove <<<");
remove.addActionListener(this);
add(remove);

copyLst = new List(5, false);
add(copyLst);
}

public void actionPerformed( ActionEvent e )
{
if( e.getSource() == copy )
{
String copyCls[];

copyCls = classLst.getSelectedItems();

for( int i = 0; i < copyCls.length; i++)
copyLst.add(copyCls[i]);
}
else if( e.getSource() == remove )
{
String removeCls[];

removeCls = copyLst.getSelectedItems();

for( int i = 0; i < removeCls.length; i++)
removeCls[i].setVisible(false);
}

}
}

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Gerald Cruz     Answered On: Sep 22

Revise the method actionPerformed like:

public void  actionPerformed (ActionEvent e){
applet.showStatus("You Pressed: " + e.paramString());
String actionCommand = e.getActionCommand();
if (actionCommand.equals("ClassList")){
ClassList classList = new ClassList();
classList.init();
removeAll();
add(classList);
setVisible(true);
}
}

 
Didn't find what you were looking for? Find more on build a program Or get search suggestion and latest updates.




Tagged: