Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!

Matt Senecal

Ranch Hand
+ Follow
since Dec 01, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matt Senecal

Thanks! I just slapped my forehead and said "duh". I'm running on empty today....

Originally posted by fred rosenberger:
Both derive from TableModel, so you could cast either TableSorter or TableIndex to a TableModel.

but you can't cast a TableIndex to a TableSorter.

if i had Chihuahua derives from Dog derives from Mammal, and Cat derives from Mammal, i can't cast a Cat as a Dog.

15 years ago
Hi,

Yes I verified it. The exception is just your generic ClassCastException, specifying the line number and the file that the exception is being thrown in. No other information is being given.

Originally posted by Dave Wingate:
Could you post the exception you're getting?

Did you verify that getModel() is actually returning an object of type TableIndex?

e.g. System.out.println(table.getModel().getClass().getName());

15 years ago
I inherited an unfinished (undocumented and uncommented) program from another programmer (now gone), and I'm trying to figure out a ClassCastException that gets thrown at runtime.

In the program contains a lot of custom classes for table manipulation. The two key classes here are TableIndex, and TableSorter. Their inheritance hierarchy is as follows:

TableSorter extends TableMap
TableMap extends AbstractTableModel
AbstractTableModel implements TableModel

TableIndex implements TableModel.

At some point, a JTable is created that has a TableIndex as it's model:



Later on, this call is made, and it throws a ClassCastException:



table.getModel() returns a TableIndex, which is being (illegally, apparently) cast to a TableSorter. Looking up the inheritance chain, both TableIndex and TableSorter are derived from TableModel. Why, then, is this not working? Is this problem because both classes are not extended from the same superclass? Can someone tell me where the break is?
15 years ago
Hi,

I've not tried this, but in looking over the API documentation I see some methods that might help. My thoughts:

Get the JScrollPane's JViewport with JScrollPane.getViewPort().

Get the size of the viewport by calling JViewport.getViewSize().

Set the size of the JPanel to this with setSize() or setPreferredSize().

My question for you is: wouldn't shrinking the JPanel (which is contained by the JScrollPane) to the size of the JScrollPane's viewport eliminate the need for a JScrollPane?
15 years ago
This is something I've been pondering for a while, and I'd appreciate some solid guidance on the matter: If you have an object that needs to call a method in the class that created it, why not just pass the object a reference to "this" (i.e to the parent class as a whole)? The created object can just call the method it needs directly. The process of creating an interface and implementing it just seems to me like adding another layer.
15 years ago
I have what is probably a dumb question. I'm creating a custom dialog, but would like to use the default dialog icons provided by the look and feel (you know: the standard question mark, exclamation point, etc.)

Dumb question: how do I go about loading these default icons? I can't find them anywhere, nor can I find instructions for doing this anywhere. I need a kick in the right direction, and I'd appreicate any help.

Thanks!
15 years ago
Yes, I just tried it, and it works fine. I'm looking to see if my web server isn't preventing it.

Originally posted by Shailesh Chandra:
Matt ,

did you try creating a new html with your view source code ??
and opening same in browser.

are you still not able to open file ?

in that case there would be nothig releated to your jsp code.

16 years ago
JSP
IE6 correctly interprets the URL's that my code created as files. That is, when you do a copy link, they come out as "file:///BLAHBLAH". I tried doing it explicitly anyway, and the results were the same.

Originally posted by Bear Bibeault:
Valid file protocol URLs are of the form:

16 years ago
JSP


Why not post the resulting HTML from your View Source? That'll give us a better look at why your links may not be working.



No problem! I appreciate your help.

I altered the source slightly. I guess my brain isn't working today, because I totally forgot that arrays have a length property! That's been fixed. I also added explicit quotes to the links.

The links still don't work. However, if I copy the link shortcuts and paste them into the address bar of my browser, the files open fine. Puzzling.

The resulting HTML is below:

16 years ago
JSP


1) Why do you complicate your JSP pages needlessly by generating HTML in Java code



Because you're looking at what is literally my first attempt at a JSP after less than a day of study. It naturally follows that it's going to contain things that look funny/inefficient/complicated to someone who knows more than I do.



2) What do you see at the browser via View Source? Is your HTML as you expected?



Pretty much!
16 years ago
JSP
I'm trying to create a JSP that reads the contents of a directory and creates a list of links to the files in that directory. The idea is that the user should be able to click on one of the links, and open the file up.

The code correctly creates a list of hyperlinked files, but when I click on the links, the files do not open. No dialog comes up, or anything.

Can anyone tell me what I'm doing wrong?

My page code is as follows:

16 years ago
JSP
Is it possible for Java3D to use pre-defined 3D objects that were created with another program, say Blender or some other commercial package? If so, could someone please direct me towards the instructions for doing so?

Thanks in advance.
16 years ago
D-n-d gurus, I need your help. I'm creating a backgammon game, and need help in figuring out what components should be sources, and what should be targets.
The way the board works is that each point on the board is a separate object. The checkers (also separate objects) are contained within the point in a vector. Checkers are added/subtracted to/from the point by adding/removing them to/from the vector, then calling a custom method which redraws the checkers on the point. The board is just a large JPanel, and the points are positioned within the board using explicit positioning.
I would like to add drag-and-drop capabilities to the board, so that the user can click and drag a checker to another point. After reading the drag-and-drop tutorial, I'm more confused than ever.
My question to you: what should my drag sources be, and what should the targets be? I'm assuming that the points should be drop targets, since they will be receiving the dropped checkers. Should the checkers or points be drag sources?
Also, since a checker is just a glorified JPanel, what do I need to do to make it draggable?
Any help would be appreciated!
16 years ago
Hi,
Did you mean that you want each node to have a JCheckBox *and* a JComboBox? If so, you can change your editor/renderer to handle JPanels, and then just add both Swing objects to the JPanel in each node. I've done it in past projects.
17 years ago
Looks good to me. The only thing I wondering (and it's probably inconsequential) is why you're explicitly closing the IS/OS/ES.
17 years ago