Here's an example of some code where I'm detecting when a user selects a tab in a JTabbedPane. There are pretty much just three important pieces of code, and I've labeled those with comments and the numbers 1, 2, and 3.
Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X
Here is a quick example of how to set JTable column widths. I don't know if this is a perfect solution, but it is one possible solution:
Help, I need to install a Perl module, and I need to know what my Perl "include" path (library path) is?
Here's a simple way to print your Perl include path from the command line:
perl -e "print qq(@INC)"
You can just run that command from the Unix/Linux or DOS command line. The output I get from this command on my Windows PC looks like this:
C:/Perl/lib C:/Perl/site/lib .
The output I get on a nearby Linux server looks like this:
Summary: This is a brief discussion about how to debug a JBuilder OpenTool. Debugging an OpenTool is not at all like debugging normal Java code, and a special technique is required, specifically starting one instance of JBuilder from an existing JBuilder environment. These notes apply to JBuilderX, and may not work for other versions.
Here are a couple of quick tips related to the development of JBuilder OpenTool's. I just started working with the JBuilder OpenTool API this weekend, and it seems relatively easy to get a handle on.
I recently started creating a few OpenTools for JBuilder. One of the instructions you see when you first start creating an OpenTool is that you need to modify your JBuilder classpath during OpenTool development so the classpath includes the location of your OpenTool files. But, the instructions I found were for old versions of JBuilder (that were no longer valid), which leads to the question "How can I modify the JBuilder
CLASSPATH to recognize the location of my custom class files?"
So, you're creating a JBuilder OpenTool (using the JBuilder OpenTool API) and
you want to use a properties file to configure your OpenTool. Knowing the way
OpenTools are installed within the JBuilder environment, you come to the
conclusion that the best place to store that properties file is in the "
directory under the JBuilder installation directory. That being said, how do you
access that directory from within your OpenTool?
Note: You can use the Java program below for this task, especially if you’re not using MySQL, but if you are using MySQL, you can use this query instead:
Me: "I'd like the #8 (a taco, chili relleno, beans, and mexican salad) with no beans please." (Thinking to myself that this is just too much food, and since I'm trying to cut down my proportions I decide to skip the beans.)
Five minutes go by ... the waiter comes back with a taco, a chili relleno, a mexican salad ... and rice. Apparently saying "no beans" means "rice".
How often are you stuck in a dualistic world like this, unable to see another option? How often do you not communicate well?
Java current directory FAQ: Can you share an example of how to determine the current directory in Java?
You can determine the current directory your application is started in using Java's
System.getProperty() method and the
user.dir property, like this:
Wow, this was a tough LaTeX problem, and it would really help if I knew a lot more about LaTeX.
My goal for a LaTeX PDF that I created recently was to get the header of my pages to look something like this:
Section Name (Chapter Name)
where "Section Name" and "Chapter Name" are left-aligned in the header of the page, and would be dynamically replaced by the actual values of the current section and chapter names, respetively.
Summary: Use the LaTeX soul package to highlight text in a LaTeX document.
Suppose you want to provide a highlight color or background color for text in a LaTeX document. A good example is when you want to highlight the background yellow, so it looks like it was highlighted with a marker, to catch a reader's attention. "How do you do this in LaTeX?" you ask.
Normally I like to answer "simple", but in this case there is a multi-step answer. It's still pretty easy, but you'll need to download a package named "soul".
LaTeX table/figure FAQ - How do I reference a table or figure in a LaTeX document?
Being able to automatically reference a figure within a LaTeX document is a very cool thing. This referencing capability lets you easily give readers the exact number of a figure, or tell them what page number a figure is located on with the use of a few simple commands (
\pageref). The same technique works for referencing other objects within a LaTeX document, including tables and equations.
Here's an interesting page at Wikipedia, where they discuss all of the caching things they've implemented to improve performance:
Here's a Bourne Shell (sh) script I use to run a Java anti-spam program I wrote. The program I'm running isn't important, but what is worth sharing about this shell script is how I dynamically build the Java CLASSPATH by including all of the jar files in the lib directory.
Other parts of the shell script (showing a shell script for loop) may be worth sharing as well, but I think that building the Java classpath dynamically in the shell script is probably the most important part.
With that being said, here's the shell script:
Someone asked me the other day how they could search for files with different names with one Linux
find command. They wanted to create a list of all files that ended with the extensions .class and .sh.
Although this is actually very easy to do with the
find command, the syntax is obscure and probably not well documented, so let's look at how to do this.
Here's a link to a a quick tutorial/tip I wrote on using the Java Preferences API. I had never used it before, but got this example working in less than 15 minutes (so you know it's pretty easy).
Linux shell script FAQ: Can you share a Linux shell script while loop example? While you're at it, can you show how to use the sleep command in the shell script while loop?
Sure. As a little background, I've written a program I call an Email Agent that periodically scans my email inbox, and does a lot of things to the inbox, including deleting the over 6,000 spams that I receive in a typical day. A recent problem with the Agent is that it runs too fast, apparently overwhelming the sendmail process on the machine that it runs on.
As each day passes I use Cygwin more and more. One of the things I like to do on Unix platforms is to control what my command prompt looks like. On Cygwin, I edited my
.bash_profile to include a multi-line entry like this:
PS1=' $PWD yo: '
This may look bizarre, but I like the results. It makes my command line prompt look like this: