Browse Source

Made working pane layout for chat window.

server
Cameron Weinfurt 2 years ago
parent
commit
08b3cc5712
  1. 23
      sample/Main.java
  2. 62
      window/ChatWindow.java

23
sample/Main.java

@ -1,23 +0,0 @@
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

62
window/ChatWindow.java

@ -0,0 +1,62 @@
package window;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.stage.Stage;
import javafx.scene.control.Button;
public class ChatWindow extends Application {
public ChatWindow() {
this.servername = "Serverless Chat Window";
}
public ChatWindow(String servername) {
this.servername = servername;
}
@Override
public void start(Stage primaryStage) throws Exception{
AnchorPane root = new AnchorPane();
primaryStage.setMaximized(true);
primaryStage.setTitle("Clype Chat: " + servername);
primaryStage.setScene(new Scene(root, 800, 800));
Pane statusBar = new Pane();
AnchorPane.setBottomAnchor(statusBar, 0.0);
AnchorPane.setLeftAnchor(statusBar, 0.0);
AnchorPane.setRightAnchor(statusBar, 0.0);
statusBar.setPrefHeight(20);
Pane inputPane = new Pane();
AnchorPane.setBottomAnchor(inputPane, statusBar.getPrefHeight());
AnchorPane.setLeftAnchor(inputPane, 0.0);
AnchorPane.setRightAnchor(inputPane, 0.0);
inputPane.prefHeightProperty().setValue(40);
FlowPane usersPane = new FlowPane();
AnchorPane.setTopAnchor(usersPane, 0.0);
AnchorPane.setRightAnchor(usersPane, 0.0);
usersPane.prefWidthProperty().setValue(300);
usersPane.prefHeightProperty().bind(root.heightProperty().subtract(statusBar.heightProperty()).subtract(inputPane.heightProperty()));
ScrollPane messagePane = new ScrollPane();
AnchorPane.setTopAnchor(messagePane, 0.0);
AnchorPane.setLeftAnchor(messagePane, 0.0);
messagePane.prefWidthProperty().bind(root.widthProperty().subtract(usersPane.widthProperty()));
messagePane.prefHeightProperty().bind(root.heightProperty().subtract(statusBar.heightProperty()).subtract(inputPane.heightProperty()));
root.getChildren().addAll(statusBar, inputPane, usersPane, messagePane);
primaryStage.show();
}
public static void main(String[] args) {launch(args);}
private String servername;
}
Loading…
Cancel
Save