Java 由6个项组成的数组,所有项都进入JTable的一个单元格,而不是每个项进入单元格

Java 由6个项组成的数组,所有项都进入JTable的一个单元格,而不是每个项进入单元格,java,arrays,swing,jtable,2d,Java,Arrays,Swing,Jtable,2d,我有一个2d数组,我想在一个JTable中显示,但是当我尝试添加它时,会发生什么情况,即6个项目的每个数组从左到右添加到每个JTable单元格中,而不是6个项目中的每一个都在单独的单元格中。我尝试了许多不同的方法将数组放入JTable中,这是我最接近的方法 有人能帮我写代码吗 public static void main(String argv[]) throws SAXException, IOException, ParserConfigurationException, XMLS

我有一个2d数组,我想在一个JTable中显示,但是当我尝试添加它时,会发生什么情况,即6个项目的每个数组从左到右添加到每个JTable单元格中,而不是6个项目中的每一个都在单独的单元格中。我尝试了许多不同的方法将数组放入JTable中,这是我最接近的方法

有人能帮我写代码吗

public static void main(String argv[]) throws SAXException,
    IOException, ParserConfigurationException, XMLStreamException, XPathExpressionException {
    
    ArrayList<rollingS> s = new ArrayList<rollingS>();
    Hashtable<String,Hashtable<String,rollingS>> rowArray = new Hashtable<>();
    String fileName = "https://api.bmreports.com/BMRS/LATESTACCEPTS/v1?APIKey=xxxxxxxxx&ServiceType=XML";
    
    String xml = crunchifyGetURLContents(fileName);
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    XPath xPath =  XPathFactory.newInstance().newXPath();
    String expression = "/response/responseBody/responseList/item";    
    NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(document, XPathConstants.NODESET);
    
    for (int i = 0; i < nodeList.getLength(); i++) 
    {
    Node nNode = nodeList.item(i);
    
    if (nNode.getNodeType() == Node.ELEMENT_NODE) {
    Element eElement = (Element) nNode;
    String one = eElement.getElementsByTagName("recordType").item(0).getTextContent();
    String two = eElement.getElementsByTagName("bmuName").item(0).getTextContent();
    String three = eElement.getElementsByTagName("bidOfferAcceptanceNumber").item(0).getTextContent();
    String four = eElement.getElementsByTagName("acceptanceTime").item(0).getTextContent();
    String five = eElement.getElementsByTagName("fromTime").item(0).getTextContent();
    String six = eElement.getElementsByTagName("activeFlag").item(0).getTextContent();
    
    rollingS rollingS = new rollingS(one,two,three,four,five,six);
    
    
    s.add(rollingS);
    
    }
    
    }
    String students[] = { "S1", "S2", "S3", "S4", "S5", "S6"};
    int numberOfContacts = s.size()/6;
    Object[][] newArrayContent = new Object[numberOfContacts][6];
    for(int x = 0; x<numberOfContacts; x++){
    for(int z = 0; z < 6; z++){
    int y = 6 * x;
    newArrayContent [x][z] =    s.get(y+z); 
    System.out.println(newArrayContent [x][z].toString());
    
    }
    
    JTable table = new JTable(newArrayContent, students);
    
    
    
    Font font = new Font("Verdana", Font.PLAIN, 12);
    table.setFont(font);
    table.setRowHeight(30);
    JFrame frame = new JFrame();
    frame.setSize(600, 400);
    frame.add(new JScrollPane(table));
    frame.setVisible(true);
    
    }
    }
    
    
    
    private static String crunchifyGetURLContents(String oracle) 
    {
    System.out.println("https : " + oracle);
    StringBuilder sb = new StringBuilder();
    URLConnection urlConn = null;
    InputStreamReader in = null;
    try {
    URL url = new URL(oracle);
    urlConn = url.openConnection();
    if (urlConn != null)
    urlConn.setReadTimeout(60 * 1000);
    if (urlConn != null && urlConn.getInputStream() != null) {
    in = new InputStreamReader(urlConn.getInputStream(), Charset.defaultCharset());
    BufferedReader bufferedReader = new BufferedReader(in);
    if (bufferedReader != null) {
    int cp;
    while ((cp = bufferedReader.read()) != -1) {
    sb.append((char) cp);
    }
    bufferedReader.close();
    }
    }
    in.close();
    } catch (Exception e) {
    throw new RuntimeException("Exception while calling URL:" + oracle, e);
    }
    
    return sb.toString();
    }}
publicstaticvoidmain(字符串argv[])引发SAXException,
IOException、ParserConfiguration异常、XMLStreamException、XPathExpressionException{
ArrayList s=新的ArrayList();
Hashtable rowArray=新的Hashtable();
字符串文件名=”https://api.bmreports.com/BMRS/LATESTACCEPTS/v1?APIKey=xxxxxxxxx&ServiceType=XML";
字符串xml=crunchifyGetURLContents(文件名);
DocumentBuilderFactory工厂=DocumentBuilderFactory.newInstance();
DocumentBuilder=factory.newDocumentBuilder();
documentdocument=builder.parse(新的InputSource(新的StringReader(xml));
XPath=XPathFactory.newInstance().newXPath();
字符串表达式=“/response/responseBody/responseList/item”;
NodeList NodeList=(NodeList)xPath.compile(expression.evaluate(document,XPathConstants.NODESET);
for(int i=0;i