Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pakk;
- import javafx.fxml.FXML;
- import javafx.scene.control.*;
- import javafx.scene.layout.VBox;
- import org.xml.sax.SAXException;
- import javax.xml.parsers.ParserConfigurationException;
- import java.io.IOException;
- import java.util.ArrayList;
- public class Controller {
- @FXML
- public TextField urlBox;
- public TextArea textBox1;
- public ScrollPane container;
- public TextField authorBox;
- @FXML
- private void handleButtonAction() throws ParserConfigurationException, SAXException, IOException {
- ArrayList<News> news = (ArrayList<News>) XMLreader.readXML(urlBox.getText());
- Hyperlink[] links = new Hyperlink[news.size()];
- VBox newsTitles = new VBox();
- for (int j = 0; j < news.size(); j++) {
- links[j] = new Hyperlink(news.get(j).getTitle());
- links[j].setWrapText(true);
- links[j].setPrefWidth(container.getPrefWidth()-15);
- newsTitles.getChildren().add(links[j]);
- String desc = news.get(j).getDescription();
- String author = news.get(j).getAuthor();
- links[j].setOnAction(event -> {
- textBox1.setText(desc);
- authorBox.setText(author);
- });
- }
- container.setContent(newsTitles);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement