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

            How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

            Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?