java - How to display text vertically on a button in JavaFX? -
i want create button , display it's text vertically on it, in javafx. aware of rotate not want use it.is there other way name button vertically.
rotate way this, there no other solution.
sample code:
import javafx.application.application; import javafx.geometry.pos; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.stackpane; import javafx.stage.stage; /* displays button it's text rotated 90 degrees left */ public class rotatedtext extends application { @override public void start(stage stage) { button feedbackbutton = createbuttonwithrotatedtext("feedback form"); stackpane layout = new stackpane(); layout.getchildren().setall(feedbackbutton); stackpane.setalignment(feedbackbutton, pos.top_right); layout.setprefsize(225, 275); layout.setstyle("-fx-background-color: lightcyan;"); stage.setscene(new scene(layout)); stage.show(); } private button createbuttonwithrotatedtext(string text) { button button = new button(); label label = new label(text); label.setrotate(-90); button.setgraphic(new group(label)); // in-line css used sample purposes, // apply stylesheet. button.setstyle( "-fx-base: orange; " + "-fx-font-size: 30px; " + "-fx-text-background-color: whitesmoke;" ); return button; } public static void main(string[] args) { launch(args); } }
Comments
Post a Comment