tag:blogger.com,1999:blog-6790609626295816719.comments2019-11-26T13:56:35.549-08:00Aberrant CodeUnknownnoreply@blogger.comBlogger24125tag:blogger.com,1999:blog-6790609626295816719.post-47002562775226725972009-08-27T07:13:18.994-07:002009-08-27T07:13:18.994-07:00Hi -S-
Java.net is having some issues so I can...Hi -S-<br /><br />Java.net is having some issues so I can't look at the code and give you an exact answer. If I remember correctly the 2 JTables both look at the same TableModel. If you want sorting then wrap the TableModel in a TableSorter and pass the sorted table model to both JTables. This was I used before java 1.6 introduced the "table sorting API". I'll look into it when Java.net is back up.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-643111985572980632009-08-25T01:08:06.150-07:002009-08-25T01:08:06.150-07:00Hi mr Aberrant. I've seen your code about Froz...Hi mr Aberrant. I've seen your code about Frozen Columns in JTable. It's really interesting to know that we can do that in JTable. I tried ur code and it worked. Thank you so much for the code. <br />In your code there are 2 tables become 1,right? (One table that has the frozen column and the rest in the other table). My question is how to sort the two tables? Because when I tried to sort the table, it's not related each other (just one table that being sort).<br />I want to post<br /><br />NB: Sorry if my english is so bad. hope you understand what I mean. Waiting for your reply. :)-S-noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-17715637982758481502009-01-19T01:19:00.000-08:002009-01-19T01:19:00.000-08:00The problem with a non-local exception handler is ...The problem with a non-local exception handler is that you have no access to local variables. Maybe you could pass some of them to the handler?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-31990330267108305152008-11-10T07:59:00.000-08:002008-11-10T07:59:00.000-08:00Good for people to know.Good for people to know.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-17010181224934306382008-05-09T22:31:00.000-07:002008-05-09T22:31:00.000-07:00Cool Idea,really useful if only want to be doing l...Cool Idea,<BR/>really useful if only want to be doing logging or some common tasks on the exceptions.<BR/>But I think it will become more verbose when you need to have different exception handling codes in different scenarios.Shamshttps://www.blogger.com/profile/10301627897367423203noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-70510765774869352282008-05-08T07:48:00.000-07:002008-05-08T07:48:00.000-07:00@CasperThanks, Yes I really should try to implemen...@Casper<BR/><BR/>Thanks, Yes I really should try to implement this. I'll have to see if Kijaro will except me. <BR/><BR/>@David<BR/><BR/>It does turns out to look like the the control invocation syntax. It's not really a closure. It's just a delegate object for the exception handling logic.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-8803680627748052112008-05-08T06:41:00.000-07:002008-05-08T06:41:00.000-07:00It's similiar to the control invocation syntax of ...It's similiar to the control invocation syntax of the BGGA proposal, right? http://www.javac.info/closures-v05.htmlDavid Linsinhttps://www.blogger.com/profile/12280104990941617395noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-6678609698568758882008-05-07T10:05:00.000-07:002008-05-07T10:05:00.000-07:00Nice idea! May I recommend trying it in Kijaro, th...Nice idea! May I recommend trying it in Kijaro, the no-nonsense sandbox set up by Stephen Colebourne?Casper Banghttps://www.blogger.com/profile/09493174484116672294noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-22157390257911522202008-04-30T13:41:00.000-07:002008-04-30T13:41:00.000-07:00@ColdstoneI agree that the next and previous butto...@Coldstone<BR/><BR/>I agree that the next and previous buttons might make sense if this was a general purpose application. My intent was to shove as much icon related code into as little a space as possible. If I was building a general purpose image viewer the code would be very different.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-51312497978682958602008-04-30T13:30:00.000-07:002008-04-30T13:30:00.000-07:00Nice example. However, I am not sure if I am miss...Nice example. However, I am not sure if I am missing something, but what if someone uses this example with more than 5 images? <BR/><BR/>Seems like it would be good to keep the next/previous buttons.Smugginshttps://www.blogger.com/profile/14344761401667845274noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-12445106225029396592008-03-11T16:23:00.000-07:002008-03-11T16:23:00.000-07:00I guess I should have read them more carefully the...I guess I should have read them more carefully then, LOL. But it's no big deal anyways. I'm very impressed with how functional it is for a prototype.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-43551003095788537632008-03-11T15:31:00.000-07:002008-03-11T15:31:00.000-07:00The current FCM prototype does not handle exceptio...The current FCM prototype does not handle exceptions well. At least it is in the release notes...Stephen Colebournehttps://www.blogger.com/profile/01454237967846880639noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-42403370119730071022007-11-16T16:38:00.000-08:002007-11-16T16:38:00.000-08:00Very good point. But there are some sets that are ...Very good point. But there are some sets that are order dependent, like SortedSet. I will adjust and repost at some point. There is probably a much better design for this type of functionality, like a getDeepEqulator() method that would return an object capable of dealing with these issues.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-87911388348484722882007-11-16T08:29:00.000-08:002007-11-16T08:29:00.000-08:00Hi,seems like your code will compare all Collectio...Hi,<BR/><BR/>seems like your code will compare all Collections as Sets (without checking the order), meanwhile two Lists are not equal if they contain the same elements but in a different order.AlexFacehttps://www.blogger.com/profile/10982265171747293445noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-16857852871779013532007-08-25T07:03:00.000-07:002007-08-25T07:03:00.000-07:00@Spencer If your images are located outside the Ne...@Spencer <BR/><BR/>If your images are located outside the Netbeans project then you need to use the full pathname in the array. <BR/><BR/>c:\yourfullpath\yourimage.jpg<BR/><BR/>If you use the images directory then you need to place the desired file in the Netbeans project. Since the path is "images" you need to add a package named images. Then place your images in that package. <BR/><BR/>Actually a more simplified version of this demo got into the actual java tutorial.<BR/><BR/>http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html<BR/><BR/>There is a even a Netbeans project to download. <BR/><BR/>Good luck I hope you find the demo helpful.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-56366168586179532442007-08-24T08:09:00.000-07:002007-08-24T08:09:00.000-07:00I'm trying to run this at home and have got the .j...I'm trying to run this at home and have got the .java to compile in NetBeans. However when I run it, I get "Cannot Find File: images/Slide01.JPG" (I've changed the filename array to represent files I have in images\"<BR/><BR/>What am I doing wrong?<BR/><BR/>Thanks...Anonymoushttps://www.blogger.com/profile/14874504081749849409noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-52039227876089980352007-07-23T14:00:00.000-07:002007-07-23T14:00:00.000-07:00Complete JavaDoc comments would be nice.- A senten...Complete JavaDoc comments would be nice.<BR/>- A sentence should end with a dot.<BR/>- @param and @return<BR/>But I share your general critic about the examples. Learners need shining examples.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-9504092276629001262007-07-23T12:10:00.000-07:002007-07-23T12:10:00.000-07:00Hey aberrant,I think it's great that you actually ...Hey aberrant,<BR/><BR/>I think it's great that you actually reworked the demo.<BR/><BR/>Would you be interested in having your version featured in the tutorial? We'd run it past engineering and then replace the current demo with this one. (The text on the icon page would need some updating as well.)<BR/><BR/>Of course you would get full credit for the new version.<BR/><BR/>Let me know.<BR/><BR/>Sharon ZakhourShamshttps://www.blogger.com/profile/16395230649775467820noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-41437242846616608622007-07-21T04:53:00.000-07:002007-07-21T04:53:00.000-07:00@cpedros - thanks for the feedback.Why aren't the ...@cpedros - thanks for the feedback.<BR/><BR/>Why aren't the String arrays static? Humm... well I thought about it and since it's a demo and I am demonstrating generically how to do something I didn't want to make the reader think static was necessary for the example. This very simple example can use static, but thats not always the case. Is that enough of a reason? I'll think about it some more. Since there is only one instance of the app data is not duplicated anyways.<BR/><BR/>LinkedHashMap? Where? Ok you got me, it had been a LinkedHashMap because in one of my revisions I was iterating threw the keys. A LinkedHashMap guarantees the iteration order is the same as the insertion order. A regular HashMap can have the order of the keys change at any random time. In any case I no longer need that functionality and so I'll change it to a plain HashMap. <BR/><BR/>As for the declaration changing to a plain Map. I tend not to do that for member data declarations. There are times to do it, like when designing an interface or API, but only if the API is truly implementation agnostic. When I look at all the implementations of the Map interface I see very specific interaction rules. LinkedHashMap has a constant key iteration order, TreeMap is sorted, WeakHashMap does not hold on to it's keys and so on. By declaring the variable as exactly what I need I force the next person who modifies my code to think about what they assign to that variable. <BR/><BR/>If you went threw all the trouble to build a TreeMap with a string comparator that sorts in reverse alphabetical order and then someone later came along and reinitialized your Map with a HashMap things could get rather buggy if you depend on that sorted order. Declare it as a TreeMap and then someone will at least get a compile time error when trying to assign a HashMap to it. <BR/><BR/>Thanks again.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-66577691141993628652007-07-21T01:36:00.000-07:002007-07-21T01:36:00.000-07:00I know I'm stating what everyone thinks, but SUN's...I know I'm stating what everyone thinks, but SUN's reliance on NetBeans in their tutorials is something that infuriates me. It's like a driving instructor saying "I'll teach you how to drive but only if your car is a Ford." However, I must admit that the whole process of seeing a badly written program reworked has probably been of more benefit than aim of the tutorial itself! As a learner working through a tutorial, you can take on board code comments that tell you why a specific piece of code exists, but you don't truly understand <B><I>why</I></B> until you see it done badly. Is this a practice SUN should continue to follow ;-) ?<BR/><BR/>I have the following questions (not criticisms) regarding the example. Hopefully I'm asking what other newbies would be asking:<BR/><BR/>- atripp already raised this but would it better to declare the private members iconCache and thumbnailCache using the interface rather than the Map implementation?<BR/>- Why use a LinkedHashMap?<BR/>- What are the reasons against the String arrays for imageCaptions and imageFileNames being declared as static?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-53607407740046400972007-07-19T15:11:00.000-07:002007-07-19T15:11:00.000-07:00atripp: No, the best practice is avoiding demand-i...atripp: No, the best practice is avoiding demand-import (.*) completely. There are even rules to catch this sin in tools like Checkstyle (see its rule "AvoidStarImport"). Rationale from Checkstyle's docs: "Importing all classes from a package leads to tight coupling between packages and might lead to problems when a new version of a library introduces name clashes.". Moreover, star imports make javac slower (resolution of identifier becomes much harder, I've implemented this myself), and it allows certain bugs (even if admittedly rare) like wanting class X which you never used before in a given source file, typing X in editor, and the editor doesn't complain because X is already imported thanks to some star import, so you accept and save it although you really want a similar class in another package (and nobody looks at the import section of sources these days, thanks to editors with "import completion" and code folding...).Osvaldo Doederleinhttps://www.blogger.com/profile/05264918260779798314noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-5439268515362596702007-07-19T11:33:00.000-07:002007-07-19T11:33:00.000-07:00Thanks for the comments.@Mr Bob DobolinaThanks for...Thanks for the comments.<BR/><BR/>@Mr Bob Dobolina<BR/><BR/>Thanks for the bug catch. I have changed it to execute. We use a home grown SwingWorker here and we end up passing it to an executor. I think a more advanced demo would be a great idea. Maybe I'll attempt that soon.<BR/><BR/>@atripp: <BR/>I removed the PLAF code. I can't use the foreach loop in doInBackground() because I need the loop counter to access the two arrays.Anonymoushttps://www.blogger.com/profile/16791229566372038427noreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-5855978771032022222007-07-19T10:43:00.000-07:002007-07-19T10:43:00.000-07:00It looks nice, and for "A more complex example" I ...It looks nice, and for "A more complex example" I think it's OK to do things the "right" way (load images in a different Thread) and SwingWorker is obviously a good choice.<BR/><BR/>However there is a bug using SwingWorker in the example.<BR/>It should be loadimages.execute();<BR/>Calling run won't do it in a different Thread.<BR/><BR/>I wouldn't extend JFrame but rather create one in the App class. (Favor composition over inheritance)<BR/><BR/>Of course we could have gone all out with classes like an ImageFactory, PhotoAlbum, PhotoPanel et.c. but I agree that the focus should probably be on how to load/show icons/images here. <BR/>To load them from different sources like a file, a web page and a jar would be a nice addition.<BR/><BR/>I would put some notification in place in the event the image files weren't downloaded with the example, or the sources can't be reached et.c. I'd say that should always be part of "best practice" examples.<BR/><BR/>@atripp: Is using wildcards in import statements really best practice?<BR/>I agree with the reasons against wildcards from this link:<BR/>http://www.javaperformancetuning.com/news/qotm031.shtmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6790609626295816719.post-59278979502793736302007-07-19T08:37:00.000-07:002007-07-19T08:37:00.000-07:00A few suggestions:* combine imports with "import j...A few suggestions:<BR/>* combine imports with "import java.util.*;" - best practice and also brevity.<BR/><BR/>* declare collection class variables to be of the most general type possible (i.e. make iconCache and thumbnailCache be type Map).<BR/><BR/>* get rid of the commented-out PLAF code - it's irrelevent.<BR/><BR/>* The code is just overwhelmed by the SwingWorker stuff. I'd actually take it out, at the expense of the demo actually being "wrong" because it will confuse the newbie reader.<BR/><BR/>* be consistent: You used the JDK1.5 foreach construct in process(), also use it in doInBackground().Unknownhttps://www.blogger.com/profile/01529480676361880188noreply@blogger.com