Basically, what I've come to is that the ActionListener dies if there's a Try/Catch in it. It doesn't even matter what's in the Try/Catch.
I commented out everything inside and had it try just writing to the textarea(cliTextArea) from the textfield(cliTextField) and it would freeze up when I hit enter. When I took out the try/catch block it would run just fine.
It also stops if I remove the try/catch block, when it gets String cliString = _input.readLine(); But with the try/catch and nothing else but cliTextArea.append(cliUserInput.getText().toString()); it still doesn't run. I don't think the _input.readLine() is what's killing it.
Anyway, enough explaining. Here's the code that I think matters. If anyones curious, _input is a BufferedReader, and _output is a PrintWriter.
Here's the implementation:
cliUserInput.addActionListener(new ButtonListener());
and here's the ButtonListener class.
private class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
//get command from command line
String command = cliUserInput.getText();
cliTextArea.append("Enter key hit, saving text. . ." + '\n');
//send command to server
cliTextArea.append("Sending text. . ." + '\n');
_output.append(command);
cliTextArea.append("Text sent. Flushing output. . ." + '\n');
_output.flush();
cliTextArea.append("Output flushed." + '\n');
cliTextArea.append("Waiting for response from server. . ." + '\n');
try
{
String cliString = _input.readLine();
cliTextArea.append("Response received." + '\n');
cliTextArea.append("Writing response to cli. . ." + '\n');
cliTextArea.append(cliString + '\n');
cliTextArea.append("Response from server written to cli." + '\n');
cliTextArea.append("Clearing cliUserInput TextBox" + '\n');
cliUserInput.setText("");
cliTextArea.append("Text Box should be clear" + '\n');
}
catch (IOException ex)
{
cliTextArea.append(ex.toString());
}
}
}
Most of the append text is just from trying to pinpoint the bug.

New Topic/Question
Reply




MultiQuote






|