Click here to Skip to main content
15,742,303 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can not display on my listview of java fxml in intellij. I would like anyone to help me by //checking my code. when I run my code is display a blank page.

This is the fxml code:
<pre><?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="" xmlns:fx="">
      <MenuBar layoutY="2.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
          <Menu mnemonicParsing="false" text="File">
              <MenuItem mnemonicParsing="false" text="Close" />
          <Menu mnemonicParsing="false" text="Edit">
              <MenuItem mnemonicParsing="false" text="Delete" />
          <Menu mnemonicParsing="false" text="Help">
              <MenuItem mnemonicParsing="false" text="About" />
      <ListView fx:id="lista" layoutY="26.0" prefHeight="376.0" prefWidth="248.0" />

this is the controller code:

<pre>package com.example.helloworldfx;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;

import java.util.ResourceBundle;

public class HelloController implements Initializable {

    private ListView<String> lista;

    public void initialize(URL url, ResourceBundle resourceBundle) {
        String b = "marcos";
        String c = "marcos";
        String d = "marcos";
        String e = "marcos";

        lista = new ListView<>();
        lista.getItems().setAll(b, c,d,e);


this is the main class code

package com.example.helloworldfx;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;


public class HelloApplication extends Application {
    public void start(Stage stage) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
        Scene scene = new Scene(fxmlLoader.load(), 500, 240);

    public static void main(String[] args) {

What I have tried:

I have tried to create the object of linkList however it does not works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900