Scala, Java, Unix, MacOS tutorials (page 390)
Java Swing drag and drop FAQ: How do I get Java/Swing image drag and drop working on Mac OS X?
I've been working on several new Swing applications for Mac OS X recently, and most of these applications include features like image processing, copy and paste clipboard interaction, and in today's example, dealing with drag and drop events on the Mac.
Update (August, 2010): This website no longer runs under my earlier Java servlet/JSP blog code, so the JSP calendar I used to have running here is not running any more. That being said, I am still sharing my JSP calendar source code, as it still works just fine.
My JSP calendar source code
As I've mentioned in other blog posts, I like my servlet/JSP calendar approach for the following reasons:
Just poking around the internet, I see that Google is providing an "early release" of the Chrome browser for Mac OS X. They have several warnings about privacy concerns, but if you'd like to see what's coming, it might be worth a look. I just took it for a spin, and while it seems pretty basic, it didn't crash, and it seems pretty quick.
In an earlier blog post I shared a small section of Java code that showed how to place an image on a JLabel.
A frequently asked Java question is, "How can I tell what version of Java is running my program?"
Answer: Just use this line of source code to determine the version of Java that is running your program:
Java AppleScript FAQ: How can I run a multiline AppleScript script from a Java application?
If you ever need to run a multi-line Applescript command from a Java program, fear not, it can be done.
A Java AppleScript example
Here's an example of some Java code that runs multiple lines of Applescript, six to be precise:
I've been doing a lot of work with Java and images on Mac OS X lately, and I thought I'd share a Java method I use to get an image off the clipboard. I won't get into the details of working with an Image or a BufferedImage in this tutorial, but I will show you how to get the Image off the clipboard.
Java Mac keystroke FAQ: How do I write Java KeyStroke code for Mac OS X systems?
When I switched from "Java programming on Windows" (or Linux) to "Java programming on a Mac", I quickly learned that I was going to have to change the way I bound my keystrokes for handling key-driven events (things like keystroke-driven popup menus, mnemonics, or accelerator keys). On Windows systems I used to write key-binding code like this:
Summary: An Ant date and timestamp (tstamp) task example.
I was just digging through some Ant build scripts I've created, and I noticed a segment of a build script that first creates a timestamp, and then uses that timestamp in the process of creating a manifest file. (This build script is used for building a Java Swing application.)
Here's the code from my Ant script that does this timestamp magic:
Here’s a quick snippet of code from an Ant build script that demonstrates how to create a classpath variable in an Ant script, where the classpath is built from all of the jar files in your project’s lib folder:
Summary: This tutorial shows how to use a list of jar files in a lib directory to create a dynamic classpath you can write to a manifest file using an Ant build script.
In this tutorial I'd like to demonstrate how to convert a list of jar files in a standard lib directory into a classpath string you can use to define a manifest file in an Ant build script. By converting this list of jar files into a classpath string, the build process for your jar file can depend on any number of external jar files, and you can create this classpath dynamically.
Summary: How to build an executable jar file that has dependencies on other jar files.
If you ever need to create an executable jar file that has dependencies on other jar files, this tutorial is for you. I'll show you ever thing you need to do -- including the use of an Ant build script -- so your users can just type something like this at the command line:
java -jar my-application.jar
to run your Java application.
Many times when you're working with Java servlets and JSP's, you'll want to forward some piece of information from your servlet to your JSP without having to put that piece of information into the session. For instance, in many applications you may not have a user session, and in other cases where you do have a session, you may just not want to put a bunch of junk in there.
Note: This approach is very old; Java/JSP scriptlets were deprecated a long time ago. I don't have time to update this article to the correct, modern approach, but I hope this JSP session example will point you in the right direction.
Every once in a while I'm asked something like, "How can I tell if I have a valid user session in my JSP code?"