KirkPatrick 28 Junior Poster

Haven't really dealt with this before, but have you tried:

JFrame.HIDE_ON_CLOSE

Not sure if the results will be different. Might have the main JFrame dispose of them both on exit

KirkPatrick 28 Junior Poster

I'm not quite sure I understand your question exactly, but when you are overriding something there are infinite possibilities depending on what you are wanting to do.

For instance, I have an object and I want to change how toString() works instead of just giving me random information. Lets say I want it to actually print out the information in it with commas between the values. The code would look like so:

@Override
public String toString() {
        StringBuffer b = new StringBuffer();
        b.append(getStringA() + "," + getStringB() + "," + getStringC());
        return b.toString();
    }

To my knowledge no, there isn't only one way to code an override. It really depends on what you want to do with it. You will however need the @Override though.

Now specifically for Overriding .equals() so that it compares objects or values of objects, most code will probably be similar.


(if my post is inaccurate or one feels the need to elaborate feel free to post so, constructive criticism is a great learning tool)

KirkPatrick 28 Junior Poster

I actually started a small html parser not long ago (never did get too specific with it, but was hoping on expanding it)

Just a short snippet I pulled out from the link you are pulling the feed from:

<title>Reclusive author J.D. Salinger dies</title>

<guid isPermaLink="false">http://www.cnn.com/2010/SHOWBIZ/books/01/28/salinger.obit/index.html?eref=rss_topstories</guid>
<link>http://rss.cnn.com/~r/rss/cnn_topstories/~3/j6L8eXQWUIk/index.html</link>
<description>J.D. Salinger, author of "The Catcher in the Rye" and other books, has died, according to his literary agent. He was 91.&lt;div class="feedflare"&gt;
&lt;a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=j6L8eXQWUIk:Pqkyy5dEj-8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=j6L8eXQWUIk:Pqkyy5dEj-8:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;

&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/rss/cnn_topstories/~4/j6L8eXQWUIk" height="1" width="1"/&gt;</description>
<pubDate>Thu, 28 Jan 2010 14:55:47 EST</pubDate>
<feedburner:origLink>http://www.cnn.com/2010/SHOWBIZ/books/01/28/salinger.obit/index.html?eref=rss_topstories</feedburner:origLink></item>

Just off a glance, it looks like you are wanting to pull out everything between the <description> desired text/string </description>

I am about to leave, but perhaps I can get back to this post tomorrow, for the mean time (im not sure how helpful this will be to you) but check out the thread I created when I was parsing some html:

http://www.daniweb.com/forums/thread236349.html

KirkPatrick 28 Junior Poster

So that would probably be free design, have you thought about trying a different layout? I prefer gridbaglayout because it allows you to set what you want by weight which is very helpful for keeping things in place.

KirkPatrick 28 Junior Poster

What layout are you using?

KirkPatrick 28 Junior Poster

Are you wanting to stick with a certain layout? Or are you willing to try out other layouts? If you are, you could use a gridBagLayout and set the x and y weight to how you are wanting it to adjust.

I believe that will do what you are looking for, if I read you correctly

KirkPatrick 28 Junior Poster

My question is that instead of reading to the console how would I get this informaton into the JMenus.

Are you wanting to have 3 jMenus reading like so:

jMenu1:
Bike
Car

jMenu2:
Schwinn
Mercedes

jMenu3:
45.00
98,000

If thats how you are wanting them split, then split them using "," and specify each column, perhaps save each to an arraylist, and then have your menus get the value based on column.


*edit*
Here is an example snippet to help you understand

BufferedReader reader = new BufferedReader(new FileReader("C:\\myfile.fileExtension"));

        ArrayList<String> list1 = new ArrayList<String>();

        try {
            //this checks for headers, if you dont have them, ignore this part
            boolean bHeadersDone = false;
            while (reader.ready()) {
                String headerInfo = reader.readLine();

                if (!bHeadersDone) {
                    if (headerInfo.contains("Your last header here")) {
                        bHeadersDone = true;
                    }
                }
                else {
                    //splitting file into 3 columns
                    String[] info = list1Info.split("," , 3);
                    Column1Info = info[0];
                    Column2Info = info[1];
                    Column3Info = info[2];
                    
                    //adding columns to arraylist
                    if(!list1.equals(0)) {

                        list1.add(itemA);
                        list1.add(itemB);
                        list1.add(itemC);

                        //do what you want here
                        //maybe add them to jMenu here
                        //catch exceptions

I hope that helps a little bit

KirkPatrick 28 Junior Poster

Posting the exact exceptions might be helpful to those who are wanting to help you. (i didn't see them posted, but could have missed them. If they aren't in your post, add them and it should help in getting a response)

KirkPatrick 28 Junior Poster

Not to hijack this thread, but is there a way to do what his original question is asking? Reading two files at the same time? The reason I ask is because I am wanting to compare two text files and then write the new information to one file