slade cox

Greenhorn
+ Follow
since Sep 07, 2002
Merit badge: grant badges
For More
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 slade cox

Glad to help. Out of curiosity, how smoothly does the JTree work?
19 years ago
No, you will have to delete all of the contents first.
19 years ago
As far as I know there is no way to hide the arrow. The ListCellRenderer only affects the popup menu. If you absolutely cannot stand the arrow then you could roll your own using a JLabel and JPopupMenu.
19 years ago
Actually, the OutOfMemoryError only occurs when Java's allotted memory is completely used up within the virtual machine. This is entirely independent from Windows running out of memory. In fact, if java tries to take up more memory within windows than is available you will get strange behavior, not the OutOfMemoryError. Before you run java, how much free memory is available on your windows machine? By default java will try to take up 64Mb and if you have less than 64Mb available then you will have problems.

Having said all that, it's more likely that you have plenty of memory and that something else is causing the crash. I've seen similar crashes triggered by the AWT-Event-Thread. Does it die most often at some event? When you mouse over a particular component? Click a button? Or does it just happen after a while of running it? The best way to track down the problem is to compile it with debugging options and use jdb.
19 years ago
You say to replace commas with newlines, but your example list split "baba crap" into two lines. Assuming this was a typo and you left out the comma, here is example code:



If you want it to split on any white space or a comma replace the regular expression in split() with this: "\\s*[\\s,]\\s*"
[ July 21, 2004: Message edited by: slade cox ]
19 years ago
What is the full exception message? ie. which line is causing the ClassCastException, which object is incorrectly cast?

Also, when you iterate through myPathList and expand the paths you could do something simpler like

for(int li=0;li<myPathList.size();li++){
t.expandPath((TreePath)myPathList.get(li));
}
19 years ago
As for your issue 1) you bring up a good point that an accidental shadowing of a parent class's member variable could produce unexpected results. This is why it's always best to avoid shadowing variables. In fact, better compilers like jikes will warn you if you attempt to do so. Anyone using a compiler that doesn't issue such warnings should make sure to be familiar with the parent classes public and its protected instance variables.

Regarding issue 2) I would ask you this, how else would you access the parent class's member variable if it was completetly overriden by the subclass? ie. if you had an instance of class B above, how could one access the original m_num if casting it to class A still gave you class B's member variable?
19 years ago
Yes you can. On the page mentioned above see the FileExplorer example and the Dynamically Modifying a Tree section.
19 years ago
The reason your subclass's variable does not behave like an overriden function is that you have declared the variable twice, thus creating two separate variables with the same name (generally not a good idea). The member variable for class A is used when an object is cast as A. If you actually want to change the original variable for all instances of subclass B then you should do this:

class A {
protected int m_num = 10;
}
class B extends A {
B() { m_num=20; }
}
A obj = new B();
obj.m_var --> 20

Then there is only one variable named m_num, and no confusion.
19 years ago
Frame.setResizable(false) should work. However, if your users are frequently attempting to resize the window you might want to consider whether the size of your window does not fit the needs or requirements of your users' desktops. And a well designed layout should scale well.
19 years ago
It would help to know exactly how your code fails. Does it generate an exception? Does the process generate any output/error messages? If the code doesn't exit abnormally try grabbing the error and input streams with listBurn.getInputStream() and listBurn.getErrorStream(), then print them out.

If an IOException is generated mkisofs might not be in the PATH of the process's environment. In that case you would need to pass the appropriate environment to the exec method. In any case, I'm sure it gives a more detailed error message than "doesn't work" so post it here.
19 years ago
First I would say that you are using TreeModel incorrectly if you are modifying the JTree by calling setModel. This should only be used for creating a new JTree. Instead you should modify your TreeModel and call the reload() method of DefaultTreeModel (which you extended, right?). For a full description and example see:

http://java.sun.com/products/jfc/tsc/articles/jtree/

If you absolutely insist on using the setModel method to update your tree then you could do something like this. Keep track of the expanded paths in a list. Register a TreeExpansionListener that does something like this:



Then after calling setModel iterate through the path list and call expandPath for each one. But, the first option is better.
19 years ago
I feel stupid posting a question and then replying with the solution. But, I found the problem so I might as well post it. Two switches needed to be added to the gcc command.

-Wl,--add-stdcall-alias
This seems to export the function correctly, while the JNIEXPORT seems to do nothing at all. (-Wl,--kill-at seems to work as well. Anyone know what difference it makes beyond a smaller file?)

-mno-cygwin
Without this, java exits abruptly with exit code 128 and no error messages. I presume this is a bug/issue with cygwin.
19 years ago
I have copied and compiled the JNI example given by Sun at http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/index.html. I used gcc on cygwin to compile HelloWorldImp.c. When I run it, I get the following error:



The the current directory is in PATH, so it's not a path issue. The JNIEXPORT appears to be properly defined in jni.h, so it shouldn't be an issue of exporting the function. Any other suggestions?

I'm running a completely updated cygwin on win2k. HelloWorldImp.c is:

19 years ago