label.setFont(new Font("Arial", 20));
label.setFont(new Font("Arial", 20));
label.setFont(new Font("Arial", 20));
public class Controller implements Initializable { @FXML private GridPane greadpane; @Override public void initialize(URL url, ResourceBundle resourceBundle) { final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); greadpane.add(label, 0, 0); } }
FontLoader fontLoader = Toolkit.getToolkit().getFontLoader(); Label label = new Label("My name is Warren. I love Java."); label.setFont(Font.font("Consolas", FontWeight.THIN, FontPosture.REGULAR, 16)); System.out.println("The label's width is: " + fontLoader.computeStringWidth(label.getText(), label.getFont()));
Label startLabel = new Label("Start"); startLabel.setFont(new Font(26)); Button start = new Button(""); //do not add Text to the Button start.setGraphic(startLabel);
FontLoader fontLoader = Toolkit.getToolkit().getFontLoader(); Label label = new Label("My name is Warren. I love Java."); label.setFont(Font.font("Consolas", FontWeight.THIN, FontPosture.REGULAR, 16)); System.out.println("The label's textProperty string width is: " + fontLoader.computeStringWidth(label.getText(), label.getFont())); System.out.println("Label's width before layouted: " + label.getWidth()); primaryStage.setScene(new Scene(new StackPane(label), 300, 250)); primaryStage.show(); System.out.println("Label's width after layouted: " + label.getWidth());
public class Test2 extends Application { public static void main(String[] args) { launch(args); } public void start(final Stage primaryStage) { Group rootGroup = new Group(); // create a label to show some text Label label = new Label("Demo Text"); try { // load a custom font from a specific location (change path!) // 12 is the size to use final Font f = Font.loadFont(new FileInputStream(new File("./myFonts/TRON.TTF")), 12); label.setFont(f); // use this font with our label } catch (FileNotFoundException e) { e.printStackTrace(); } rootGroup.getChildren().add(label); // create scene, add root group and show stage Scene scene = new Scene(rootGroup, 640, 480, Color.WHITE); primaryStage.setScene(scene); primaryStage.show(); } }
public class ContentTab extends VBox{ Label allegati; TextField inseriscitesto; ListView<MyObject> view; public ContentTab(int width){ setPadding(new Insets(20)); setSpacing(10); allegati = new Label("Allegati alla lezione"); allegati.setFont(Font.font("Verdana", 13)); inseriscitesto = new TextField(""); FilteredList<MyObject> filteredData = new FilteredList(FXCollections.observableArrayList(), s -> true); view = new ListView<MyObject>(filteredDate); inseriscitesto.textProperty().addListener(obs->{ String filter = inseriscitesto.getText(); if(filter == null || filter.length() == 0) { filteredData.setPredicate(s -> true); } else { filteredData.setPredicate(s -> s.getTitolo().contains(filter)); } }); view.setStyle("-fx-background-color: transparent;"); setPrefWidth(width); getChildren().addAll(allegati,inseriscitesto, view); }
public void start(Stage primaryStage) { Label label = new Label(); label.setText("Hello"); label.setFont(Font.font("Arial", 32)); System.out.println(label.getWidth()); StackPane root = new StackPane(); root.getChildren().add(label); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); System.out.println("------"); System.out.println(label.getWidth()); }
public class Dimensions extends Application { public static void main(String[] args) { launch(args); } public void start(Stage primaryStage) { MyPanel myPanel = new MyPanel(); primaryStage.setScene(new Scene(myPanel, 500, 500)); primaryStage.show(); System.out.println(myPanel.label.getWidth()); } } class MyPanel extends Pane { public Label label; public MyPanel() { label = new Label(); label.setText("Hello"); label.setFont(new Font(32)); getChildren().add(label); label.relocate(150, 150); } }
private final Random random = new Random(); private final Color[] colors = { Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW }; @Override public void start( final Stage primaryStage ) { HBox hbox = new HBox(); String str = "my-string-val"; for ( String s : str.split( "" ) ) { Label l = new Label( s ); l.setBorder( new Border( new BorderStroke( Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT ) ) ); l.setBackground( new Background( new BackgroundFill( colors[random.nextInt( colors.length )], CornerRadii.EMPTY, Insets.EMPTY ) ) ); l.setPrefWidth( 20 ); l.setAlignment( Pos.CENTER ); l.setFont( font( "Arial", FontWeight.BOLD, 16 ) ); hbox.getChildren().add( l ); } final Scene scene = new Scene( hbox, 800, 600 ); primaryStage.setScene( scene ); primaryStage.show(); }
label.setFont(Font.font("Verdana", 20)); list.setItems(data); stage.show();
@Override public void start( Stage primaryStage ) { final Label label = new Label( "Lorem Ipsum is simply dummy long text of the printing and typesetting industry" ); label.setFont( Font.font( 10 ) ); System.out.println( "originalText = " + label.getText() ); Platform.runLater( () -> { Double fontSize = label.getFont().getSize(); String clippedText = Utils.computeClippedText( label.getFont(), label.getText(), label.getWidth(), label.getTextOverrun(), label.getEllipsisString() ); Font newFont = label.getFont(); while ( !label.getText().equals( clippedText ) && fontSize > 0.5 ) { System.out.println( "fontSize = " + fontSize + ", clippedText = " + clippedText ); fontSize = fontSize - 0.05; newFont = Font.font( label.getFont().getFamily(), fontSize ); clippedText = Utils.computeClippedText( newFont, label.getText(), label.getWidth(), label.getTextOverrun(), label.getEllipsisString() ); } label.setFont( newFont ); } ); Scene scene = new Scene( new VBox(label), 350, 200 ); primaryStage.setScene( scene ); primaryStage.show(); }
public ListCell<String> call(ListView<String> p) { Label usernameLabel = new Label(); usernameLabel.setFont(Font.font("Arial", FontWeight.BOLD, 12)); Button callButton = new Button("Call");
label.setFont(new Font("Arial", 20));
displayLabel.setFont(Font.font(null, FontWeight.BOLD, 14));
displayLabel.setFont(Font.font(null, FontWeight.BOLD, 14));
displayLabel.setFont(Font.font(null, FontWeight.BOLD, 14));