追加 JTextArea &稍后调用()

发布于 2024-12-09 17:36:24 字数 1543 浏览 0 评论 0原文

我需要一些关于这个的帮助,

我基本上有menuVIP.java和vipKeyword.java。

这是 menuVIP.java

if (source == enter2) {
            Thread blah = new Thread() {
                String keyword = keyfield.getText();
                public void run() {
                    final String result;
                    vipKeyword vipK = new vipKeyword();
                    result = vipK.keyword(keyword);
                }

            };

            blah.start();

这是 vipKeyword.java

public class vipKeyword {

public String keyword(String keyword) {
    menuVIP vip = new menuVIP();

    String password;
    String tbl;
    String Final = null;
    int dot;
    try {

        databaseConnection dbC = new databaseConnection();
        dbC.connection();

        PreparedStatement prep2 = dbC.conn.prepareStatement("SELECT * "
                + "FROM Vip_tbl");
        ResultSet rs = prep2.executeQuery();

        while(rs.next()) {
            cellnumber = rs.getString(1);
            try {
            final String cell;
            cell = cellnumber;
                    SwingUtilities.invokeLater(new Runnable() {
                        menuVIP vip = new menuVIP();
                        public void run() {
                            vip.ta.append(cell + "\n");
                            vip.ta.repaint();
                        }

                    });
return keyword;
}

我需要知道的是如何在 SwingUtilities.invokelater() 中“附加”我的 vipKeyword 中的 Jtextarea?

注:ta = JTextArea

I need some help on this one please,

i basically have menuVIP.java, and vipKeyword.java.

This is menuVIP.java

if (source == enter2) {
            Thread blah = new Thread() {
                String keyword = keyfield.getText();
                public void run() {
                    final String result;
                    vipKeyword vipK = new vipKeyword();
                    result = vipK.keyword(keyword);
                }

            };

            blah.start();

And this is vipKeyword.java

public class vipKeyword {

public String keyword(String keyword) {
    menuVIP vip = new menuVIP();

    String password;
    String tbl;
    String Final = null;
    int dot;
    try {

        databaseConnection dbC = new databaseConnection();
        dbC.connection();

        PreparedStatement prep2 = dbC.conn.prepareStatement("SELECT * "
                + "FROM Vip_tbl");
        ResultSet rs = prep2.executeQuery();

        while(rs.next()) {
            cellnumber = rs.getString(1);
            try {
            final String cell;
            cell = cellnumber;
                    SwingUtilities.invokeLater(new Runnable() {
                        menuVIP vip = new menuVIP();
                        public void run() {
                            vip.ta.append(cell + "\n");
                            vip.ta.repaint();
                        }

                    });
return keyword;
}

What i need to know is how to "append" the Jtextarea from my vipKeyword in the SwingUtilities.invokelater()?

Note: ta = JTextArea

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一曲琵琶半遮面シ 2024-12-16 17:36:24
public String keyword(String keyword) {
     final menuVIP vip = new menuVIP(); // mark it as final

...

 SwingUtilities.invokeLater(new Runnable() { 
    //menuVIP vip = new menuVIP();   // comment it
public String keyword(String keyword) {
     final menuVIP vip = new menuVIP(); // mark it as final

...

 SwingUtilities.invokeLater(new Runnable() { 
    //menuVIP vip = new menuVIP();   // comment it
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文