From 470dc19c41669b95b27819f516fde71d7ebd4a62 Mon Sep 17 00:00:00 2001 From: GalKarp Date: Wed, 8 Oct 2014 11:34:34 +0300 Subject: [PATCH] ddd --- Java-Missle/src/view/ConsoleApp.java | 127 +++----------------------- Java-Missle/src/view/Launchertab.java | 39 ++++++++ Java-Missle/src/view/Missiletab.java | 78 ++++++++++++++++ 3 files changed, 129 insertions(+), 115 deletions(-) create mode 100644 Java-Missle/src/view/Launchertab.java create mode 100644 Java-Missle/src/view/Missiletab.java diff --git a/Java-Missle/src/view/ConsoleApp.java b/Java-Missle/src/view/ConsoleApp.java index 8e42df4..647d157 100644 --- a/Java-Missle/src/view/ConsoleApp.java +++ b/Java-Missle/src/view/ConsoleApp.java @@ -1,146 +1,43 @@ package view; -import java.util.List; - import javafx.application.Application; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; import javafx.scene.Scene; -import javafx.scene.control.Button; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; -import javafx.scene.control.TextField; -import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; -import javax.swing.JOptionPane; - -import war.controller.WarUIEventsListener; - public class ConsoleApp extends Application { -// private List allListeners; -// private String launcherName; -// public ConsoleApp(List allListeners, WarGui warGui) { -// this.allListeners = allListeners; -// this.launcherName = launcherName; -// main(null); -// } - - - - - + private Stage primaryStage; + private Missiletab missiletab; + private Launchertab launcherTab; public void start(Stage primaryStage) throws Exception { -// Group root = new Group(); -// primaryStage.setScene(new Scene(root)); + final Tab tabMissile = new Tab(); -// tabMissile.setId("tabMissile"); tabMissile.setText("Missile"); final Tab tabLauncher = new Tab(); -// tabLauncher.setId("tabLauncher"); tabLauncher.setText("Launcher"); TabPane tabPane = new TabPane(); tabPane.setId("mainPane"); - AnchorPane Missiletab = new AnchorPane(); - AnchorPane LauncherTab = new AnchorPane(); - final TextField missileID = new TextField(); - final TextField destination = new TextField(); - final TextField damage = new TextField(); - final TextField flytime = new TextField(); - Button add = new Button("Resquest & Add missile from server"); - final Button connect = new Button("Connect to server"); - Button connectLauncher = new Button("Connect to server"); - TextField launcherId = new TextField(); - Button addLauncher = new Button("Resquest & Add Launcher from server"); - Missiletab.setMaxSize(285.0, 371.0); - LauncherTab.setMaxSize(285.0, 371.0); - - missileID.setPromptText("missileID"); - missileID.setMaxSize(221, 25); - missileID.setLayoutX(14.0); - missileID.setLayoutY(37.0); - - launcherId.setPromptText("LauncherID"); - launcherId.setMaxSize(221, 25); - launcherId.setLayoutX(14.0); - launcherId.setLayoutY(37.0); - - destination.setPromptText("destination"); - destination.setMaxSize(221, 25); - destination.setLayoutX(14.0); - destination.setLayoutY(69.0); - - damage.setPromptText("damage"); - damage.setMaxSize(221, 25); - damage.setLayoutX(14.0); - damage.setLayoutY(101.0); - - flytime.setPromptText("flytime"); - flytime.setMaxSize(221, 25); - flytime.setLayoutX(14.0); - flytime.setLayoutY(133.0); + missiletab = new Missiletab(this); + launcherTab = new Launchertab(this); - add.setLayoutX(14.0); - add.setLayoutY(167.0); - - addLauncher.setLayoutX(14.0); - addLauncher.setLayoutY(78.0); - - connect.setLayoutX(14.0); - connect.setLayoutY(5.0); - - add.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - System.out.println("Hello World!"); - new Thread(new Runnable() { - @Override - public void run() { - // while (true) { - - String id = missileID.getText(); - String dest = destination.getText(); - String damageT = damage.getText(); - String flyTime = flytime.getText(); - if (id.isEmpty() || dest.isEmpty() || damageT.isEmpty()) { - JOptionPane.showMessageDialog(null, - "You must fill all details!"); - return; - } -// for (WarUIEventsListener l : allListeners) { -// l.addMessageThroughClient(id, dest, damageT, flyTime , launcherName); -// } - - } - }).start(); - } - }); - - - connectLauncher.setLayoutX(14.0); - connectLauncher.setLayoutY(5.0); - - Missiletab.getChildren().addAll(connect, missileID, destination, damage, flytime,add); - LauncherTab.getChildren().addAll(connectLauncher, launcherId, addLauncher); - tabMissile.setContent(Missiletab); - tabLauncher.setContent(LauncherTab); + tabMissile.setContent(missiletab); + tabLauncher.setContent(launcherTab); tabPane.getTabs().addAll(tabMissile , tabLauncher); Scene scene = new Scene(tabPane, 255, 240); -// primaryStage.setScene(scene); -// root.getChildren().add(tabPane); scene.getStylesheets().add(this.getClass().getResource("ClientStyle").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } - - - - public static void main(String[] args) { launch(args); } + + public Stage getPrimaryStage() { + return primaryStage; + } } diff --git a/Java-Missle/src/view/Launchertab.java b/Java-Missle/src/view/Launchertab.java new file mode 100644 index 0000000..1dc8ecb --- /dev/null +++ b/Java-Missle/src/view/Launchertab.java @@ -0,0 +1,39 @@ +package view; + +import java.util.Vector; + +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.scene.layout.AnchorPane; +import war.controller.WarUIEventsListener; + +public class Launchertab extends AnchorPane { + private ConsoleApp theApplication; + private Vector allListeners; + private Button connectLauncher, addLauncher; + private TextField launcherId; + public Launchertab(ConsoleApp theApplication) { + this.theApplication = theApplication; + allListeners = new Vector(); + + connectLauncher = new Button("Connect to server"); + launcherId = new TextField(); + addLauncher = new Button("Resquest & Add Launcher from server"); + setMaxSize(285.0, 371.0); + + launcherId.setPromptText("LauncherID"); + launcherId.setMaxSize(221, 25); + launcherId.setLayoutX(14.0); + launcherId.setLayoutY(37.0); + + addLauncher.setLayoutX(14.0); + addLauncher.setLayoutY(78.0); + + connectLauncher.setLayoutX(14.0); + connectLauncher.setLayoutY(5.0); + + getChildren().addAll(connectLauncher, launcherId, addLauncher); + + + } +} diff --git a/Java-Missle/src/view/Missiletab.java b/Java-Missle/src/view/Missiletab.java new file mode 100644 index 0000000..8e478f2 --- /dev/null +++ b/Java-Missle/src/view/Missiletab.java @@ -0,0 +1,78 @@ +package view; + +import java.util.Vector; + +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.scene.layout.AnchorPane; +import war.controller.WarUIEventsListener; + +public class Missiletab extends AnchorPane{ + private ConsoleApp theApplication; + private Vector allListeners; + + public Missiletab(ConsoleApp theApplication) { + this.theApplication = theApplication; + allListeners = new Vector(); + TextField missileID = new TextField(); + TextField destination = new TextField(); + TextField damage = new TextField(); + TextField flytime = new TextField(); + Button add = new Button("Resquest & Add missile from server"); + Button connect = new Button("Connect to server"); + this.setMaxSize(285.0, 371.0); + + missileID.setPromptText("missileID"); + missileID.setMaxSize(221, 25); + missileID.setLayoutX(14.0); + missileID.setLayoutY(37.0); + + destination.setPromptText("destination"); + destination.setMaxSize(221, 25); + destination.setLayoutX(14.0); + destination.setLayoutY(69.0); + + damage.setPromptText("damage"); + damage.setMaxSize(221, 25); + damage.setLayoutX(14.0); + damage.setLayoutY(101.0); + + flytime.setPromptText("flytime"); + flytime.setMaxSize(221, 25); + flytime.setLayoutX(14.0); + flytime.setLayoutY(133.0); + + add.setLayoutX(14.0); + add.setLayoutY(167.0); + + connect.setLayoutX(14.0); + connect.setLayoutY(5.0); + + // add.setOnAction(new EventHandler() { + // @Override + // public void handle(ActionEvent event) { + // System.out.println("Hello World!"); + // new Thread(new Runnable() { + // @Override + // public void run() { + // // while (true) { + // + // String id = missileID.getText(); + // String dest = destination.getText(); + // String damageT = damage.getText(); + // String flyTime = flytime.getText(); + // if (id.isEmpty() || dest.isEmpty() || damageT.isEmpty()) { + // JOptionPane.showMessageDialog(null, + // "You must fill all details!"); + // return; + // } + // } + // }).start(); + // } + // }); + + + getChildren().addAll(connect, missileID, destination, damage, flytime,add); + + } +}