A sentimental robot

Chatting UI 본문

Java

Chatting UI

GOD03219 2018. 2. 7. 13:42

package Pack01;

import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Hello extends Application {

 @Override
 public void start(Stage arg0) throws Exception {

  VBox vbox = new VBox();
  vbox.setPrefSize(300, 300);

  // --------------- code
  Button btn1 = new Button("Conversation Start");
  TextField text = new TextField();
  TextArea textArea = new TextArea();

  text.setOnAction(new EventHandler<>() {

   @Override
   public void handle(ActionEvent arg0) {
    String s = text.getText();
    textArea.appendText("User: " + s + "\n");
    text.setText(" ");
    btn1.setVisible(false);

   }
  });

  vbox.getChildren().addAll(btn1, text, textArea);

  // ---------------

  Scene scene = new Scene(vbox);
  arg0.setScene(scene);
  arg0.setTitle("server");
  arg0.show();

 }

 public static void main(String[] args) {

  launch();

 }

}

'Java' 카테고리의 다른 글

NullPointerException  (0) 2018.06.30
Platform.runLater( )  (0) 2018.02.07
UI  (0) 2018.02.07
진수에 대해서  (0) 2018.01.09
객체참조  (0) 2018.01.09