TheButcher
Programmer
need help! I'm having problems with ActionListener. I don't know how to have mulitiple action listeners in the same program. This is probably very easy to do but I'm fairly new to java (only new C before this program).
here is my program so far:
1) click on the applet and will create a numbered vertice
2) seperate frame has 3 text fields...vertice1, vertice2, weight.
3) click buton to create an edge between vertices with associated weight.
code snippets:
Button addEdge; //before init() section
addEdge = new Button("Add Edge" //within init()
addEdge.addActionListener(this); //within init()
public void paint
{
code here makes vertices
}
public void actionPerformed (ActionEvent event)
{
code here reads in #'s from text fields & connects graph
}
now here is the problem. I need to make another button that will traverse the edges when clicked. Unfortunately, all the examples in my java book only deals with using one action listener. It says action listener must be implemented and have to use this function that is automatically called. Can I still write another one using action listener?
Many Thanks, Butch
here is my program so far:
1) click on the applet and will create a numbered vertice
2) seperate frame has 3 text fields...vertice1, vertice2, weight.
3) click buton to create an edge between vertices with associated weight.
code snippets:
Button addEdge; //before init() section
addEdge = new Button("Add Edge" //within init()
addEdge.addActionListener(this); //within init()
public void paint
{
code here makes vertices
}
public void actionPerformed (ActionEvent event)
{
code here reads in #'s from text fields & connects graph
}
now here is the problem. I need to make another button that will traverse the edges when clicked. Unfortunately, all the examples in my java book only deals with using one action listener. It says action listener must be implemented and have to use this function that is automatically called. Can I still write another one using action listener?
Many Thanks, Butch