How to display contents of an Array using JavaFX GUICreate ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?How to insert an item into an array at a specific index (JavaScript)?How do I determine whether an array contains a particular value in Java?Loop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?Why is processing a sorted array faster than processing an unsorted array?

Who won a Game of Bar Dice?

What do the pair of vertical lines in empirical entropy formula mean?

Proving that a Russian cryptographic standard is too structured

What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?

A word that means "blending into a community too much"

Why do radiation hardened IC packages often have long leads?

Does the new finding on "reversing a quantum jump mid-flight" rule out any interpretations of QM?

What would prevent chimeras from reproducing with each other?

How to publish items after pipeline is finished?

Solving ‘Null geometry…’ error during distance matrix operation?

How can I make 12 tone and atonal melodies sound interesting?

If I leave the US through an airport, do I have to return through the same airport?

How can I remove material from this wood beam?

How can one's career as a reviewer be ended?

What is the polarity of this barrel plug with a double circle?

Increase speed altering column on large table to NON NULL

How creative should the DM let an artificer be in terms of what they can build?

Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?

Does a bank have to tell me if a check made out to me was cashed there?

What is the color of artificial intelligence?

Why can my keyboard only digest 6 keypresses at a time?

Teaching a class likely meant to inflate the GPA of student athletes

Who voices the small round football sized demon In Good Omens

How to add arrows in smartdiagram (descriptive diagram)



How to display contents of an Array using JavaFX GUI


Create ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?How to insert an item into an array at a specific index (JavaScript)?How do I determine whether an array contains a particular value in Java?Loop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?Why is processing a sorted array faster than processing an unsorted array?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have an array containing potential moves for a board game in one file. The display panel that informs the players of current state of game is in another file. I am trying to display this potential moves array as a menu (or table/combo box) in the display panel but I am having problems accessing the array because both codes are in separate files. Any thoughts on how I could display the contents would be greatly appreciated. The array is in my Main.java which contains loads of code but I will post the display panel code here. The array is in a function that returns nothing and prints to the console okay. I hope I have been able to articulate my problem, apologies in advance. calculatemoves function is in Main.java while displayLabels function is in Displaypanel.java



I have tried to create an object of Main but it is not possible because it extends Application(using JavaFX).



public void calculateMoves(int dice1, int dice2)
String[] potentialMoves = new String[500];
int k=0;
....

System.out.println("reach");
System.out.println("k: "+k);
for(k=k-1; k>=0; k--)
System.out.println(potentialMoves[k]);

ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.getItems().addAll(potentialMoves);


