|
Twitchy posted:If you have the JDK installed most IDE's will let you right click the Class name and goto the source code.
|
# ¿ Jun 5, 2008 12:19 |
|
|
# ¿ May 9, 2024 20:43 |
|
You're only reassigning the field jList1; the original JList instance is still displayed in the UI. What you should really be doing is is assigning a DefaultListModel to jList1 once, never reconstructing jList1, and modifying the model (i.e. the DefaulListModel object) directly. For what it's worth you look like you're using Netbeans. Create a new property (i.e. a getter) for a ListModel instance on the main object and use that in the designer as the model for the element (there's a dropdown that'll let you select any property of the right type). Just have a field containing the (one!) DefaultListModel instance you're using, have the getter return that, and operate only on that. zootm fucked around with this message at 19:51 on Jun 10, 2008 |
# ¿ Jun 10, 2008 19:42 |
|
More explicitly, the property (along with the field) would look like this:code:
From then on just write your action handlers to update the model and the changes will be shown in the UI. You do not need to manually update the UI at all, Swing is pretty good for noticing changes in its underlying models and updating automatically. Edit: Here is the full source to an example which I just made in the UI designer, hopefully it'll be illustrative. The only methods I wrote are the ones detailed above and the content of the "hilarityButtonActionPerformed" method (the method itself was added by the designer). Incidentally I don't know how the binding stuff works in full but it might be possible to bind your data more directly to the "elements" property of the JList. zootm fucked around with this message at 21:05 on Jun 10, 2008 |
# ¿ Jun 10, 2008 21:02 |
|
No problem. Incidentally, though, Java 5 and 6 can call 1.4 JARs without any problem at all; unless you need the code you produce to run on 1.4 or earlier it shouldn't be an issue at all.
|
# ¿ Jun 11, 2008 09:30 |
|
Netbeans, using its newer Swing Application Framework stuff, is very good at making SAF apps. I assume your other Netbeans entry is the Netbeans framework itself, which is neat but only really for apps which are a lot like Netbeans, like you state. Eclipse is much the same when used as a framework. I wouldn't go with QtJambi since I'm not a big fan of Qt, although as you say it might fit well with you since you do like the framework. Swing has the advantage of (these days) integrating very well with both Windows and Linux (GTK+) systems; the OS X stuff is nice too but Apple provide it themselves and it can be a little slow. Pre-Qt4 I'm not sure how great Qt is across platforms. zootm fucked around with this message at 14:27 on Jun 11, 2008 |
# ¿ Jun 11, 2008 14:23 |
|
You're right, BeefofAges, Java doesn't have operator overloading.
|
# ¿ Jun 20, 2008 11:00 |
|
This all seems extremely complicated, but the implementation looks at least mostly correct - the paper in question is here. Concurrent algorithms are something of a black art and I this is currently hurting my head. You could be correct though, it might be that head should be written as an atomic reference to the same node as tail rather than being the same atomic reference. Not sure, though. The line in the paper there is: code:
Edit: The implementation given is consistent with (not the same as, but consistent with) the one in OpenJDK. zootm fucked around with this message at 11:18 on Jun 21, 2008 |
# ¿ Jun 21, 2008 10:58 |
|
poopiehead posted:The OpdenJDK implementation looks ok. tail and head are volatile read-only fields. They use this special atomic reference class that handles all of the writes to the fields using reflection. Hopefully that makes you feel better
|
# ¿ Jun 21, 2008 22:34 |
|
That's not what I thought I read at all! I'll need to check up on that again. Neat, anyway.
|
# ¿ Jun 22, 2008 00:54 |
|
I think the ByteBuffer solution is the "correct" one here, but if that Swap thing works for you and it's a small project then I suppose you may as well.
|
# ¿ Jun 25, 2008 08:56 |
|
csammis posted:Also why are you using @Override on an interface method?
|
# ¿ Jun 26, 2008 18:32 |
|
poopiehead posted:In C#, it's even part of the method signature. poopiehead posted:On using @Override with interfaces, it will actually cause a compiler error in Java 5, but will not in Java 6.
|
# ¿ Jun 27, 2008 11:24 |
|
Changing the command line arguments only changes the memory available to Eclipse itself; your program runs in a completely separate VM. You can manage this from within Eclipse. One way to do it is in Preferences, go to Java/Installed JREs, "Edit..." the one you use, and then put args in "default VM arguments". You can also do it on a per-launch configuration basis by playing with them in your project settings.
|
# ¿ Jun 28, 2008 00:25 |
|
Smackbilly posted:Oops, yeah, I was thinking in C++ there (where a throw with no arguments re-throws the exception you just caught).
|
# ¿ Jul 10, 2008 09:32 |
|
I'm pretty sure there's not in the default libraries.
|
# ¿ Jul 13, 2008 22:51 |
|
I think the libraries just use the OS stuff transparently, and there isn't a direct way to do that. I imagine there's about a billion libraries available for it though. Edit: Actually it looks like this might let you access stuff through JNDI, although the one "review" of it I saw didn't seem to rate it highly. This library looks a bit more direct, and is allegedly used by quite a few projects. zootm fucked around with this message at 09:24 on Jul 14, 2008 |
# ¿ Jul 14, 2008 09:19 |
|
csammis posted:What sort of metric is "classy," and how are virtual methods informal? A virtual (abstract) method is exactly what you want here, and like 10011 said it'd just be protected if you didn't want callers to access it*. code:
code:
code:
|
# ¿ Jul 14, 2008 19:27 |
|
clayburn posted:Anyone know how to restore the build.xml file that NetBeans creates? I have a project and somehow mine got messed up and now it won't compile.
|
# ¿ Jul 18, 2008 00:25 |
|
Profilers can usually track where allocations happen as well as what was allocated, I'd investigate that. Is it possible that you're keeping one massive transaction open, or just re-using something that's supposed to be discarded? I'd guess it's somewhere in the database connector but I've really no idea I'm afraid.
|
# ¿ Jul 24, 2008 11:50 |
|
Entheogen posted:I believe you want to look into finalize() method. You can overload that for your class and it will get called by garbage collector when it frees that object from heap. In the case of java.net.IDN the methods are all static and it cannot be overridden or instantiated anyway, so the point is moot, but in general if you think it's a good idea to use a finalizer you're likely to be wrong. They're sadly not very useful. Entheogen posted:I don't know how IDN class works, but perhaps it has handle to some native resources and is not designed to free them? This is usually how memory leaks occur in Java. You could perhaps write your own class extending from IDN and then free whatever IDN doesn't?
|
# ¿ Jul 24, 2008 20:53 |
|
Entheogen posted:How can I determine endianess of a floating point number at run time? That is, I am reading a binary file and I would like to determine whether I should reverse the bits or not. Is this even possible?
|
# ¿ Aug 1, 2008 09:23 |
|
GT_Onizuka posted:Recommendations for a Java memory profiler? I don't want to attach it to any IDE as I need to run it all remotely. We're using Java 1.5.
|
# ¿ Aug 16, 2008 10:03 |
|
Chuu posted:According to the book I'm using to study, this should be equivalent to Implementation #1. Read naively, to me this means "Wait for the class lock before executing "counter()" then "Wait for the class lock before executing the return statement" i.e. it should automatically deadlock. Since it's functionally equivalent though, I assumed the "synchronized" keyword meant "somewhere in this method something is synchronized, not necessarily the entire method, unless you do not see a synchronized block, then the entire method is synchronized" i.e. it won't deadlock. Does what's expected, prints "hi". The problem is . . . Chuu posted:So what exactly is the difference in #2 and #3, or is there something going on here that my trivial example isn't showing? All three programs are equivalent but a synchronized block on the class within a synchronized method as in 2 will never do anything. As an extreme example, here's another equivalent program: code:
zootm fucked around with this message at 15:00 on Aug 16, 2008 |
# ¿ Aug 16, 2008 14:55 |
|
Chuu posted:Ahh, ok, thanks a lot. I assumed they work the same was as mutexes on *nix. zootm fucked around with this message at 17:46 on Aug 16, 2008 |
# ¿ Aug 16, 2008 17:37 |
|
1337JiveTurkey posted:Apache Derby claims to be fairly lightweight but I don't have much experience with it.
|
# ¿ Aug 21, 2008 09:40 |
|
The non-blocking IO stuff in java.nio lets you deal with many inputs using very few Java threads. You stated before that you knew of no non-blocking alternative so there it is. It's not on Reader because Reader etc. predate all the non-blocking stuff they added in I think version 5. But really I'm kind of lost trying to figure out what all this bickering is about. For what it's worth an N thread pool to service M readers is still only N threads (Readers do not spin up their own threads - what would be the point?). It will only service N Readers at the same time, though, which kind of defeats the purpose. zootm fucked around with this message at 22:16 on Aug 25, 2008 |
# ¿ Aug 25, 2008 22:11 |
|
triplekungfu posted:No, that's not what I meant, in the example I gave earlier I had three threads servicing 15 objects. zootm fucked around with this message at 14:09 on Aug 26, 2008 |
# ¿ Aug 26, 2008 13:57 |
|
Mustach posted:The lesson is that everything that depends on input should be in the try block: There's two other problems here though - the compiler may not recognise that System.exit terminates control flow (although really avoiding that function is the best solution for that). The other problem is that FindBugs may not think that 'readLine' returns a non-null value.
|
# ¿ Aug 29, 2008 07:59 |
|
Mustach posted:
code:
zootm fucked around with this message at 13:50 on Aug 29, 2008 |
# ¿ Aug 29, 2008 13:40 |
|
Mustach posted:What makes that superior to
|
# ¿ Aug 29, 2008 15:17 |
|
Make sure that a.equals( b ) iff a.compareTo( b ) == 0. The first condition needs to be true for 'get' to yield a value, but the second is the case where keys will overwrite elements, I think.
|
# ¿ Aug 30, 2008 09:48 |
|
invid posted:I'm creating a jsp powered booking system and I'm not sure how I should be doing the controller classes. I have a jsp (view) that displays all the bookings, and on that page, users can add or delete them. Currently I'm using a addBooking servlet, should I be creating a delBooking Servlet, or is there a better way to do this (MVC)? dancavallaro posted:I have a bunch of mailing list data in an Excel file that I want to put in an Access file (I would prefer/it would be easier to use mySQL, but I'm doing this pro bono for a non-profit and they want it in an Access DB). Ideally I could just import the data into Access using the import wizard, but I need to do some processing on the data before I can import it, and I want to split it into 2 files. I was hoping to do this with Java, because that's the language I'm most familiar with. I was hoping to just export the Excel file as CSV data, and then write a Java program to process the data and insert it into my Access database. If there's a better way to do this, I'm open to suggestions, but I'd like to use Java and I'm just having trouble interfacing with Access. How can I use an Access database from Java? zootm fucked around with this message at 16:10 on Sep 1, 2008 |
# ¿ Sep 1, 2008 16:06 |
|
I think that the NetBeans 6.5 beta may have Groovy support, they've added a ton of dynamic language support in there recently and it works pretty well. Failing that some nerd may well have made nice Vim or Emacs bindings.
|
# ¿ Sep 2, 2008 00:51 |
|
I never hear anything but glowing reviews about everything IntelliJ IDEA does so yeah, if willing to fork out the cash it's likely a good call.
|
# ¿ Sep 2, 2008 18:07 |
|
Edit - double post
|
# ¿ Sep 2, 2008 18:07 |
|
Could be a shaky JDBC driver I guess. Without the actual error this'll be basically impossible to diagnose though.
|
# ¿ Sep 3, 2008 14:08 |
|
If you're having problems, surely an exception was thrown? Also I've noticed that in your SQL statement you pass the last argument as a string, whereas in your Java code you set it as a number. Depending on your database this could cause a problem.
|
# ¿ Sep 3, 2008 14:34 |
|
You're catching the SQLException and not using its value. Try at least printing it out.
|
# ¿ Sep 3, 2008 15:10 |
|
If you create an interface which defines your expected method call, you can avoid using reflection (build the class and then just newInstance it then cast to MyInterface or Callable<T> or whatever). As for your "deeper" problem, I really don't know why serialising a Class instance doesn't work - it may "just work" unless the byte array is really tiny. Also, to load your own classes in a custom way, you probably want your own ClassLoader implementation - try subclassing ClassLoader (I don't think you need the extra gubbins that SecureClassLoader buys you but I could easily be wrong). Of course the "outside the box" solution would be to use javax.script and define the function to be called in Javascript (comes with SE6) or any one of these languages (requires bundling the runtime for the language, which can get large). Then you just need to pass the string of the source. Probably completely over the top for any reasonable use-case though. zootm fucked around with this message at 17:33 on Sep 9, 2008 |
# ¿ Sep 9, 2008 17:30 |
|
|
# ¿ May 9, 2024 20:43 |
|
Flamadiddle posted:is this the proper solution?
|
# ¿ Sep 16, 2008 19:32 |