Lépésszám kijelzése és menüpontok beállítása
This commit is contained in:
parent
370e5c65bc
commit
17a6c9b10f
|
@ -7,7 +7,6 @@ import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Spinner;
|
import javafx.scene.control.Spinner;
|
||||||
|
|
|
@ -1,17 +1,41 @@
|
||||||
package hanoi;
|
package hanoi;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Alert.AlertType;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
public class HanoiFormController {
|
public class HanoiFormController {
|
||||||
|
|
||||||
private Korong kezbeKorong;
|
private Korong kezbeKorong;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem ujItem;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem beallItem;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem kilepItem;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem helpItem;
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ResourceBundle resources;
|
private ResourceBundle resources;
|
||||||
|
@ -33,7 +57,41 @@ public class HanoiFormController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Pane felvettPane;
|
private Pane felvettPane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label lepesCimke;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void beallKattintas(ActionEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void helpKattintas(ActionEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void kilepkattintas(ActionEvent event) {
|
||||||
|
Alert alert = new Alert(AlertType.CONFIRMATION);
|
||||||
|
alert.setTitle("Kilépés megerõsítése");
|
||||||
|
alert.setHeaderText("Ön a kilépés menüpontra kattintott.");
|
||||||
|
alert.setContentText("Valóban ki akar lépni a programból?");
|
||||||
|
|
||||||
|
|
||||||
|
Optional<ButtonType> result = alert.showAndWait();
|
||||||
|
if (result.get() == ButtonType.OK){
|
||||||
|
// ... itt kell kilépni
|
||||||
|
//Platform.exit();
|
||||||
|
((Stage)jatekTerulet.getScene().getWindow()).close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void ujKattintas(ActionEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void elsoRudClick(MouseEvent event) {
|
void elsoRudClick(MouseEvent event) {
|
||||||
korongMozgatas(r1);
|
korongMozgatas(r1);
|
||||||
|
@ -62,6 +120,8 @@ public class HanoiFormController {
|
||||||
if (r.addKorong(kezbeKorong)) {
|
if (r.addKorong(kezbeKorong)) {
|
||||||
kezbeKorong = null;
|
kezbeKorong = null;
|
||||||
egyRudRajzolas(r);
|
egyRudRajzolas(r);
|
||||||
|
fh.lepesNoveles();
|
||||||
|
lepesCimke.setText("Lépések száma: "+fh.getLepesSzam());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//rudRajzolas();
|
//rudRajzolas();
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
<?import javafx.scene.layout.Pane?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.shape.Rectangle?>
|
<?import javafx.scene.shape.Rectangle?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="hanoi.HanoiFormController">
|
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="hanoi.HanoiFormController">
|
||||||
<children>
|
<children>
|
||||||
|
@ -48,23 +49,16 @@
|
||||||
<menus>
|
<menus>
|
||||||
<Menu mnemonicParsing="false" text="Fájl">
|
<Menu mnemonicParsing="false" text="Fájl">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="New" />
|
<MenuItem fx:id="ujItem" mnemonicParsing="false" onAction="#ujKattintas" text="Új játék" />
|
||||||
<MenuItem mnemonicParsing="false" text="Open…" />
|
|
||||||
<Menu mnemonicParsing="false" text="Open Recent" />
|
|
||||||
<SeparatorMenuItem mnemonicParsing="false" />
|
<SeparatorMenuItem mnemonicParsing="false" />
|
||||||
<MenuItem mnemonicParsing="false" text="Close" />
|
<MenuItem fx:id="beallItem" mnemonicParsing="false" onAction="#beallKattintas" text="Beállítások" />
|
||||||
<MenuItem mnemonicParsing="false" text="Save" />
|
|
||||||
<MenuItem mnemonicParsing="false" text="Save As…" />
|
|
||||||
<MenuItem mnemonicParsing="false" text="Revert" />
|
|
||||||
<SeparatorMenuItem mnemonicParsing="false" />
|
<SeparatorMenuItem mnemonicParsing="false" />
|
||||||
<MenuItem mnemonicParsing="false" text="Preferences…" />
|
<MenuItem fx:id="kilepItem" mnemonicParsing="false" onAction="#kilepkattintas" text="Kilépés" />
|
||||||
<SeparatorMenuItem mnemonicParsing="false" />
|
|
||||||
<MenuItem mnemonicParsing="false" text="Quit" />
|
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Súgó">
|
<Menu mnemonicParsing="false" text="Súgó">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="About MyHelloApp" />
|
<MenuItem fx:id="helpItem" mnemonicParsing="false" onAction="#helpKattintas" text="Használati útmutató" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
|
@ -75,9 +69,14 @@
|
||||||
<Rectangle fx:id="masodikRudRect" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="303.0" layoutX="310.0" layoutY="81.0" onMouseClicked="#masodikRudClick" stroke="BLACK" strokeType="INSIDE" width="8.0" />
|
<Rectangle fx:id="masodikRudRect" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="303.0" layoutX="310.0" layoutY="81.0" onMouseClicked="#masodikRudClick" stroke="BLACK" strokeType="INSIDE" width="8.0" />
|
||||||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="15.0" layoutY="384.0" stroke="BLACK" strokeType="INSIDE" width="640.0" />
|
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="15.0" layoutY="384.0" stroke="BLACK" strokeType="INSIDE" width="640.0" />
|
||||||
<Rectangle fx:id="harmadikRudRect" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="303.0" layoutX="480.0" layoutY="81.0" onMouseClicked="#harmadikRudClick" stroke="BLACK" strokeType="INSIDE" width="8.0" />
|
<Rectangle fx:id="harmadikRudRect" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="303.0" layoutX="480.0" layoutY="81.0" onMouseClicked="#harmadikRudClick" stroke="BLACK" strokeType="INSIDE" width="8.0" />
|
||||||
<Pane fx:id="felvettPane" layoutX="133.0" layoutY="4.0" prefHeight="30.0" prefWidth="352.0">
|
<Pane fx:id="felvettPane" layoutX="133.0" layoutY="4.0" prefHeight="30.0" prefWidth="481.0">
|
||||||
<children>
|
<children>
|
||||||
<Label layoutX="13.0" layoutY="5.0" prefHeight="17.0" prefWidth="155.0" text="A felemelt korong:" />
|
<Label layoutX="13.0" layoutY="5.0" prefHeight="17.0" prefWidth="105.0" text="A felemelt korong:" />
|
||||||
|
<Label fx:id="lepesCimke" layoutX="325.0" layoutY="5.0" prefHeight="20.0" prefWidth="155.0" text="Lépések száma: 0">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
</children>
|
</children>
|
||||||
</Pane>
|
</Pane>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -2,6 +2,7 @@ module HanoiTornyai {
|
||||||
requires javafx.controls;
|
requires javafx.controls;
|
||||||
requires javafx.fxml;
|
requires javafx.fxml;
|
||||||
requires javafx.graphics;
|
requires javafx.graphics;
|
||||||
|
requires javafx.base;
|
||||||
|
|
||||||
opens hanoi to javafx.graphics, javafx.fxml;
|
opens hanoi to javafx.graphics, javafx.fxml;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user