public void displayLabels(){
if(gridSize < 31)
int numOfLabels = gridSize;
int j = 0;
for (int i = numOfLabels; i > numOfLabels - 31; i--)
GridPane.setConstraints(labels[i - 1], 0, j);
grid.getChildren().addAll(labels[i - 1]);
j++;
if (i - 1 == 0) break;




13-7 8-3 13-7 7-2 24-18 8-3 24-18 13-8 24-18 18-13 should be printed as a menu. This is the sort of result I get on my console at the moment.










share|improve this question



















  • 1





    I think that code (minimal reproducible example ) would have been clearer and shorter than the attempt to describe it.

    – c0der
    Mar 25 at 7:56

















0















I have an array containing potential moves for a board game in one file. The display panel that informs the players of current state of game is in another file. I am trying to display this potential moves array as a menu (or table/combo box) in the display panel but I am having problems accessing the array because both codes are in separate files. Any thoughts on how I could display the contents would be greatly appreciated. The array is in my Main.java which contains loads of code but I will post the display panel code here. The array is in a function that returns nothing and prints to the console okay. I hope I have been able to articulate my problem, apologies in advance. calculatemoves function is in Main.java while displayLabels function is in Displaypanel.java



I have tried to create an object of Main but it is not possible because it extends Application(using JavaFX).



public void calculateMoves(int dice1, int dice2)
String[] potentialMoves = new String[500];
int k=0;
....

System.out.println("reach");
System.out.println("k: "+k);
for(k=k-1; k>=0; k--)
System.out.println(potentialMoves[k]);

ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.getItems().addAll(potentialMoves);


public void displayLabels(){
if(gridSize < 31)
int numOfLabels = gridSize;
int j = 0;
for (int i = numOfLabels; i > numOfLabels - 31; i--)
GridPane.setConstraints(labels[i - 1], 0, j);
grid.getChildren().addAll(labels[i - 1]);
j++;
if (i - 1 == 0) break;




13-7 8-3 13-7 7-2 24-18 8-3 24-18 13-8 24-18 18-13 should be printed as a menu. This is the sort of result I get on my console at the moment.










share|improve this question



















  • 1





    I think that code (minimal reproducible example ) would have been clearer and shorter than the attempt to describe it.

    – c0der
    Mar 25 at 7:56













0












0








0








I have an array containing potential moves for a board game in one file. The display panel that informs the players of current state of game is in another file. I am trying to display this potential moves array as a menu (or table/combo box) in the display panel but I am having problems accessing the array because both codes are in separate files. Any thoughts on how I could display the contents would be greatly appreciated. The array is in my Main.java which contains loads of code but I will post the display panel code here. The array is in a function that returns nothing and prints to the console okay. I hope I have been able to articulate my problem, apologies in advance. calculatemoves function is in Main.java while displayLabels function is in Displaypanel.java



I have tried to create an object of Main but it is not possible because it extends Application(using JavaFX).



public void calculateMoves(int dice1, int dice2)
String[] potentialMoves = new String[500];
int k=0;
....

System.out.println("reach");
System.out.println("k: "+k);
for(k=k-1; k>=0; k--)
System.out.println(potentialMoves[k]);

ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.getItems().addAll(potentialMoves);


public void displayLabels(){
if(gridSize < 31)
int numOfLabels = gridSize;
int j = 0;
for (int i = numOfLabels; i > numOfLabels - 31; i--)
GridPane.setConstraints(labels[i - 1], 0, j);
grid.getChildren().addAll(labels[i - 1]);
j++;
if (i - 1 == 0) break;




13-7 8-3 13-7 7-2 24-18 8-3 24-18 13-8 24-18 18-13 should be printed as a menu. This is the sort of result I get on my console at the moment.










share|improve this question
















I have an array containing potential moves for a board game in one file. The display panel that informs the players of current state of game is in another file. I am trying to display this potential moves array as a menu (or table/combo box) in the display panel but I am having problems accessing the array because both codes are in separate files. Any thoughts on how I could display the contents would be greatly appreciated. The array is in my Main.java which contains loads of code but I will post the display panel code here. The array is in a function that returns nothing and prints to the console okay. I hope I have been able to articulate my problem, apologies in advance. calculatemoves function is in Main.java while displayLabels function is in Displaypanel.java



I have tried to create an object of Main but it is not possible because it extends Application(using JavaFX).



public void calculateMoves(int dice1, int dice2)
String[] potentialMoves = new String[500];
int k=0;
....

System.out.println("reach");
System.out.println("k: "+k);
for(k=k-1; k>=0; k--)
System.out.println(potentialMoves[k]);

ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.getItems().addAll(potentialMoves);


public void displayLabels(){
if(gridSize < 31)
int numOfLabels = gridSize;
int j = 0;
for (int i = numOfLabels; i > numOfLabels - 31; i--)
GridPane.setConstraints(labels[i - 1], 0, j);
grid.getChildren().addAll(labels[i - 1]);
j++;
if (i - 1 == 0) break;




13-7 8-3 13-7 7-2 24-18 8-3 24-18 13-8 24-18 18-13 should be printed as a menu. This is the sort of result I get on my console at the moment.







java arrays javafx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 7:57









c0der

10.2k51948




10.2k51948










asked Mar 24 at 20:41









OthelloOthello

378




378







  • 1





    I think that code (minimal reproducible example ) would have been clearer and shorter than the attempt to describe it.

    – c0der
    Mar 25 at 7:56












  • 1





    I think that code (minimal reproducible example ) would have been clearer and shorter than the attempt to describe it.

    – c0der
    Mar 25 at 7:56







1




1





I think that code (minimal reproducible example ) would have been clearer and shorter than the attempt to describe it.

– c0der
Mar 25 at 7:56





I think that code (minimal reproducible example ) would have been clearer and shorter than the attempt to describe it.

– c0der
Mar 25 at 7:56












1 Answer
1






active

oldest

votes


















1














You can use ComboBox. Porbably its really simple way.



class YourController implements Initializable
@FXML
private JFXComboBox<String> cccombo;

@Override
public void initialize(URL url, ResourceBundle rb)
ArrayList<String> yourArray = new ArrayList<>();
//fill your array
cccombo.setItems(FXCollections.observableList(yourArray));







share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328367%2fhow-to-display-contents-of-an-array-using-javafx-gui%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can use ComboBox. Porbably its really simple way.



    class YourController implements Initializable
    @FXML
    private JFXComboBox<String> cccombo;

    @Override
    public void initialize(URL url, ResourceBundle rb)
    ArrayList<String> yourArray = new ArrayList<>();
    //fill your array
    cccombo.setItems(FXCollections.observableList(yourArray));







    share|improve this answer



























      1














      You can use ComboBox. Porbably its really simple way.



      class YourController implements Initializable
      @FXML
      private JFXComboBox<String> cccombo;

      @Override
      public void initialize(URL url, ResourceBundle rb)
      ArrayList<String> yourArray = new ArrayList<>();
      //fill your array
      cccombo.setItems(FXCollections.observableList(yourArray));







      share|improve this answer

























        1












        1








        1







        You can use ComboBox. Porbably its really simple way.



        class YourController implements Initializable
        @FXML
        private JFXComboBox<String> cccombo;

        @Override
        public void initialize(URL url, ResourceBundle rb)
        ArrayList<String> yourArray = new ArrayList<>();
        //fill your array
        cccombo.setItems(FXCollections.observableList(yourArray));







        share|improve this answer













        You can use ComboBox. Porbably its really simple way.



        class YourController implements Initializable
        @FXML
        private JFXComboBox<String> cccombo;

        @Override
        public void initialize(URL url, ResourceBundle rb)
        ArrayList<String> yourArray = new ArrayList<>();
        //fill your array
        cccombo.setItems(FXCollections.observableList(yourArray));








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 21:06









        sad decembersad december

        564




        564





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328367%2fhow-to-display-contents-of-an-array-using-javafx-gui%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현