I'm just starting to get into making my Java/Swing application look and feel a lot more like a native Mac application. I've created two earlier posts on this topic already, including Making your Swing application look like a Mac application, and Putting your JMenuBar on the Mac menu bar.
Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X
I've been working hard lately to get a lot of ideas out of my head and onto the blog. Here's a summary of what I've posted recently on the Unix/Linux side:
cp command lets you copy one or more files or directories. To be clear, the
cp command makes a duplicate copy of your information, whereas the
mv command moves your information from one location to another.
Let's take a look at some Linux cp command examples.
Simple file copying
Using a Linux or Unix system, to copy a file named "foo" to a new file named "bar" just type:
grep command is used to search for text. The name "grep" means something like "general regular expression parser", and if you look at the grep man page it says "print lines matching a pattern". I always tell people that if they don't like the name "grep" they can think of it as "search" instead.
In "grep tutorial", we'll share a number of grep example commands. Let's get started.
cd command is used to navigate around the Linux filesystem. In this post I'll show the most common uses of the
To move to another directory on the filesystem just use the Linux
cd command to move to the desired directory. For instance, this command:
moves you to the
/tmp directory, and this command:
would move you to a directory named
/foo/bar, assuming that directory existed.
As I've started to work on designing an HTML editor I'd like for the Mac platform, a little irony has set in: I find that I don't want to write it in Objective C. Given my history with Java, I find that I don't want to be tied to one platform, even Mac OS X. What if I install Ubuntu later this week (as scheduled) and fall madly in love with it? I want my application to work there also.
Just looking through some old code for a Java/Swing editor I started writing years ago, I saw this line of code that I added specifically for the Mac OS X platform:
Here's a brief list of some of the most obvious, and important, team-level best practices I know for software development:
Linux ls command FAQ: Can you share some examples of the Unix/Linux
ls command is used to list files and directories. While it has many options, I thought I'd list the most common ls command uses I'm aware of.
ls command options I use most of the time are
-a ("show all") and
-l ("long listing"). Put together, like this:
Using command-line expansion
Now, if I'm really cool, I don't actually type out that whole remove command, do I? As a practical matter I usually just type in something like this:
and then hit the [Tab] key, and if "delete.me" is the only file in the current directory beginning with the characters "de" the Unix system expands my command line to look like this:
Pretty cool, eh? That part is called "command-line expansion", and it makes life very easy.
Looking at file contents with the "more" and "cat" commands
If I want to be sure that I have the right file I can also look at it with the
more command, like this:
Question: How do I set my Java/Swing application to use the native look and feel of the platform it is running on?
Answer: Use the Java UIManager class to set the look and feel properly, like this:
Note that the
setLookAndFeel method can throw an
UnsupportedLookAndFeelException exception that you should handle.
Mac Java menubar FAQ: I'm creating a "Mac Java" application for (a Java Swing application for Mac OS X) ... how do I put my Java menu bar (JMenuBar) on the Mac menubar?
Answer: In your Java Mac application, set the system property
true, like this:
Here's a simple Ruby program that opens a text file, then uses a series of simple algorithms to look for hidden words in the text. For instance, it looks at only odd words, only even words, then looks at Nth characters, Nth words, and also Fibonacci words and characters.
Logging in to a remote system
To login to that system I'll use a command named
ssh, which stands for "secure shell". It's basically an encrypted login session to a remote system. To login to that remote system I'll type this command in my terminal window:
(Of course everything after the ssh command there is made up. I don't have a login account on any systems named anything like that.)
Quick Start: A typical login session
In my previous post I talked about the history of the Unix and Linux operating systems to give you a little background for the rest of this lesson.
Next, I'd like to dig in and show you what a typical Unix login session looks like, and then I'll get into more details after that.
I thought I'd take a little time and write a tutorial on how to get started with the Linux, Unix, and Mac OS X operating systems. As I write this I'm trying to keep in mind a friend of mine who works strictly on Windows, so I'm writing this from that perspective.
Here then is my "Getting Started with Linux and Unix" tutorial.
I just updated my "Software career best practices 101" post from a few years back. It was a little dated, and hopefully now it's a little refreshed.
I just updated an old Postgresql blog entry about how to make a backup of a Postgresql database. The syntax changed quite a bit since that post in 2004.