Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, that's really about it. You have to check against all four bounds for containment.

If you're using Rectangle to store the rectangles, you can use its contains() method, but it does pretty much the same calcs you are doing there.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look through the tutorial on using tables and stop hijacking the OP's thread with your own questions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>Data can not be edited in a Jtable.
It certainly can be edited and saved back to the database. Ignore this nonsense.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I already solved it......

Yes, I am aware of that.

Pardon me for mentioning additional information that I though you might find useful. String matching error messages isn't really the most robust way to isolate the nature of error conditions.

mKorbel commented: i can't see reason for donw-voting +1 +8
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

To get it to actually render in the correct location, I also had to negate the x position in the super.paintIcon() call to account for the inverted scaling:

super.paintIcon(c, g2, -x, y);

@yancuoto: I would also recommend extending JComponent instead of Component and overriding paintComponent() unless you have to mix this with other heavyweight AWT components.

yancouto commented: Thank you man, you really helped me! +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, but one is partially occluded by the other because I did not alter any of the positioning code to account for differences in image width.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The code works just fine here. Check the size and positions you're painting the icons, because I think you're just overlapping them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at the SQLException api. There are methods to get SQL State and the Error Code, which will often provide the specific info you're wanting.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's currently optimized for the key phases "Thanks for sharing" and "Do SEO to get backlinks to ur site."

jingda commented: Lol:) +0
Salem commented: LOL +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, but the docs on using that service are very thin. I chose to point out the spelling difference because String-keyed locators like that do not provide much feedback for minor errors such as a key misspelling.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Spelling counts in service provider look-ups. Try

ScriptEngine engine=manager.getEngineByName("JavaScript");
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It would really depend on how you created the renders and assigned them to the column. If you did it the same way as the first then I don't see any reason why it would not work fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try using this for your cell renderer. You can pass it the combo box that you are using for the cell editor.

class CheckBoxCellRenderer implements TableCellRenderer {
        JComboBox combo;
        public CheckBoxCellRenderer(JComboBox comboBox) {
            this.combo = new JComboBox();
            for (int i=0; i<comboBox.getItemCount(); i++){
                combo.addItem(comboBox.getItemAt(i));
            }
        }
        public Component getTableCellRendererComponent(JTable jtable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            combo.setSelectedItem(value);
            return combo;
        }
    }

On your table column, column.setCellRenderer(new CheckBoxCellRenderer(comboBox));

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why not mark it solved yourself? Click the link at the bottom of the thread that says "Mark This Thread As Solved".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you Google it?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

At the bottom of the thread, above the quick reply box, there is a question "Has this thread been answered?" with a link "Mark this Thread as Solved". Click the link.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Check how you are creating your output label.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I wouldn't think so. Perhaps it was just an incompatible file or it was corrupted.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you tried a different wav file?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Eclipse is obviously not happy that you are directly accessing sun classes. Those are just warnings though and won't prevent you from using them.

Did you change your catch block to print the stack trace of the IOException?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> i have a bunch of warning signs on a bunch of my lines in the program. is it possibly because of my settings in eclipse?
Well, reading them seems to be a good place to start?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use error.printStackTrace() instead of just printing "file not found".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, you can see that your search is basically working because it does print out the days for the month that matches.

The problem is that you are printing out something for every single iteration of the loop. You really only want to print out the result of your search. To do that, perhaps you should make a variable to hold the search results you want to display. If you find a match, set the variable to that information.

After you have completed the search loop, print out your result.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you kidding? I can't possibly explain what floor() does in any clearer terms.

If you want to scold people that try to explain things for you, just forget it. RTFM. I won't trouble you with any further attempts to help.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The description of floor() is pretty straightforward:

Returns the next lowest integer value by rounding down value if necessary.

It basically gives you integer portion of your number without any of the decimal portion.
So think about that in the context of dividing your number by 10 and how the result compares to the values that you have hard-coded in that block of if statements.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

They are initialized once, but can be re-assigned. "Final" variables cannot be re-assigned after they are initialized.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It will change B every time an instance of A is created. Static is not the same as final.

Static merely means that all instances of a class share that reference instead of each having their own instance variable for it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why do you think they need to be static?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So simply provide instance methods on Main that return reference to A,B, and C. Let the instance of Main decide how to handle them internally. There isn't any need to make them static.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post the error instead of making people guess.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use String.valueOf(int) to convert your int to a string for the writer.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Is this not simply a variation on your other question here?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

We can just move it :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nope. Show some effort if you expect help with your homework.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The path to your database can be specified in your JDBC connection URL. See the following page about that: http://db.apache.org/derby/docs/10.8/devguide/

Examples are shown on this page

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That's a JVM crash message, not an exception. Check the hs_err log file indicated and search the net for the specific crash info reported there.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why do you need to start the db as a server at all on a single machine? Do you have more than one client sharing the data?

In your earlier posts, it sounded as if you were wanting an embedded database for use with a single application instance.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Is it possible that you have included an old version of the Carrot2 jar? Because the archived 2.x version API does not have that constructor for DirLocator. It only has the DirLocator(String) constructor.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That all looks reasonable to me. Assuming you don't have any custom classes named File or DirLocator within that same package, I would wonder if some other issue is preventing the Eclipse parser from correctly seeing that constructor. It's obviously there and is public.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post the import statements for your class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try using H2 or JavaDB instead. Both are embedded databases that do not need to be separately installed.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try H2 if you want a local embedded database for use with Java.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

See How to Write a Key Listener. Check the key code and increment your positional variables based on that. Repaint as needed.

Be mindful about focus issue with key listeners. The listener will only receive events if that component has the focus.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

BigDecimal not work for you?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I recommended that you move the table creation code into initUI, not all of the database and model code. Create only your UI components in initUI(). Do not create your table model there. The entire point is to create the UI components only once.

In your action listener, create or update your table model. The model will initially be null, so you create it the first time a selection is made. If the model is not null, simply call setQuery() with the new query string.

Do NOT re-create your entire UI just because they selected a different value to query.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Marking this solved. I think the OP has found an answer by now.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post your updated code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would recommend moving the table creation code out of conn() into your initUI() method.

Your action listener for the combo box then needs to initialize the table model if it is null or setQuery() with the new query string if the model has already been created.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are correct that they are adding a new JTable every time, but the solution is not to remove those tables before adding the new one. The solution is to keep one JTable.

There is absolutely no need to create a new table just to update the data. The data is the model's responsibility and that is all that needs to change here. There is even a method to change the query without creating a new ResultSetTableModel, so it's simply a matter of calling that method on the existing model instance with a new query string.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No need to remove or create new JTables at all. Change the data that is within the model instead.

It looks like you can call setQuery() on your ResultSetTableModel to query a new set of data. If you maintain a single instance of that model, you can just update it's query when your combobox selection changes.