Menu

How can I include this in another Swing frame

Help
Payam Fard
2007-03-30
2012-09-14
  • Payam Fard

    Payam Fard - 2007-03-30

    I have a swing application and want to have one of the frames within my application show an RSS feed based on a user selection. I have downloaded and added the jar file to my classpath, but I cannot integrate this with my Swing application. I have created an exact replica of JRSST.java in my project, but I cannot get it to compile. It basically cannot find any of the classes that JRSST.java uses but is included in the jar file. I cannot import them either because they are not part of any pckages. Any ideas how I can fix this?

    Thanks in advance.

     
    • DrB80

      DrB80 - 2007-03-30

      As of today, jrsst isn't organized to allow it to reside in another frame. I'm happy to do some reorganization so that it can. It will probably take a week or so. At that point, i can put the new version up and you can see if it works for you. If you want to look at the source, it comes in the jar file. Just 'jar xf JRSST*.jar' and you should be able to see everything. Thanks!

       
    • Payam Fard

      Payam Fard - 2007-04-13

      Have you had a chance to reorganize the code to be able to include it in another frame?

       
      • DrB80

        DrB80 - 2007-04-14

        Yep. I'm testing it now. I'll post a beta version today or tomorrow. Thanks!

         
    • DrB80

      DrB80 - 2007-04-15

      Beta version posted and CVS updated. A number of packages created to facilitate incorporation into other programs. One should be able to:

      import edu.mscd.cs.jrsstlabel.JRSSTLabel;
      [...]
      JRSSTLabel label = new JRSSTLabel (args);
      label.doit ();

      Let me know if this is what you were looking for and if it works for you. Thanks!

       
      • Payam Fard

        Payam Fard - 2007-04-20

        Thanks for the code update.

        I am getting the following exception message when running the code. What am I doing incorrectly?

        Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and height (0) must be non-zero
        at java.awt.image.ReplicateScaleFilter.<init>(ReplicateScaleFilter.java:85)
        at java.awt.image.AreaAveragingScaleFilter.<init>(AreaAveragingScaleFilter.java:60)
        at java.awt.Image.getScaledInstance(Image.java:152)
        at edu.mscd.cs.jrsstlabel.JRSSTLabel.setThisIcon(JRSSTLabel.java:175)
        at edu.mscd.cs.jrsstlabel.JRSSTLabel.loop(JRSSTLabel.java:202)
        at edu.mscd.cs.jrsstlabel.JRSSTLabel.doit(JRSSTLabel.java:244)
        at mine.TestReader.<init>(TestReader.java:28)
        at mine.TestReader.main(TestReader.java:43)

        Here is the code:

        package mine;

        import edu.mscd.cs.jrsstlabel.JRSSTLabel;

        import javax.swing.JFrame;

        public class TestReader extends JFrame {

        public TestReader(String feeds[]) {
            super();
        
            JRSSTLabel label = new JRSSTLabel(feeds);
            label.doit ();
            this.add(label);
        
            this.pack();
            this.setVisible(true);
            this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);   
        }
        
        public static void main(String args[]) {
        
            java.util.ArrayList feeds = new java.util.ArrayList();
        
            feeds.add(&quot;http://rss.cnn.com/rss/cnn_world.rss&quot;);
            feeds.add(&quot;http://rss.cnn.com/rss/si_topstories.rss&quot;);
        
            TestReader reader = new TestReader((String[])feeds.toArray(new String[feeds.size()]));
        }
        

        }

         
        • DrB80

          DrB80 - 2007-04-23

          it seems Java doesn't know the size of the frame here. this works for me, let me know if it doesn't for you. thanks!

          package mine;

          import edu.mscd.cs.jrsstlabel.JRSSTLabel;

          import javax.swing.JFrame;

          public class TestReader extends JFrame
          {
          public TestReader(String feeds[])
          {
          super();

              JRSSTLabel label = new JRSSTLabel(feeds);
          
              getContentPane().add (label);
              pack();
              setVisible(true);
              setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
          
              label.doit ();
          }
          
          public static void main(String args[])
          {
              TestReader reader =
                  new TestReader (new String[]
                      {&quot;http://rss.cnn.com/rss/cnn_world.rss&quot;,
                      &quot;http://rss.cnn.com/rss/si_topstories.rss&quot;});
          }
          

          }

           

Log in to post a comment.