1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tutorial How to match the styling of the client

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

  1. Exia

    Joined:
    Nov 3, 2013
    Messages:
    609
    Likes Received:
    259
    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):
    1.  
    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.     }
    9.  
    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.     }
    16.  
    17.     private JFXPanel findJFXPanel(JFrame frame) {
    18.         return (JFXPanel)((JLayeredPane)frame.getRootPane().getComponents()[1]).getComponent(0);
    19.     }
    20.  
    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

Loading...