开发者

append JTextArea & invokelater()

开发者 https://www.devze.com 2023-04-12 21:33 出处:网络
I need some help on this one please, i basically have menuVIP.java, and vipKeyword.java. This is menuVIP.java

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() {
 开发者_Go百科                       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


public String keyword(String keyword) {
     final menuVIP vip = new menuVIP(); // mark it as final

...

 SwingUtilities.invokeLater(new Runnable() { 
    //menuVIP vip = new menuVIP();   // comment it
0

精彩评论

暂无评论...
验证码 换一张
取 消