Applications linked to this framework have no external dependencies (other than Mac OS X itself). A source-code only distribution synced up to version 0.6.1 is available for GNUstep for use on Linux and other Unix platforms.These include receiving notifications from the OS when a user opens a file specific to your java application, apple macintosh specific user interface guidelines.Prepare a project Create a new Java projectIt’s massive, so start downloading it now. Grab it from the App Store, and then grab a coffee or play with your kid or dog.On Mac applications are just special kinds of folders that act like a single file.In IntelliJ IDEA, a project helps you organize your source code, tests, libraries that you use, build instructions, and your personal settings in a single unit.If the Welcome screen opens, click New Project.Otherwise, from the main menu, select File | New Project.In the New Project wizard, select Java from the list on the left.To develop Java applications in IntelliJ IDEA, you need the Java SDK ( JDK).If the necessary JDK is already defined in IntelliJ IDEA, select it from the Project SDK list.If the JDK is installed on your computer, but not defined in the IDE, select Add JDK and specify the path to the JDK home directory (for example, /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk).If you don't have the necessary JDK on your computer, select Download JDK. In the next dialog, specify the JDK vendor (for example, OpenJDK), version, change the installation path if required, and click Download.We're not going to use any additional libraries or frameworks for this tutorial, so click Next.Don't create a project from the template. In this tutorial, we're going to do everything from scratch, so click Next.Name the project, for example: HelloWorld.If necessary, change the default project location and click Finish.Together with the file, IntelliJ IDEA has automatically generated some contents for your class. In this case, the IDE has inserted the package statement and the class declaration.This is done by means of file templates.They have the Java 2 Standard Edition (J2SE) v1.3.1 pre-installed on their computers and may not even know it. There is a market full of millions of potential customers for your Java application that you may not be considering. For more information on how to use and configure templates, refer to File templates.The Project tool window Alt+1 displays the structure of your application and helps you browse the project.In Java, there's a naming convention that you should follow when you name packages and classes.
Whether or not you develop on a Mac, take the time to make a small number of changes to your application so that you provide a Mac-like experience for the millions of potential customers who already use Mac OS X. The Mac is a great platform for Java developers with a wide array of commercial, free, and open source development tools available. Check a checkbox and you've enabled the built in Apache server. Developers can pop open a Terminal window and find that their favorite geek tools like vi, emacs, and the Java command line tools are already installed. In this article we'll look at some of the runtime properties you can set to move the position of the main menu bar, customize the Application menu, and tweak the appearance of the frame components. There are three phases to making your application feel more like a native Mac OS X application when running on a Mac without changing the look and feel on other platforms. After all, the end users don't care what language an application is written in any more than you care if this article is drafted in longhand, on a typewriter, or on a TiBook. Providing the tools that developers need on the platform is already bringing new first class applications to Mac OS X. Even at consumer shows such as MacWorld, Jobs lets audiences know that Apple is the leading supplier of UNIX in the world. Included in Apple's operating system is both the JRE and JDK for J2SE v1.3.1. On the other hand, every version of Mac OS X is a system ready to run your Java application. As a Java developer, you might dismiss this as still being a small percentage of the personal computer market. In the third article, we'll look into packaging and deploying your Java application so that users don't have to think about jar files, shell scripts, or opening a Terminal window.At his July 2002 MacWorld Expo keynote, Apple CEO Steve Jobs reported that there were two and a half million Mac OS X users and that by the end of the year there will be five million users. On a Windows machine, use your favorite utility to expand the. Head to the JUnit homepage and download the latest version. I like using JUnit as an example because, as we'll see, it was clearly not written on or for a Mac but we can easily customize it to look more Mac like without touching any code. After instructing the viewers to take the machine out of the box and plug it in, the announcer laughed to himself that "there is no step three." In some ways, bringing your Java application to Mac OS X is that easy.Let's start by running the open source unit testing application JUnit on Mac OS X. There is no step threeYou might remember Apple's ad for how easy it was to set up and connect to the internet with iMac. With UNIX underneath you can open up a Terminal window and run JUnit from the command line the same as you would on a Windows box. You should see something like this:It may surprise you to discover that you can follow the exact same steps on a Mac. Junit.swingui.TestRunnerThe Swing version of the JUnit TestRunner will start up and run the tests referenced in the class junit.samples.AllTests. Run JUnit with this command:Java -cp junit.jar. Packaging A Java Application Zip File ToSecond, you need to change the semi-colons that are used in Windows to separate files in the classpath with colons, the standard UNIX separator. First, you don't need to worry about installing the JRE - it's part of the OS. You can avoid these problems by using the jar utility or gunzip.There are a couple of differences in running JUnit on Mac OS X. Although the Mac does come with the Stuffit expander, earlier versions had problems with files with long names and so some of the inner classes in JUnit will be renamed when they are expanded. After downloading the JUnit zip file to your Mac, use the jar utility to expand it. It will also be blue and not green. In fact, with the latest version of JUnit, the bar may be more three dimensional. You see the buttons and tabs and scroll bars help this application look as if it were written for Mac OS X. If you don't specify a look and feel for your Java application, the Aqua look and feel is used as the default on Mac OS X. Junit.swingui.TestRunnerWithout any changes, JUnit on Mac OS X looks like this:We get a lot for free. Set the system property com.apple.macos.useScreenMenuBar to have the value true. Ideally, if you are writing a Java application that targets both platforms (and perhaps others), you would like it to feel like a Windows application on a Windows machine and like a Mac application on a Mac.Fortunately, Apple has made it easy for you to customize the location of your menu bar when running on a Mac while leaving it where it is in the other look and feels so long as you have a top level JFrame for which you have assigned a menu bar using the setMenuBar() method. This is a religious issue and neither side is likely to convince the other. To a longtime Windows user this may seem crazy while to an experienced Mac user the top of the screen is the natural location for a menu bar. Moving the menu barOn a Mac, application menu bars belong at the top of the screen. Let's see how we can improve on this by setting some runtime properties. The JUnit menu bar in its proper place More tinkering with the menu barWhile we're here, let's look a little closer at the Application menu. The JUnit menu bar within the JFrameFigure 4. In the second, the system property has been set and the JUnit menu moves to the screen menu bar next to the Apple and the Application menus.Figure 3. In the first, the system property hasn't been set and the JUnit menu appears within the JFrame. -Dcom.apple.macos.useScreenMenuBar=trueJunit.swingui.TestRunner junit.samples.AllTestsCompare the two images below. Of course you can add as many of these as you'd like. -Xdock:name="JUnit on Mac OS X"To keep the command line from getting overloaded with too many options we're only experimenting with one parameter at a time. We can change this name in both locations by setting the -Xdock:name parameter.As an example we could change it to JUnit on Mac OS X like this:Java -cp junit.jar. This is also the name displayed when we mouse over the application icon in the dock. In this case the application is the name of the class we're running: junit.swingui.TestRunner. It appears just to the right of the Apple menu (the menu underneath the Apple logo). ![]() You can set the name for this item and have it automatically added to the Application menu by setting the system property com.apple.mrj.application.apple.menu.about.name like this:-Dcom.apple.mrj.application.apple.menu.about.name=JUnitThe good news is that now there is an "About JUnit" item in the Application menu. When they key in Command-H the application hides and can be unhidden by clicking on the icon in the Dock.The one element usually found in the Application menu that hasn't been created for you is an About menu item. When they key in Command-Q the Application quits (in this case by calling System.exit(0)). In fact, without any coding on your part, hiding and quiting behaves as the user expects for any Mac OS X application. So after a quick look at the menu with the "About JUnit" item, we'll forget all about this option until next time.Figure 7. Even though JUnit comes with an About box, we need a little bit of code to wire this up properly.
0 Comments
Leave a Reply. |
Details
AuthorRebecca ArchivesCategories |