开发者

append JTextArea & invokelater()

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