I have recently shifted from c# to try Javafx2. I am also new to this forum. I have been stuck trying to implement internal frames in Javafx. I stumbled upon this link: Internal Frames in JavaFX I have managed to add jfxtras 8 jar file to my project as well as in scene builder 2. However, am stuck in aligning the controls on the window.
This is the code for the fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import jfxtras.labs.scene.control.window.*?>
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="500.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="trials.MamaCont">
<children><Window fx:id="wini" layoutX="122.0" layoutY="105.0" prefHeight="190.0" prefWidth="313.0" title="Window" />
</children></AnchorPane>
This the code for the controller class:
package trials;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import jfxtras.labs.scene.control.window.CloseIcon;
import jfxtras.labs.scene.control.window.MinimizeIcon;
import jfxtras.labs.scene.control.window.Window;
/**
* FXML Controller class
*
* @author smoothie
*/
public class MamaCont implements Initializable {
/**
* Initializes the controller class.
*/
/*@FXML
private Button pb;
@FXML
private Label lb;*/
@FXML
private Window wini;
/*@FXML
void pressed(ActionEvent event) {
lb.setText("Gotcha!!!....");
}*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
wini.getLeftIcons().add(new CloseIcon(wini));
wini.getRightIcons().add(new MinimizeIcon(wini));
//wini.setVisible(false);
Button butt = new Button("Enter");
/*butt.setLayoutX(100);
butt.setLayoutY(100);*/
Label lab = new Label();
/*lab.setLayoutX(261);
lab.setLayoutY(192);*/
butt.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
lab.setText("I've been pressed!!!");
}
});
wini.getContentPane().getChildren().add(butt);
wini.getContentPane().getChildren().add(lab);
}
}
This is the screen that appears when the fxml is loaded:
This is the screen that appears when the button is pressed:
As you can see, the text from the label appears infront of the button. This is not what I wanted to achieve.
Does any one know how I can be able to arrange the label so that it is above or below the button?
I managed to add the jfxtras 8 jar file to scene builder and have been able to access its controls as custom controls. However, I noticed that in scene builder one is not able to put javafx controls on the jfxtras window. I tried putting a button on the window but it ended up being put on the anchorpane rather on the window content pane. Has anyone been able put javafx controls on jfxtra window using scene builder? If so, could you please share how you were able to acheve it?
Thank you...
--
You received this message because you are subscribed to the Google Groups "JFXtras Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jfxtras-user...@googlegroups.com.
To post to this group, send email to jfxtra...@googlegroups.com.
Visit this group at http://groups.google.com/group/jfxtras-users.
For more options, visit https://groups.google.com/groups/opt_out.
This is the second screen the button is pressed. The second scene is opened in a new stage with the fxml loaded in the window.
These are the two screens side by side.
Finally, this is what happens when one presses the button on the window screen....
My original question has been fully answered.
If you can permit me to deviate slightly, does anyone know how I can open a new fxml scene on the same stage as the previous fxml scene? I would like to open the jfxtra window on the same stage as the first screen using the first screen's controller but am stuck...
Thanks...