Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. package pakk;
  2.  
  3. import javafx.fxml.FXML;
  4. import javafx.scene.control.*;
  5. import javafx.scene.layout.VBox;
  6. import org.xml.sax.SAXException;
  7. import javax.xml.parsers.ParserConfigurationException;
  8. import java.io.IOException;
  9. import java.util.ArrayList;
  10.  
  11. public class Controller {
  12.  
  13. @FXML
  14. public TextField urlBox;
  15. public TextArea textBox1;
  16. public ScrollPane container;
  17. public TextField authorBox;
  18.  
  19.  
  20. @FXML
  21. private void handleButtonAction() throws ParserConfigurationException, SAXException, IOException {
  22.  
  23. ArrayList<News> news = (ArrayList<News>) XMLreader.readXML(urlBox.getText());
  24. Hyperlink[] links = new Hyperlink[news.size()];
  25. VBox newsTitles = new VBox();
  26.  
  27. for (int j = 0; j < news.size(); j++) {
  28.  
  29. links[j] = new Hyperlink(news.get(j).getTitle());
  30. links[j].setWrapText(true);
  31. links[j].setPrefWidth(container.getPrefWidth()-15);
  32. newsTitles.getChildren().add(links[j]);
  33. String desc = news.get(j).getDescription();
  34. String author = news.get(j).getAuthor();
  35.  
  36. links[j].setOnAction(event -> {
  37. textBox1.setText(desc);
  38. authorBox.setText(author);
  39. });
  40. }
  41.  
  42. container.setContent(newsTitles);
  43. }
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement