Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zarkopafilis.koding.io.rfslabs.servermanager;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.BufferedWriter;
- import java.io.IOException;
- import java.io.OutputStreamWriter;
- public class SendListener implements ActionListener{
- private Frame f;
- public SendListener(Frame f){
- this.f = f;
- }
- public void actionPerformed(ActionEvent e){
- System.out.println("a");
- sendCommand();
- }
- @SuppressWarnings("static-access")
- public void sendCommand(){
- if(f.started = true && !(f.cmdArea.getText().equalsIgnoreCase("Write your command here")) && !(f.cmdArea.getText() == null)){
- if(!f.cmdArea.getText().equalsIgnoreCase("stop") || !f.cmdArea.getText().equalsIgnoreCase("reload")){
- Thread sendCmd = new Thread(){
- @Override
- public void run(){
- f.log.append(f.cTag + "Sending command\n");
- final String command = f.cmdArea.getText();
- BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(f.outputStream));
- try {
- writer.write(command);
- writer.flush();
- writer.close();
- f.cmdArea.setText("Write your command here");
- } catch (IOException e) {
- e.printStackTrace();
- }
- f.log.append(f.cTag + "Sent command sucessfully\n");
- f.started = false;
- }
- };
- sendCmd.start();
- }else{
- f.log.append(f.cTag + "This command is not allowed\n");
- }
- }else{
- f.log.append(f.cTag + "Please start your server first\n or make sure that you have entered a command\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement