Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package giereczka2;
- import javafx.event.Event;
- import javafx.event.EventHandler;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.image.Image;
- import javafx.scene.layout.AnchorPane;
- import javafx.scene.layout.Background;
- import javafx.scene.layout.BackgroundImage;
- import javafx.scene.layout.BackgroundPosition;
- import javafx.scene.layout.BackgroundRepeat;
- import javafx.stage.Stage;
- import javafx.scene.image.ImageView;
- import javafx.scene.media.Media;
- import javafx.scene.media.MediaPlayer;
- import javafx.stage.Stage;
- import javafx.scene.SubScene;
- public class widok {
- private static final int HEIGHT = 786;
- private static final int WIDTH = 1024;
- private AnchorPane mainPane;
- private Scene mainScene;
- private Stage mainStage;
- private final String StartPrzycisk = "-fx-background-color: transparent; -fx-graphic: url('resouces/START.png');";
- private final String JakGracPrzycisk = "-fx-background-color: transparent; -fx-graphic: url('resouces/JakGrac.png');";
- private final String RankingPrzycisk = "-fx-background-color: transparent; -fx-graphic: url('resouces/Ranking.png');";
- private final String WyjsciePrzycisk = "-fx-background-color: transparent; -fx-graphic: url('resouces/wyjscie.png');";
- private final String DzwiekPrzycisk = "-fx-background-color: transparent; -fx-graphic: url('resouces/dzwiek.png');";
- private final String MuzykaPrzycisk = "-fx-background-color: transparent; -fx-graphic: url('resouces/muzyka.png');";
- //private ZywieniowePotyczkiStart startSubscene;
- private GraSubscene startSubscene;
- private GraSubscene jakgracSubscene;
- private GraSubscene rankingSubscene;
- private GraSubscene wyjscieSubscene;
- public widok()
- {
- mainPane = new AnchorPane();
- mainScene = new Scene(mainPane,WIDTH,HEIGHT);
- mainStage = new Stage();
- mainStage.setScene(mainScene);
- //mainStage.setResizable(false);
- // nie umiem inaczej tego napisac
- mainStage.setMinWidth(1024);
- mainStage.setMaxWidth(1024);
- mainStage.setMinHeight(786);
- mainStage.setMaxHeight(786);
- createButtons();
- createBackground();
- createLogo();
- createSubScenes();
- /*sprawdzenie działania subscene
- GraSubscene subScene = new GraSubscene();
- subScene.setLayoutX(100);
- subScene.setLayoutY(100);
- mainPane.getChildren().add(subScene);*/
- }
- private void createSubScenes() {
- startSubscene = new GraSubscene();
- mainPane.getChildren().add(startSubscene);
- jakgracSubscene = new GraSubscene();
- mainPane.getChildren().add(jakgracSubscene);
- rankingSubscene = new GraSubscene();
- mainPane.getChildren().add(rankingSubscene);
- wyjscieSubscene = new GraSubscene();
- mainPane.getChildren().add(wyjscieSubscene);
- }
- public Stage getMainStage(){
- return mainStage;
- }
- public void createButtons() {
- Button button = new Button();
- button.setLayoutX(402);
- button.setLayoutY(200);
- button.setStyle(StartPrzycisk);
- Button jakgrac = new Button();
- jakgrac.setLayoutX(337);
- jakgrac.setLayoutY(300);
- jakgrac.setStyle(JakGracPrzycisk);
- Button ranking = new Button();
- ranking.setLayoutX(359);
- ranking.setLayoutY(400);
- ranking.setStyle(RankingPrzycisk);
- Button wyjscie = new Button();
- wyjscie.setLayoutX(363);
- wyjscie.setLayoutY(500);
- wyjscie.setStyle(WyjsciePrzycisk);
- Button dzwiek = new Button();
- dzwiek.setLayoutX(84);
- dzwiek.setLayoutY(15);
- dzwiek.setStyle(DzwiekPrzycisk);
- Button muzyka = new Button();
- muzyka.setLayoutX(10);
- muzyka.setLayoutY(10);
- muzyka.setStyle(MuzykaPrzycisk);
- //subscene obsługa przycisków
- mainPane.getChildren().add(button);
- mainPane.getChildren().add(jakgrac);
- mainPane.getChildren().add(ranking);
- mainPane.getChildren().add(wyjscie);
- mainPane.getChildren().add(dzwiek);
- mainPane.getChildren().add(muzyka);
- button.setOnMouseClicked(new EventHandler<Event>() {
- @Override
- public void handle(Event event){
- startSubscene.moveSubScene();
- }
- });
- }
- private void createBackground() {
- Image backgroundImage = new Image("resouces/tlo.png",1024,786,false,true);
- BackgroundImage background = new BackgroundImage(backgroundImage, BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT, BackgroundPosition.DEFAULT, null);
- mainPane.setBackground(new Background(background));
- }
- private void createLogo(){
- ImageView logo = new ImageView("resouces/Logo.png");
- logo.setLayoutX(101);
- logo.setLayoutY(75);
- mainPane.getChildren().add(logo);
- }
- /*public void start(Button muzyka){
- muzyka.setOnMouseClicked(new EventHandler<Event>() {
- @Override
- public void handle(Event event){
- mediaplayer.play();
- System.out.print("Nasz tekst");
- }
- });
- Media MusicFile = new Media(getClass().getResource("resources/music.mp3").toExternalForm());
- mediaplayer = new MediaPlayer(MusicFile);
- mediaplayer.setAutoPlay(true);
- mediaplayer.setVolume(0.1);
- mainPane.getChildren().addAll(muzyka);
- }
- */ // kiedyś może to się przyda
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement