Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, this is a complete JavaFX program that prints out tweets from a timeline. I have a problem displaying results in the scene of my

Hello, this is a complete JavaFX program that prints out tweets from a timeline. I have a problem displaying results in the scene of my JavaFX app. Can anyone help me?

 import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.FlowPane; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.Button; import javafx.geometry.Insets; import javafx.event.ActionEvent; import javafx.event.EventHandler; import java.util.List; import twitter4j.*; import java.util.ArrayList; // import twitter4j.Status; // import twitter4j.TwitterException; // import twitter4j.TwitterFactory; import twitter4j.conf.ConfigurationBuilder; public class Client extends Application { // GUI controls private TextField tfSearch; private Button btnSearch; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { // Window title primaryStage.setTitle("Twitter Client"); // Search text field tfSearch = new TextField(); tfSearch.setPrefColumnCount(20); tfSearch.setPromptText("Enter a search string"); // Search button btnSearch = new Button("Search"); // Handle button event btnSearch.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { try { searchTwitter(tfSearch.getText()); } catch (TwitterException e) { e.printStackTrace(); } } }); primaryStage.show(); // Pane FlowPane pane = new FlowPane(); pane.setHgap(5); pane.setVgap(5); pane.getChildren().addAll(new Label("Search:"), tfSearch, btnSearch); pane.setPadding(new Insets(10, 10, 10, 10)); // Scene Scene scene = new Scene(pane, 400, 300); primaryStage.setScene(scene); primaryStage.show(); } public static void searchTwitter(String searchString) throws TwitterException { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setDebugEnabled(true); configurationBuilder.setOAuthConsumerKey(""); configurationBuilder.setOAuthConsumerSecret(""); configurationBuilder.setOAuthAccessToken(""); configurationBuilder.setOAuthAccessTokenSecret(""); //configurationBuilder.setUseSSL(true); TwitterFactory tf = new TwitterFactory(configurationBuilder.build()); twitter4j.Twitter twitter = tf.getInstance(); try { ResponseList a = twitter.getHomeTimeline(new Paging(1, 5)); for (Status b : a) { System.out.println(b.getText()); } } catch (Exception e) { System.out.println(e); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Programming questions

Question

List three benefits of using a to-do list.

Answered: 1 week ago

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago

Question

Write a note on job design.

Answered: 1 week ago

Question

What are bounds and what do companies do with them?

Answered: 1 week ago