Input array into GUI Jtextarea

后端 未结 1 1834
忘了有多久
忘了有多久 2021-01-29 08:35

Been trying to add my array, year and size of a house into a GUI, more precisely JTextarea. What\'s the simplest way of doing so? Not quite grasped data input yet.



        
相关标签:
1条回答
  • 2021-01-29 08:58

    JTextArea has a simple append method that should make it easy to append the results

    For example...

    for(int i=0; i< myHouse.length; i++){
        if(myHouse[i]!=null){
            textArea.append("Year: ");
            textArea.append(Integer.toString(myHouse[i].getYear()));
            textArea.append(".  Size: ");
            textArea.append(Integer.toString(myHouse[i].getSize()));
            textArea.append("\n");
        }
    }
    

    Take a look at How to use text areas for more deatils

    0 讨论(0)
提交回复
热议问题