private HBox addHBox() {
HBox hbox = new HBox();
hbox.setPadding(new Insets(15, 12, 15, 12));
hbox.setSpacing(10); // Gap between nodes
hbox.setStyle("-fx-background-color: #336699;");
TextField txtSearch = new TextField ();
Button btnSubmit = new Button("Submit");
hbox.getChildren().addAll(txtSearch, btnSubmit);
return hbox;
} }
this show my button code on an class and i want to use that button on another class.
Basically, this is the code in my another class and i want to link BtnSubmit on this class, how should i do it?
ConfigurationBuilder configBuilder = new ConfigurationBuilder();
configBuilder.setOAuthConsumerKey("");
configBuilder.setOAuthConsumerSecret("");
configBuilder.setOAuthAccessToken("");
configBuilder.setOAuthAccessTokenSecret("");
//Create instance of Twitter for searching etc.
TwitterFactory tf = new TwitterFactory(configBuilder.build());
Twitter twitter = tf.getInstance();
btnSubmit.setOnAction((javafx.event.ActionEvent event) -> {
Query query = new Query(txtSearch.getText());
query.setLang("en");
QueryResult result;
query.setCount(100);
int count = 0;
try {
result = twitter.search(query);
List<Status> tweets = result.getTweets();
for (Status tweet : tweets) {
String userName = tweet.getUser().getName();
long userId = tweet.getUser().getId();
//Date creationDate = tweet.getCreatedAt();
String tweetText = tweet.getText();
count++;
System.out.println("Tweet created by " + userName + "(" + userId + ")" + count);
System.out.println("Tweet text " + tweetText);
}
}
catch(TwitterException ex){
}
});