Write down your replacement progression through the loop on paper. I believe you'll see that you are holding the wrong value if you loop proceeds in a positive direction.
Of course, you don't necessarily have to loop in a positive direction either.
Write down your replacement progression through the loop on paper. I believe you'll see that you are holding the wrong value if you loop proceeds in a positive direction.
Of course, you don't necessarily have to loop in a positive direction either.
You are already doing most of those things. You just aren't doing them in the correct order as I outlined above.
You should construct all the boxes, add them to the "checkPanel", add "checkPanel" to the frame and then set it visible.
You need to set the alignment on the label. It's filling the scrollpane by default.
label.setVerticalAlignment(SwingConstants.TOP);
Try
jScrollPane1.setViewportView(new JLabel("Connecting to the database. Please wait...")
and when the table is ready
jScrollPane1.setViewportView(table);
You don't have to name the class, just the reference you're creating.
Thread t = new Thread()
{
@Override
public void run()
{
while(true)
{
//Update loop stuff
}
}
};
t.setDaemon(true);
t.start();
Yes, as Kramerd suggested, you'll need to create the Thread object, setDaemon(), and then start it.
The setDaemon() method is a void return, so you cannot chain it as you tried above. If setDaemon() returned a reference to itself then chaining would be possible.
Or just create your own small wrapper model.
Take a look at this section on using JList with a mutable model:
http://download.oracle.com/javase/tutorial/uiswing/components/list.html#mutable
> Recently i offered them to send them a couple of notes, and they never got back to me
Well, there is your answer then. If they ask, just don't get back to them.
The API says it all.
Good catch, James. I never saw that. I assumed it was a mutable model like the default combobox model.
It looks like you'll need to create your own model if you wish to add or remove items. You can read about that in the tutorial here.
It should be just a minor change to your existing code to use new JList(lmSeries);
since you're creating that model anyway.
You're parsing it as a double as soon as you read it. "Q" isn't a double.
It looks to me like your code should work just fine. Are you sure that you aren't resetting the model at some point after listSeries() has updated it? The add() method automatically fires an event that should keep your JList updated with the model.
Arrays do not have a "pop()" method - they are fixed storage. You can null out elements or shift them out of existence.
His comment was quite straightforward. Did you look up JLayer?
Yes, you would initialize based on the number of rows.
Re-reading your post: Do you mean that the error is getting past your catch? I may have misunderstood you with the previous comment.
> However, it doesn't work - the error message is generated for the empty set.
I assume you meant the error is not generated. An empty result doesn't throw an exception because it's a completely valid result - there simply are no records that match the query.
If your code needs to know that, you could either throw your own exception from the setQuery() method when the result is empty, or you could return a value from that method. It could return an int count of the records found or boolean to indicate at least one record was returned from that method.
You already have a section where you are updating the maxScore. You can update more than one thing in that if() block if you add some braces (which you should always use anyway).
You don't need to grab a previous string - you just need a new variable to hold the max score player name.
Update a variable 'maxScorePlayer' whenever you update the 'maxScore' variable.
It should only add the numbers in the line that you have passed it for that player. You will need to reset total to 0 between players.
Perhaps using while(parser.hasNextInt())
and parser.nextInt()
.
My point was that you mis-wrote your function trace value sec2(1-1) + 2 * 1 - 1
is 1 + 2 * 1 - 1
which equals 2, not 1.
> which is 0 + 2*1 -1
No. It is 1 + 2*1 - 1 => 2
seq2(0) returns 1, not 0.
Can you post your getValueAt() code?
In the comments on UPDATE, one guy mentions using the following work-around
UPDATE abm_downtime set
lost_time = now()
where lost_time = null
order by ID desc limit 1
You could give that a try I suppose.
I'm assuming you aren't actually using now()
for lost_time, right?
Yes, I found this buried in the manual
Currently, you cannot update a table and select from the same table in a subquery.
Very inconvenient.
Can you select the ID in a separate statement and then run your update?
You can't sub-select from the table you are updating? Did you check your parenthesis to make sure it didn't just parse it incorrectly?
Perhaps something like
update yourTable set time_lost=theValue where ID=(select max(ID) from yourTable) and time_lost is null
I don't work with MySQL specifically so there may be a slight syntax variation.
Did you make any changes in your getColumnClass() method? What prompted the class cast exception?
You might try changing this part of your model creation code
while (rs.next()) {
Object[] record = new Object[colCount];
for (int i = 0; i < colCount; i++) {
record[i] = rs.getObject(i + 1);
}
cache.addElement(record);
}
I'm not certain if you have an actual boolean coming from your rs.
You cannot simply make getColumnClass() return Boolean.class for that column because your data is a String value of "1" or "0". You need to store those values as booleans in your table model.
Well, it looks like all of your columns are currently String, because you have built them from the ResultSet using Strings for every value.
You could change the method that builds your table model to read the data type from the metadata and create an object of the appropriate type as you fill in the data. You also would need to change your 'record' array to Object[] instead of String[].
Using rs.getObject()
instead of getString()
might be viable as well, but if you are using 0 and 1 to represent your boolean values, they will most likely be read as Char or Integer and the default renderer will not be a check box.
As you can see, the tricky part is to keep your QueryTableModel as generic as possible and still translate those columns to the desired data type. If you hard-code the Boolean column in a particular location, you've tied your model to a specific data set - which is not necessarily a problem, but it will obviously limit it's re-use.
You probably need that method to return a Boolean object for the check box renderer.
You can either explicitly return the class for that column, or you can make sure that getValueAt() always returns a value for that column. I assume it's a boolean for the checkbox, so it needs to return true or false instead of a null.
You are getting a null value from getColumnClass, so I would look closer at what this method is returning from your model
public Class getColumnClass(int col) {
return getValueAt(0, col).getClass();
}
You have create an instance of Font first and use that in your setFont() call.
Take a look at the tutorial on using JTextArea.
They don't do anything because of lines 1 and 2.
You can read what translate() does here: http://download.oracle.com/javase/6/docs/api/java/awt/Graphics2D.html#translate(int,%20int)
Line 13 is a (somewhat inefficient and perhaps ill-fated) way of resetting back to the default starting point of your coordinate system.
If your school requires that you work with a version prior to 9i, they should be willing to provide it.
Otherwise, why not just work with 10g?
http://www.oracle.com/technetwork/database/express-edition/overview/index.html
Yes, I assume the array is to be used for some demo output within main(), though the intended usage is not stated.
LOL.. shows how much attention I was really paying to the code :)
That's what I get for hammering out a quick answer before I take care of something else at work.
Better check that declaration as Norm said.
Just assign the elements your new instances
movies[0] = new Movie(...);
or you can initialize them all at once
int[] movies = {
new Movie(...),
new Movie(...),
...
};
If you trace the function values through a small test node, you will see how the sum is automatically updated as the nested calls return back up the call stack.
I'd say you just need to check that your year count is less than the total before you prompt for another year.
Hitting "No" worked just fine for me. The program exited as expected.
If those are just entries in your log files and the result was 404 or 403, you don't need to worry about anything. Those are just bots seeking vulnerable spots. If you don't even have such a /_vti_bin/ directory, they can't exploit anything in it.
>Despite the fact that they are listed in the logs of visited pages
Those are logs of pages requested - not necessarily actually visited. That's why you will find bot fishing attempts there.
Certainly you can have multiple conditions. In your example above though, you should have an outer set of parenthesis around the entire expression. The parens around each clause are optional.ie
while(yearsloop <= years && selection == JOptionPane.YES_OPTION)
You need to the jar itself in the classpath. Java will look for the necessary files in that jar. After the classpath, you need to specify the name of your class to run your compiled program. That is why I had "ClassYouWantToRun" in my statement above.
You don't execute the driver directly. It's used by your code to obtain and use a connection like so: http://www.h2database.com/html/tutorial.html#connecting_using_jdbc
Here's a general JDBC tutorial as well: http://download.oracle.com/javase/tutorial/jdbc/index.html
>java -cp c:/H2/bin/h2-1.2.141.jar ClassYouWantToRun
The compiled jar file is located in the /bin directory.