Ablak meghívása, felhasználó és korongszám átadása. Korongok generálása
megkezdve.
This commit is contained in:
parent
a5756c8deb
commit
fdc2b18bd7
|
@ -1,13 +1,20 @@
|
|||
package hanoi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.SpinnerValueFactory;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class FoablakController {
|
||||
|
||||
|
@ -27,8 +34,24 @@ public class FoablakController {
|
|||
private Button playGomb;
|
||||
|
||||
@FXML
|
||||
void playGombAction(ActionEvent event) {
|
||||
void playGombAction(ActionEvent event) throws IOException {
|
||||
String fnev = (nevMezo.getText()==null || nevMezo.getText().isEmpty()) ? "anonymous" : nevMezo.getText();
|
||||
Felhasznalo fh = new Felhasznalo(fnev);
|
||||
|
||||
FXMLLoader fl = new FXMLLoader(getClass().getResource("hanoi_form2.fxml"));
|
||||
VBox root = (VBox)fl.load();
|
||||
|
||||
|
||||
|
||||
Scene sc = new Scene(root);
|
||||
Node n = (Node) event.getSource();
|
||||
Stage st = (Stage) n.getScene().getWindow();
|
||||
st.setScene(sc);
|
||||
st.show();
|
||||
// a felhasználó és korongszám átadása a hanoi ablaknak
|
||||
HanoiFormController hfc = fl.getController();
|
||||
hfc.setFh(fh);
|
||||
hfc.setKorongokSzama(kspin.getValue());
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -4,14 +4,21 @@ import java.net.URL;
|
|||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
|
||||
public class HanoiFormController {
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private ResourceBundle resources;
|
||||
|
||||
@FXML
|
||||
private AnchorPane jatekTerulet;
|
||||
|
||||
@FXML
|
||||
private URL location;
|
||||
|
||||
|
@ -48,6 +55,44 @@ public class HanoiFormController {
|
|||
assert masodikRudRect != null : "fx:id=\"masodikRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'.";
|
||||
assert harmadikRudRect != null : "fx:id=\"harmadikRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'.";
|
||||
assert felvettPane != null : "fx:id=\"felvettPane\" was not injected: check your FXML file 'hanoi_form2.fxml'.";
|
||||
r1 = new Rud(elsoRudRect);
|
||||
r2 = new Rud(masodikRudRect);
|
||||
r3 = new Rud(harmadikRudRect);
|
||||
//fh = new Felhasznalo(null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void korongGeneralas() {
|
||||
//System.out.println(jatekTerulet.widthProperty());
|
||||
korongSzelMax = jatekTerulet.getWidth()/3-2*KDIFF;
|
||||
for (int i = 0; i < korongokSzama; i++) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setFh(Felhasznalo fh) {
|
||||
this.fh = fh;
|
||||
System.out.println(fh.getNev());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setKorongokSzama(int korongokSzama) {
|
||||
this.korongokSzama = korongokSzama;
|
||||
korongGeneralas();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Rud r1;
|
||||
private Rud r2;
|
||||
private Rud r3;
|
||||
private Felhasznalo fh;
|
||||
private int korongokSzama;
|
||||
private double korongSzelMax;
|
||||
final private double KDIFF = 30;
|
||||
private Color[] szinek = {};
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
</Menu>
|
||||
</menus>
|
||||
</MenuBar>
|
||||
<AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||
<AnchorPane fx:id="jatekTerulet" maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<Rectangle fx:id="elsoRudRect" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="303.0" layoutX="140.0" layoutY="81.0" onMouseClicked="#elsoRudClick" 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" />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module HanoiTornyai {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires javafx.graphics;
|
||||
|
||||
opens hanoi to javafx.graphics, javafx.fxml;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user