Monthly Archives: January 2012

Opening files with native applications across multiple platforms

I was working on a project, which required the ability to export the contents of the table as a Microsoft Excel file. After saving the file, the file had to be open immediately by Microsoft Excel. However this is multi-platform application and needed to support at least Windows, Mac and Linux. What if the user didn’t have Microsoft Excel installed, but they did have another program capable of editing/viewing Excel files? Users may have installed alternatives such as Open Office, Libre Office, and Microsoft Office for Mac. How can a Java Swing program invoke an unknown native program without having to program to every native executable? After searching the web, there was an elegant solution.

READ MORE »

Do more with JPopupMenu

Java Swing’s JPopupMenu is very versatile for displaying any type of information. It can be used for more than just display a popup menu. JPopupMenu inherits all the features of java.awt.Container including the ability to set a LayoutManager and add one or more arbitrary java.awt.Component.

Below are two examples demonstrating how to use a JPopupMenu to “popup” more complex components. The first show a popup with an array of buttons and the second example shows a popup whose content is a table.

READ MORE »