Created
June 23, 2016 20:32
-
-
Save arjabbar/2d98a121e928e93bde44b1625074dd01 to your computer and use it in GitHub Desktop.
CSS Injector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cssStage = new Stage(); | |
TextArea cssBox = new TextArea(); | |
cssBox.minHeight(150); | |
cssBox.minWidth(300); | |
cssBox.setFont(new Font("monospace", 16)); | |
Parent root = new Pane(cssBox); | |
Scene scene = new Scene(root); | |
cssStage.setScene(scene); | |
cssStage.addEventFilter(KeyEvent.KEY_PRESSED, event -> { | |
if (event.getCode().equals(KeyCode.ENTER) && event.isControlDown() && !cssBox.getText().isEmpty()) { | |
String text = cssBox.getText().replaceAll("\n|\t", ""); | |
int endIndex = cssBox.getText().indexOf("{"); | |
String selector = text.substring(0, endIndex).trim(); | |
String styling = text.substring(endIndex, text.length()).replaceAll("\\{|\\}", ""); | |
getRootView().lookupAll(selector).forEach(node -> node.setStyle(styling)); | |
} | |
}); | |
cssStage.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment