Please be aware of the following forum rule:
Do provide evidence of having done some work yourself if posting questions from school or work assignments
Post your code and specific questions about what is troubling you and what you have tried.
Please be aware of the following forum rule:
Do provide evidence of having done some work yourself if posting questions from school or work assignments
Post your code and specific questions about what is troubling you and what you have tried.
You didn't provide CollegeMember with a zero-argument constructor, which your Lecturer constructors are trying to call implicitly.
Netbeans, Eclipse, and IntelliJ IDEA are all widely used tools.
You miss my point. A NullPointException occurs when you attempt to call a method on or otherwise access an object reference that has not been initialized. I can guess pretty easily what 'lstEvents' is but that doesn't address whether or not that you initialized it. You need to verify that.
Is it possible that 'lstEvent' is null? That is where you should start with any NullPointerException.
assertEquals() would not apply here since you aren't testing equality. Take a look at the other assert methods and find one that could assert your condition.
Assert that the absolute value of the difference is less than your threshold.
I'm not sure what to tell you then, because I took this fragment that you posted earlier this works just fine with both my pattern and Taywin's
String holder = "<div id=\"mess130268\" class=\"mChatBG2 mChatHover\"><span style=\"float:left;\"><a class=\"mChatScriptLink\" href=\"javascript<b></b>://\" onclick=\"insert_text('@ Run You Camper, ', false);\" title=\"Respond to user\"><span style=\"color: #ffFF15\"><strong>@</strong></span></a> <a href=\"./memberlist.php?mode=viewprofile&u=18216\" style=\"color: #ffFF15;\" class=\"username-coloured\">Run You Camper</a> - Fri Oct 28, 2011 9:17 am</span><span style=\"float:right;\"><input type=\"hidden\" id=\"edit130268\" value=\"me n him brought down a whole igc lobby ourselves... :D\" /> <a href=\"javascript<b></b>://\" onclick=\"mChat.del('130268');\"><img src=\"./mchat/del.gif\" alt=\"Delete\" title=\"Delete\" class=\"mChatImage\" /></a></span><br /><div class=\"mChatMessage\">me n him brought down a whole igc lobby ourselves... <img src=\"./images/smilies/icon_e_biggrin.gif\" alt=\":D\" title=\"Very Happy\" /></div></div> "+
" "+
" <div id=\"mess130269\" class=\"mChatBG1 mChatHover\"><span style=\"float:left;\"><a class=\"mChatScriptLink\" href=\"javascript<b></b>://\" onclick=\"insert_text('@ Run You Camper, ', false);\" title=\"Respond to user\"><span style=\"color: #ffFF15\"><strong>@</strong></span></a> <a href=\"./memberlist.php?mode=viewprofile&u=18216\" style=\"color: #ffFF15;\" class=\"username-coloured\">Run You Camper</a> - Fri Oct 28, 2011 9:17 am</span><span style=\"float:right;\"><input type=\"hidden\" id=\"edit130269\" value=\"then godfather dashboarded cuz of it and ended game 30 secs early. -.- lol\" /> <a href=\"javascript<b></b>://\" onclick=\"mChat.del('130269');\"><img src=\"./mchat/del.gif\" alt=\"Delete\" title=\"Delete\" class=\"mChatImage\" /></a></span><br /><div class=\"mChatMessage\">then godfather dashboarded cuz of it and ended game 30 secs early. -.- lol</div></div>";
Pattern pattern = Pattern.compile("value=\"(.+?)\" />");
//Pattern.compile("value=\"([^\"]*)\"", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(holder);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
I can't speak for any data other than that tested.
This works perfectly fine for me
String holder = "value=\"Hey there... blah blah\" /><more /><asd value=\"another\" /><more><asdf value=\"third line\" />";
Pattern pattern = Pattern.compile("value=\"(.+?)\" />");
Matcher matcher = pattern.matcher(holder);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
Group 1 is the portion of the match string that you were wanting to capture.
Ok, my bad, my over-escaping caution has led this astray. Just use Pattern.compile("value=\"(.+?)\" />");
@aanders5: Change \\>
to just />
and add the question mark in (.+?)
The "=" and ">" don't need to be escaped.
True. I've gotten overly cautious about escaping all reserved characters in the expressions, but evidently it's okay with those as written even though = and > are used in some pattern constructs.
But the problem with the regex above is that it will grab the last " it sees in the string.
My last change above to use (.+?) should resolve that.
Just go through your string and add a backslash escape for each backslash and quote you are using in your expression. You'll have to get used to this at some point. Escaping regex pattern literals is a pain :)
Also note that I corrected my original pattern to use the forward slash in front of the ">".
I think you'll also want to use a reluctant qunatifier to keep it from grabbing multiple elements, so instead of (.+)
use (.+?)
And what is the error?
Edit: You have to escape all of the "
and \
with additional \
in your string.
Well, the simplest case regex would be something like value\=\"(.+)\" /\>
You would retrieve your text from group 1. Of course, you may have to tune that for variability.
Edit: Oops, used the wrong direction slash. Corrected.
Are you asking what the regex would be or do you already have an expression that you are trying to tune?
Have you thought about trying one of the many HTML parsing packages like http://mozillaparser.sourceforge.net/, http://jtidy.sourceforge.net/, http://htmlparser.sourceforge.net/ ?
Are you going to ask an actual question or just hope someone wants to read all your code and try to figure out what it does and does not do?
You're trying to access the third element of array[] and it doesn't have that many elements. Don't do that.
You're setting winner from the fourth column
int Winner = rs.getInt(4);
but winner is the fifth column your data set. Contrary to most any other indexing in Java, in ResultSet the first column is 1, not 0.
i just don't know how to use color constructor
Just remove this line
public void Color(int r,int g,int b);
and this line
c = Color.magenta;
Your initial declaration is just fine.
Keep in mind rs.next()
advances the result set, so when you call that again in your while() loop you're skipping over the first record to the next.
Why this on line 120?
if (!rs.next()) {
You don't want that block to execute if the query has results?
Don't define your class to be in java.lang package.
@jQuery: The forums aren't here for you to promote your blog posts.
Thread closed.
> But the later work was really quite good
I don't believe that the later work was his own any more than the first "attempt", which was directly copied from a book. He did not even have the TemperatureInfo class and merely copied yours into his program.
> Does this Code answer that question?
If you can't tell, you need to stop wasting peoples' time here.
See what you can come up with and ask specific questions about what you are having trouble with. What you posted above is a direct copy of code you found elsewhere, so that's not going to cut it.
@hfx642: No, the situation you describe would not compile. The variable would have no scope outside the method in which it was declared. It would complain "Cannot find symbol"
Just below the text "Has this thread been answered?" there is a link to "Mark this Thread as Solved".
This example app from the tutorials seems applicable:
http://xuggle.wordpress.com/2009/01/23/how-to-use-xuggler-to-decode-and-play-video/
They are updating a VideoImage frame with a BufferedImage from the stream. VideoImage just extends JFrame, so you could probably either look at that source or override paintComponent(Graphics) on a JPanel of your own and render the BufferedImage on that panel with drawImage().
Moving to JavaScript.
> Any suggestions?
Sure, start reading their tutorials on the site.
And you can always start with the basic tutorial:
http://download.oracle.com/javase/tutorial/java/concepts/index.html
This thread was just sock-puppet promotion for a particular product by Jones_nash and Shamrocks. Those posts have been deleted, but I will leave the rest of the replies up for the benefit of others.
Closed.
Post the code that you do have and ask specific questions.
From our forum rules:
Keep It Organized - Do provide evidence of having done some work yourself if posting questions from assignments.
This was already answered in the OP's other thread for the same question but he chose to ignore the answers:
http://www.daniweb.com/software-development/java/threads/384210/1654757#post1654757
It worked fine when I set the colors after creating the chart with JFreeChart chart = ChartFactory.createXYLineChart(...
and then got the plot reference with XYPlot plot = chart.getXYPlot();
Give that a try and see if it helps.
I didn't say remove it - I said it may be the wrong one. Spelling counts.
Take a closer look at line 56 and note which method you are calling. It may not be the one you want.
Actually, on line 93 you are declaring a new variable "stkBean" which immediately goes out of scope in your loop.
StkBean stkBean = new StkBean();
Remove the declaration from that and just assign the new instance to your class-level stkBean reference.
Your current code is still using the single instance of stkBean that you initialized at declaration.
Alternately, you could move line 93 up to the beginning of the loop and do away with the class-level variable altogether. You don't have any use for stkBean other than adding to the arraylist.
while (results.next() )
{
StkBean stkBean = new StkBean();
//myList.add((results.getString(1)).trim() );
stkBean.setStkSymbol(results.getString((1)).trim () );
stkBean.setCompanyName(results.getString((2)).trim() );
stkList.add(stkBean);
}//end do-while
Edit: Also, you may want to either override toString() in your StkBean class or print one of the properties like getCompanyName() in your option list output.
Are you creating a new StkBean each iteration of your loop to add to the array list?
Ok, there is no way I'm going to try to trace that mess of meaningless variable names, but I will say that all you need is a List or Set to keep the numbers you have already encountered and the String.replace() method.
In fact, you only need the list if you want to retain a listing of the unique numbers. If you just want to cleanse repetitions, all you need to do is loop forward and remove them.
You don't want to create a new Date to compare to "d". You want to use the current instance value.
Yes, you declared the variable on line 27, but you haven't actually initialized it prior to using it. You still have to create an instance of new StkBean()
before you can assign any values to it.
I don't see where you have initialized "stkBean" prior to that line.
It seems rather lazy and unproductive to me.
You could have tried it out yourself first and then if it didn't work you could have posted "Hey, I tried this... but it gave me this... what do I need to change?" If it did work, you could focus directly on the other query without taking up any more time on the first.
That makes no sense at all.
Why not type the code into a simple query against your data and see if it works before you post it to a forum and ask others if it looks right?
Per our forum rules:
Keep It Organized - Do provide evidence of having done some work yourself if posting questions from assignments.
Sorry Didnt Tried It Yet
Why bother to post this at all then? If you aren't willing to even try out any code on your own, why should others spend their time on it?