-> hi
-> i have a client server program.. i am sending data variable
-> 'msgFromClient' through PrintWriter object as follwoing
-> pwOut.println(msgFromClient);
-> in the program.. i am reading 'msgFromClient' from the following two
-> functions. Now i want to trigger the above statement only when user
has
-> given his input through one of the following fucntions. i can
trigger
-> directly by keeping the statement in both the function. but my
-> statement is outside the both functions and now i want to trigger
the
-> statment only when input is given by user ( ie. when user clicks one
of-
-> the 2 buttons)
-> Please help me out to solve this situation
-> private payoff_oneActionPerformed(ActionEvent ae) {
-> msgFromClient = payoff_one.getText();
-> payoff_one.setEnabled(false);
-> payoff_two.setEnabled(false);
-> game_status.setText("Please wait for your Opponent to Choose");
-> }
-> private payoff_twoActionPerformed(ActionEvent ae) {
-> msgFromClient = payoff_two.getText();
-> payoff_one.setEnabled(false);
-> payoff_two.setEnabled(false);
-> game_status.setText("Please wait for your Opponent to Choose");
-> }
I don't think you can rename actionPerformed(ActionEvent ae) like
that, I'm pretty sure that name is a _required_ one for implementing
the ActionListener interface, and I think it must be public, as well.
It isn't clear from your description which "statement" is outside your
two functions, but this kind of stuff _always_ works; the guts of
"actionPerformed" don't have to be in the routine itself.
public void actionPerformed(ActionEvent ae)
{
do_something(ae);
}
private void do_something(ActionEvent ae)
{
// the real stuff you want to do goes here.
}
They don't even have to be in the same class:
private void actionPerformed(ActionEvent ae)
{
MyUtilities.do_Something(ActionEvent ae, Payoff_one p1, Payoff_two
p2);
}
in MyUtilities:
public static void do_Something(ActionEvent ae, Payoff_one p1,
Payoff_two p2)
{
// put the real stuff you want to do here. Notice that since this is
a static
// routine, we had to pass in the instance objects visible from the
instance
// object where the ActionListener was implemented, which probably
// wouldn't be visible from a static method otherwise.
}
I may have messed up the details, I often do, but the generality of
that
Works For Me.
HTH
xanthian.
> hi
> i have a client server program..
Please refrain from multi-posting

Signature
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew