Tutorial How to match the styling of the client

Discussion in 'Tutorials & Resources' started by Exia, Mar 12, 2015.

  1. Exia

    Nov 3, 2013
    Likes Received:
    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.

    Code (Text):
    2.     private Scene createScene(JFXPanel panelToMatch){
    3.         Group root = new Group();
    4.         Scene scene = new Scene(root);
    5.         matchStyleSheets(scene, panelToMatch);
    6.         //Add your gui components here
    7.         return scene;
    8.     }
    10.     private void matchStyleSheets(Scene myScene, JFXPanel otherPanel){
    11.         myScene.getStylesheets().clear();
    12.         for(String sheet : otherPanel.getScene().getStylesheets()){
    13.             myScene.getStylesheets().add(sheet);
    14.         }
    15.     }
    17.     private JFXPanel findJFXPanel(JFrame frame) {
    18.         return (JFXPanel)((JLayeredPane)frame.getRootPane().getComponents()[1]).getComponent(0);
    19.     }
    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 bots and the client being one unified experience and enjoy your gui matching the pretty client!
    Arbiter likes this.

Share This Page