Skip to Content
Swing Hacks
book

Swing Hacks

by Joshua Marinacci, Chris Adamson
June 2005
Intermediate to advanced
544 pages
22h 24m
English
O'Reilly Media, Inc.
Content preview from Swing Hacks
Open Files, Directories, and URLs on Mac OS X #80
Chapter 11, Native Integration and Packaging
|
411
HACK
As another example, cmd.exe /c start version.txt opens a text file in Win-
dows Notepad (assuming that’s the default text file viewer).
cmd.exe /c start
winword.exe version.txt
would open the file in MS Word. This requires
having Word installed, of course, so I would only recommend hardcoding
the program name if you are sure it’s really there.
Open a Directory
The start command can also open a directory as well as a file, meaning it
will open a file manager window showing the contents of that directory.
Program installers often do this after the install is complete to show where
the program was placed. The code in Example 11-4 will open a new
Explorer window showing the contents of the C: drive.
H A C K
#80
Open Files, Directories, and URLs
on Mac OS X Hack #80
Open files, directories, and URLs in external programs right from your Swing
app.
We can’t let Windows have all of the fun. Mac OS X has a similar and even
easier to use program called
open, which lets you open any file, directory, or
web page directly from the command line. This hack shows you how to
embed
open in your own program.
Using Open
Back in the late 80s, NeXT, Inc. created the first true integration between a
graphical user interface and a Unix-like operating system when they released
NeXTSTEP. Part of this OS was a command-line program ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning Swing GUI Programming

Learning Swing GUI Programming

Brian Cole
Java Swing

Java Swing

Robert Eckstein, Marc Loy, Dave Wood
JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour

Publisher Resources

ISBN: 0596009070Purchase bookErrata Page