0

I am trying to display rss feed entries in a JEditorPane with the setText method of the JEditorPane, in a method which gets the relevant information (the RSSEntries).

In this method I get the items that are to be posted in a stringBuilder, which works fine so far. However when, at the end of the method, I try to set the text from the stringBuilder to the JEditorPane, it does not post anything. I have tried to output the contents of the stringbuilder with println and the text does work but not when I set it to the JEditorPane. I also have tried to set up a setText method of my own in which I pass the string builder as a parameter and then from within the relevant class try to set it with a get method like this m_editorPane.setText(getText());… The get method gets the right information but this procedure does not set the text on the JEditorPane either …. Can any one point me in to the right direction? it seems that I am missing something ...? Thank you

    public void  createEditorInfo(ArrayList<Item> items)
        throws MalformedURLException {

    StringBuilder sb = new StringBuilder();

    String url = m_urlName;

    if (m_urlName != null) {
        if ((items != null) && !(url.equals(null))) {

            // create a new parser
            m_parser = new Parser();

            //set url name
            m_parser.setM_urlName(m_urlName);

            // start the parsing process
            m_parser.start();

            ItemList itemList = new ItemList();

            // put rss entries into a list
            itemList.setItem(items);

            System.out.println("the item list is: " + itemList.getLength());

            // /output the contents of the feed
            for (int element = 0; element < itemList.getItem().size(); element++) {

                sb.append(itemList.getItem().get(element).getTitle()
                        + itemList.getItem().get(element).getDescription()
                        + itemList.getItem().get(element).getM_myURL()
                        + " <br>");

            } // end for 
            System.out.println("sb from createEditorInfo is : "  //This works just fine 
                    + sb.toString());

            // Create editor pane
            m_editorPane = new JEditorPane();
            m_editorPane.setContentType("text/html");
            m_editorPane.setEditable(false);

            // add put the m_editorPane in a JScrollPane for scrolling function
            m_editorPaneScrollpane = new JScrollPane(m_editorPane);
            m_editorPaneScrollpane
                    .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
            m_editorPaneScrollpane.setAutoscrolls(true);
            m_editorPaneScrollpane.setEnabled(true);
            m_editorPaneScrollpane.setVisible(true);
            m_editorPaneScrollpane.setMinimumSize(new Dimension(100, 30));

            m_editorPane.setText(sb.toString()); //This does not work
        }
    }
}
mKorbel
  • 109,525
  • 20
  • 134
  • 319
bluetxxth
  • 121
  • 2
  • 16

0 Answers0