java category archive
I made this program to go along with my process for handling incoming digital pictures, but I hope you might find it useful also.
I copy files from my camera in to a working directory, and bulk rename them using my Nautilus script: rename-with-exif-date.sh. This gives me a bunch of files with a timestamp in YYMMDD_HHMMSS format, for example: 071125_090623.jpg.
Next I need to give them additional descriptive tags, and then sort them in to their permanent homes. I like to keep one big directory of originals for each year, and then a smaller subset sorted in to categories, which I might then crop and fix red-eye and etc. Let’s say the end result of a naming/sorting session results in these files:
~/pics/original/2007/
…
by Scott Carpenter on 26 November 2007 at 9:39 pm
Permalink |
Comments (0) | filed under java, programming
|
I’m working on a small application to help me with naming and sorting my pictures, so one of the basic things it needs to do is load and scale an image. Found lots of information here and there on this, and this post is to share what I came up with.
When searching around trying to figure stuff like this out, it’s hard to credit where you found everything. A lot of search results point to forum.java.sun.com, with discussions that are alternatively helpful and abusive to newbie questions. When I started leaning towards a solution based on overriding the “paint” method, one of the forum threads pointed to a good tutorial: “Lesson: Performing Custom Painting,” and an in-depth explanation: “Painting in AWT and Swing.”
The core of this is a class that …
by Scott Carpenter on 11 November 2007 at 8:26 am
Permalink |
Comments (2) | filed under graphics, java, programming
|
Let’s say you have a project with package Example, and in that package you have:
Example.java // troublemaker!
ExampleUI.java // “form” - extends JFrame
LabelExample.java // extends JLabel
One of the cool things about the Matisse GUI Editor in NetBeans is that you can add LabelExample.java as a custom component to the widget palette and then drop an instance of it on your ExampleUI.java form in design mode. NetBeans will generate the source code for you.
However, there is a little hitch. When NetBeans creates the variable declaration, it will use the fully qualified path of your class, in this case Example.LabelExample, and then the IDE (which is chanelling the compiler), will complain with:
That is, here is your generated code block:
// Variables declaration - …
by Scott Carpenter on 10 November 2007 at 8:48 pm
Permalink |
Comments (0) | filed under java, programming, tip
|
Displaying code on a web page can be tricky, and even trickier if you use WordPress. You may have noticed in WordPress that straight quotes turn in to curly quotes, multiple dashes turn in to en dashes and em dashes, and so on. While this may make our posts look prettier, it does ugly things to code formatting.
(See my post from yesterday on HTML Character Entity References for a table of related characters and encodings.)
Hyphen prettification is one example of where you’ll get in to trouble when trying to show some code. Your decrement –i; may get converted to –i;, breaking your code and causing would-be users to hate you. Or String s = "oops"; will become String s = “oops”;, with similarly unhappy copy-and-paste results.
Using the <pre> tag will take care of …
by Scott Carpenter on 4 November 2007 at 11:26 am
Permalink |
Comments (2) | filed under java, wordpress
|
Following up on my previous, surprisingly popular post about NetBeans, I finally wrote a Java GUI program with it. Simple program, but the writing of it confirmed my initial impression that NetBeans will be a good Java IDE for me. I’ve been avoiding the learning curve of Java GUI, but this weekend I thought of something I figured I could manage. It went pretty well, and I’ll be writing another post about the program soon. I still have a lot to learn, but I’m confident now I’ll be able to muddle my way along.
Random bullet points:
I certainly haven’t put the Matisse GUI builder through its paces yet, but I’m still impressed by how robust and full-featured it is.
The overall environment still feels comfortable to me …
by Scott Carpenter on 29 October 2007 at 4:56 am
Permalink |
Comments (0) | filed under java, programming
|
An objection I’ve had to many programming books and web sites is that they don’t make sample code available under a free software license. This is within the rights of the author, of course, but it seems counter to the spirit of teaching and sharing knowledge to restrict the use of example code.
A writer of instructional material may be doing so to earn some money, but I hope he or she is also motivated by the desire to help others. I think the best authors and teachers are motivated strongly by this desire. And if this is the case, I think it reasonably follows that the author of a programming work should want their students to be able to freely use their source code in the students’ own creations.
I was happy to exchange words recently with an …
by Scott Carpenter on 14 September 2007 at 3:15 pm
Permalink |
Comments (0) | filed under ai, books, code, freedom, java
|