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
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
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)
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.<div class="feedflare">
<a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=j6L8eXQWUIk:Pqkyy5dEj-8:V_sGLiPBpWU" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=qj6IDK7rITs" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=j6L8eXQWUIk:Pqkyy5dEj-8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=j6L8eXQWUIk:Pqkyy5dEj-8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/rss/cnn_topstories/~4/j6L8eXQWUIk" height="1" width="1"/></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:
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.
What layout are you using?
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
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
CarjMenu2:
Schwinn
MercedesjMenu3:
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
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)
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