Rajdeep
Rajdeep

Reputation: 2462

How do I add a label to a vBox?

I'm having some problem statically adding a label to an fxml file. Here is what I tried, but it does not work, placeholder is highlighted in red. I basically want a header/title for my list view.

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.VBox?>
<?import java.awt.Label?>
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
    <placeholder>
        <Label text="some text"/>
    </placeholder>
    <ListView fx:id="groupListView" VBox.vgrow="ALWAYS" />
</VBox>

Upvotes: 0

Views: 1922

Answers (1)

Rajdeep
Rajdeep

Reputation: 2462

I had the wrong import, and there was no need for placeholder

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Label?>
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
        <Label text="some text"/>
    <ListView fx:id="groupListView" VBox.vgrow="ALWAYS" />
</VBox>

Upvotes: 3

Related Questions