0

Im using netbeans with design (palette). I want to show my output console into GUI in netbeans. So here is my code that I want to execute. I put this to button function, and it works. But I the result show up in output console, I intention to show it in the interface too.

User user = status.getUser();
            Date dated = status.getCreatedAt();
            PreparedStatement stmt = null;
            Connection conne = null;
            try {
                Class.forName("com.mysql.jdbc.Driver");
                System.out.println("Connecting to database...");
                conne = DriverManager.getConnection("jdbc:mysql://localhost/jat?useUnicode=true&characterEncoding=UTF-8", "root", "");
                System.out.println(status);
                System.out.println("Inserting records into the table...");
                stmt = conne.prepareStatement("set names 'utf8'");
                stmt.execute();
                stmt = conne.prepareStatement("set character set utf8");
                stmt.execute();
                stmt = conne.prepareStatement("INSERT INTO tweet(ID,date,name,statusLocation,text,source) VALUES (?,?,?,?,?,?)");
                stmt.setInt(1, (int) status.getId());
                stmt.setString(2, getTimeStamp());
                stmt.setString(3, status.getUser().getScreenName());
                stmt.setString(4, user.getLocation());
                stmt.setString(5, status.getText());
                stmt.setString(6, status.getSource());
                stmt.executeUpdate();
                System.out.println("this record inserted!");
                System.out.println("==================");
            } catch (SQLException se) {
                se.printStackTrace();
            } catch (final Exception e) {
                e.printStackTrace();
            }
        }
        @Override
        public void onTrackLimitationNotice(int arg0) {
        }
        @Override
        public void onStallWarning(StallWarning sw) {
            throw new UnsupportedOperationException("Not supported yet."); 
        }
    };       
    FilterQuery fq = new FilterQuery();
    double lat1 = 121.300000d;
    double long1 = 25.020000d;
    double lat2 = 121.380000d;
    double long2 = 25.030000d;
    twitterStream.addListener(listener);
    double[][] bb = {{lat1, long1}, {lat2, long2}};
    fq.locations(bb);
    twitterStream.filter(fq);}

When the 'run' button executed, the result just displayed in the output console, not in my interface.

And this is my interface look like: enter image description here

Thank you so much for any reply

razin kac
  • 17
  • 1
  • 7
  • It shows in the console because you send it to the console: System.out.println(), if you want to display it in your graphical element, you need to call the element's method which will display your text – Barbe Rouge Oct 14 '15 at 10:58
  • sorry it seems different. I dont know. thank you, Barbe – razin kac Oct 14 '15 at 11:58

2 Answers2

1

What you want to do is to use jTextarea or jtextfield or in my case i used jlabels to display my output to the console ..

For example : If i have my result in my result variable use this result variable to set your output like

this.jLabel1.setText(Result); //This show out in the GUI where you put your label

similarly same case with other elements

this.jTextField1.setText(Result);

Farrukh Faizy
  • 1,203
  • 2
  • 18
  • 30
0

Replace the calls to System.out.println with jTextArea1.append where jTextArea1 is the name of whatever that TextArea is in your interface. You may also want to add a \n to end of each string.

WillShackleford
  • 6,918
  • 2
  • 17
  • 33