java - making the backround of a javafx textArea clear -
i looking whole text area class in java, going use in cool gui i'm making but, when looking make background clear thing find method allows set opaqueness. of whole text area (including text) want background clear. advice/tips
also google searches made came lot of css related posts huh?
a textarea
contains scroll pane internally. 3 things need make transparent make text area appear transparent
- the text area iteself
- the viewport text area's internal scroll pane
- the content pane displays text inside scroll pane
the css rule is
.text-area, .text-area .viewport, .text-area .content { -fx-background-color: transparent ; }
complete example:
transparenttextarea.java:
import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.textarea; import javafx.scene.layout.stackpane; import javafx.stage.stage; public class transparenttextarea extends application { @override public void start(stage primarystage) { textarea textarea = new textarea(); stackpane root = new stackpane(textarea); scene scene = new scene(root, 400, 400); scene.getstylesheets().add("transparent-text-area.css"); primarystage.setscene(scene); primarystage.show(); } public static void main(string[] args) { launch(args); } }
transparent-text-area.css:
.root { -fx-background-color: linear-gradient(to bottom right, white 0%, cornflowerblue 100% ); } .text-area, .text-area .viewport, .text-area .content { -fx-background-color: transparent ; }
Comments
Post a Comment