Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I make responsible FXML?

 
drashti pandya
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I move my application from one computer to other.Layout get change every time . What is solution for it?
 
Antonio Modesto Amaral Sousa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How do you build your views? Do you use Scene Builder? I just tried it for a couple of minutes and noticed that depending the way you use it, it creates a lot of static positioning.
I think the best way is to use the most suitable layout for your purpose and avoid setting nodes statically in the scene.


Regards.
 
drashti pandya
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using scene builder.Here is my code.Itry with java.awt toolkit but it doesn't show result;

public class MainApp extends Application {

@Override
public void start(Stage stage) throws Exception {
/* Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));

Scene scene = new Scene(root);
scene.getStylesheets().add("/styles/Styles.css");

stage.setTitle("JavaFX and Maven");
stage.setScene(scene);
stage.show();*/
/* Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
int screenWidth = d.width;
int screenHeight = d.height;*/
System.out.println("javafx.runtime.version: " + System.getProperties().get("javafx.runtime.version"));


FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/home.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root);
stage.setScene(scene);


scene.getStylesheets().add
(MainApp.class.getResource("/styles/SysSet.css").toExternalForm());
stage.show();
setUserAgentStylesheet(STYLESHEET_MODENA);
}
 
Antonio Modesto Amaral Sousa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the FXML Scene Builder generated. I bet you'll see a lot of setX or setY parameters. That's what I meant when I talked about static positioning. I recommend you to read the book JavaFX 8 Introduction by Example. There you'll find a lot of examples of how to add controls using just the layout system (HBox, VBox, BorderPane, GridPane, FlowPane, etc).

Bye.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!