每次点击都会设置文本Jtextarea

时间:2014-03-20 22:24:02

标签: java jbutton

每次点击jButton时我想写一个jtextarea。我不知道该怎么做,因为我这样做只会打印一行。

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    Calendar calendar = Calendar.getInstance();

    int hours = calendar.get(Calendar.HOUR_OF_DAY);
    int minutes = calendar.get(Calendar.MINUTE);
    int seconds = calendar.get(Calendar.SECOND);

    jTextArea1.setText("Comienza el partido...." + hours + ":" + minutes + ":" + seconds
            + ":\n");

    jTextArea1.setText("Resultado:" + "  " + marcador1.MLocal() + "  " + marcador1.MVisitante()
            + "  " + hours + ":" + minutes + ":" + seconds + "\n");

}

我想要那样的东西:

Match start!

local 1 -visitant 0

local 2-visitant 0

local 2-visitant 1

Thank you !

1 个答案:

答案 0 :(得分:1)

我想你问的是如何将文本附加到JTextArea,而不是每次都调用setText()来替换它。

您可以拨打append()