- Joined
- Nov 3, 2013
- Messages
- 609
- Thread Author
- #1
Pending an update that exposes the current style of client that Cloud has confirmed (Yay!), you can use this to get the style sheets that will match the current theme of the client.
This uses a bit of hackery in the way that a JFrame stores it's sub components. All you have to do is call findJFXPanel on ClientUI.getFrame(). This is a very simple way to grab this data, and it will more than likely break if any changes are made to the gui since the components may not be in the exact order. Let's try to get our scripts and the client being one unified experience and enjoy your gui matching the pretty client!
Code:
private Scene createScene(JFXPanel panelToMatch){
Group root = new Group();
Scene scene = new Scene(root);
matchStyleSheets(scene, panelToMatch);
//Add your gui components here
return scene;
}
private void matchStyleSheets(Scene myScene, JFXPanel otherPanel){
myScene.getStylesheets().clear();
for(String sheet : otherPanel.getScene().getStylesheets()){
myScene.getStylesheets().add(sheet);
}
}
private JFXPanel findJFXPanel(JFrame frame) {
return (JFXPanel)((JLayeredPane)frame.getRootPane().getComponents()[1]).getComponent(0);
}
This uses a bit of hackery in the way that a JFrame stores it's sub components. All you have to do is call findJFXPanel on ClientUI.getFrame(). This is a very simple way to grab this data, and it will more than likely break if any changes are made to the gui since the components may not be in the exact order. Let's try to get our scripts and the client being one unified experience and enjoy your gui matching the pretty client!