JAVA chapter17. javaFX. 17.10 JavaFX CSS 스타일(3)
JAVA/CONCEPT 2018. 1. 21. 20:32 |JAVA chapter17. javaFX. 17.10 JavaFX CSS 스타일(3)
17.10.5 font 속성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | package sec10.exam07_shadow; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class AppMain extends Application { @Override public void start(Stage primaryStage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("root.fxml")); Scene scene = new Scene(root); scene.getStylesheets().add(getClass().getResource("app.css").toString()); primaryStage.setTitle("AppMain"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } |
1 2 3 4 5 6 7 8 9 10 11 | <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.*?> <?import javafx.geometry.*?> <?import javafx.scene.control.*?> <VBox id="root" xmlns:fx="http://javafx.com/fxml" > <children> <Label id="welcome-text" text="Welcome" /> </children> </VBox> | cs |
1 2 3 4 5 6 7 8 9 10 | #root { -fx-padding: 10; } #welcome-text { -fx-font-size: 35; -fx-font-family: "Arial Black"; -fx-font-weight: bold; -fx-text-fill: linear-gradient(to bottom, blue, white); } | cs |
17.10.6 shadow 효과
1 2 3 4 5 6 7 | #btn1 { -fx-effect: dropshadow(three-pass-box , rgba(0,0,0,0.7) , 10, 0 , 5 , 5); } #btn2 { -fx-effect: innershadow(three-pass-box , rgba(0,0,0,0.7) , 10, 0 , 3, 3); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.*?> <?import javafx.geometry.*?> <?import javafx.scene.control.*?> <HBox prefWidth="300" prefHeight="150" xmlns:fx="http://javafx.com/fxml" spacing="50" fillHeight="false" alignment="CENTER"> <padding> <Insets topRightBottomLeft="10"/> </padding> <children> <Button id="btn1" prefWidth="100" prefHeight="50" text="DropShadow"/> <Button id="btn2" prefWidth="100" prefHeight="50" text="InnerShadow"/> </children> </HBox> | cs |
17.10.7 화면 스킨 입히기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.*?> <?import javafx.scene.control.*?> <AnchorPane styleClass="root" xmlns:fx="http://javafx.com/fxml" prefHeight="194.0" prefWidth="300.0" > <children> <Label id="welcome-text" layoutX="40.0" layoutY="14.0" text="Welcome" /> <Label layoutX="42.0" layoutY="80.0" text="아이디" /> <Label layoutX="42.0" layoutY="118.0" text="패스워드" /> <TextField layoutX="120.0" layoutY="76.0" /> <PasswordField layoutX="120.0" layoutY="114.0" /> <Button layoutX="97.0" layoutY="158.0" styleClass="button" text="로그인" /> <Button layoutX="164.0" layoutY="158.0" styleClass="button" text="취소" /> </children> </AnchorPane> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | .root { -fx-background-image: url("images/background.jpg"); } Label { -fx-font-size: 12px; -fx-font-weight: bold; -fx-text-fill: #333333; } #welcome-text { -fx-font-size: 35px; -fx-font-family: "Arial Black"; -fx-text-fill: linear-gradient(darkgray, lightgray); // 방향이 주어지지 않았으면 to bottom이 생략되어 있음 -fx-effect: innershadow( three-pass-box , rgba(0,0,0,0.7) , 3, 0 , 2 , 2.1 ); } .button { -fx-text-fill: white; -fx-font-family: "Arial Narrow"; -fx-font-weight: bold; -fx-background-color: linear-gradient(#61a2b1, #2A5058); // 방향이 주어지지 않았으면 to bottom이 생략되어 있음 -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 10, 0 , 2 , 2 ); } .button:hover { -fx-background-color: linear-gradient(#2A5058, #61a2b1); // 방향이 주어지지 않았으면 to bottom이 생략되어 있음 } .button:pressed { -fx-background-color: linear-gradient(yellow, #61a2b1); // 방향이 주어지지 않았으면 to bottom이 생략되어 있음 } | cs |
'JAVA > CONCEPT' 카테고리의 다른 글
JAVA chapter 04. 조건문과 반복문. 4.3 반복문 (for문, while문, do-while문) (0) | 2018.01.25 |
---|---|
JAVA chapter 03. 연산자. 3.4 이항 연산자 3.5 삼항 연산자 (0) | 2018.01.25 |
JAVA chapter17. javaFX. 17.10 JavaFX CSS 스타일(2) (0) | 2018.01.21 |
JAVA chapter17. javaFX. 17.7 JavaFX 컨트롤(2) (0) | 2018.01.19 |
JAVA chapter19. NIO 기반 입출력 및 네트워킹. 19.9 UDP 채널 (0) | 2018.01.17 |