------------------The MacOS Look and Feel---------------------- Actual version: 0.34 (29 January 2001) compatible Swing 1.1.1 final Name and description: public String getName() { return "MacOS"; } public String getID() { return "MacOS"; } public String getDescription() { return "The Apple Mac OS(tm) Look and Feel"; } Contributors (old e-mails should be checked): Bradley Smith (bsmith@banta-im.com) Jason Giles (jgiles@chaoticsoftware.com) Michael Heuer (heuermh@shore.net) David Himelright (vitriol@mindless.com) Luca Lutterotti (Luca.Lutterotti@ing.unitn.it) David Ayman Shamma (dshamma@ai.uwf.edu) Mike Hall (mikehall@spacestar.com) Philip Weaver (philmaker@earthlink.net) Daniel Bobbert the Swing team (thanks to Tom Santos and Steve Wilson to provide the original Mac L&F) many others from the MRJ-dev list. My apologies if I forgot someone (drop me a note in case), but I am very well known for my brilliant short memory. Included in the package: - macos.jar the MacOS L&F archive including Swing modified classes - it source code folder for MacOS L&F - swing src source code folder for Swing modified classes - Swing.properties usage how to use the swing.properties file included in "put in MRJ Libraries/lib" - MacOSreadme.txt this file - put in MRJ Libraries/lib folder containing the swing.properties file for MacOS --------------------- Instructions ------------------------------- 1) If you don't have it download the Swing package from Sun and install it: http://java.sun.com/products/jfc/ 2) drag the swing.properties file contained in the folder "put in MRJ Libraries/lib" in System Folder:Extensions:MRJ Libraries:lib this will let's now to the swing application which L&Fs are availables. 3) put the macos.jar in your classpath System Folder:Extensions:MRJ Libraries:MRJClasses for the Mac or specify his location in the JBound application (see notes below) Notes: The MacOS Look and Feel works on the Macintosh with MRJ 2.1 or later but also under any JVM 1.1 or later compatible. The patched swingall.jar archive is no more needed for the MacOS L&F to work, it use instead the standard swingall.jar archive available from the Swing Connection: http://java.sun.com/products/jfc/ The Swing modified classes are included directly in it. The only important requirement is that the macos.jar must be loaded from the JVM before the swingall.jar so it will use the modified Swing classes. This can be done on the Mac by putting the macos.jar in the System Folder:Extensions:MRJ Libraries:MRJClasses folder or in the JBindery (or JBound) application by putting the macos.jar before the $CLASSPATH field (use arrows for that). Two techniques can be used by the programmer: Simpler: in your source code you should put a line like: try { // Using the macos.jar on the Mac the MacOS L&F is the System L&F UIManager.setLookAndFeel(UIManager.getSystemLookAndFeel()); } catch (Exception exc) { System.err.println("Error loading L&F: " + exc); } or try { UIManager.setLookAndFeel("it.unitn.ing.swing.plaf.macos.MacOSLookAndFeel"); } catch (Exception exc) { System.err.println("Error loading L&F: " + exc); } at the beginning of your program or applet, to use this look and feel. Or much better: have a look at the following example on how to switch between different L&Fs using the swing.properties file definitions (you don't need any more to change your source code to add a new L&F). In the future any user may change the swing.properties file and add his preferred L&F independently from the program. To know which L&Fs are installed in your application you need to call the UIManager.getInstalledLookAndFeels() method. The example build a menu for the different L&Fs (as from the swing.properties file) and manages all the necessary switching. If a swing.properties file is not available only the default L&Fs (Mac, MacOS, Metal, Motif and Windows) will be availables. ---------------------- example -------------------------------------- JMenu options = (JMenu) menuBar.add(new JMenu("Options")); options.setMnemonic('o'); options.getAccessibleContext().setAccessibleDescription("Look and Feel options: select one of several different Look and Feels for the SwingSet application"); // Look and Feel Radio control ButtonGroup group = new ButtonGroup(); UIManager.LookAndFeelInfo[] LFs = UIManager.getInstalledLookAndFeels(); int lfsnumber = LFs.length; JRadioButtonMenuItem lfsMenuItem[] = new JRadioButtonMenuItem[lfsnumber]; for (int i = 0; i < lfsnumber; i++) { lfsMenuItem[i] = (JRadioButtonMenuItem) options.add(new JRadioButtonMenuItem(LFs[i].getName())); group.add(lfsMenuItem[i]); lfsMenuItem[i].setSelected(UIManager.getLookAndFeel().getName().equals(LFs[i].getName())); lfsMenuItem[i].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1 + i, ActionEvent.ALT_MASK)); lfsMenuItem[i].addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Component root = SwingSet.sharedInstance().getRootComponent(); root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JRadioButtonMenuItem rb = (JRadioButtonMenuItem) e.getSource(); try { if (rb.isSelected()) { UIManager.LookAndFeelInfo[] tmpLFs = UIManager.getInstalledLookAndFeels(); int tmplfsnumber = tmpLFs.length; for (int j = 0; j < tmplfsnumber; j++) { if (rb.getText().equals(tmpLFs[j].getName())) { currentUI = tmpLFs[j].getName(); UIManager.setLookAndFeel(tmpLFs[j].getClassName()); SwingUtilities.updateComponentTreeUI(getRootComponent()); } } } } catch (Exception exc) { // Error - unsupported L&F rb.setEnabled(false); System.err.println("Unsupported LookAndFeel: " + rb.getText()); } root.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); } -------------------------------------------------------- Also: - If you need more than one menuBar per Frame (like in the SwingSet example) I added a trick. From version 0.33 the setPrincipalMenuBar method has removed to be more compliance with the standard Swing and instead the MacOS L&F set the first MenuBar created on a frame as the principal (go at the top of the screen) and all the others become secondary menuBars and are inside the frame. Look at the SwingSet example (in the javaonMac web page also) for how it works. - If you add to the menuBar a Menu with the text starting with "Help", like: new JMenu("Help"); the MacOS L&F will put this menu in the Mac help menu. You will not get two help menus. ------------ Principal features -------------- This L&F was derived by the Mac L&F from the Swing Team Components modified: - progressBar - tabPanel (it supports now also tabs placed on the left, right and bottom). - default button - textFields - comboBox (out of the frame) - Some borders - FileChooser - Tree - icons - many others Components added: - a real Mac menuBar on top of the screen including CheckBox and RadioButtons. - support for Mac OS appearance (theme colors, smart scrolling....) History: Version 0.34 (January 2001) - MacOSFileChooser got the accessoryPane (for preview etc., see the SwingSet example) that was missing (thanks to Jarek for this). - Enhancements by Daniel Bobbert to solve the following problems: deactivated JScrollbars do not draw right JOptionPane does not look Mac-like so also a new class MacOSOptionPaneUI was added. - Workaround by Mike Hall to solve a problem of the MacOSMenuBarUI receiving a null menu component in JEdit 3.0. Version 0.33 (October 2000) - Code for MacOSMenuBarUI rewrited and simplify. Corrected a bug for JDialogs and on uninstalling. Method setPrincipalMenuBar removed (see notes above). Reduced the number of hacks in the swingall as well as the listeners created. - A double scrollbar's decrease button does not have a separator if the scroll bar is disabled. The bug has been corrected by Philip J. Weaver. Version 0.32 (September 2000) - Modified by Mike Hall the native Appearance approach to made it working with the new Universal headers (September 2000) from Apple - Corrected a bug preventing the Appearance to work with double dots system versions (like 9.0.4). No error was visible, the MacOS L&F was just using the default Lavender accent. - JComboBox fixed to display the comboBox out of a frame also. - Fixed a bug preventing disposed frames or dialogs with a MenuBar to be garbage collected. Version 0.31 (May 2000, not public release by mistake) - Modifications by D. A. Shamma for dynamically order JMenu, JMenuItems and JSeparators. - Mnemonics, accelerators behaviour modified, so now it's more mac like. To use mnemonics like in Windows it is necessary to call: MacOSLookAndFeel.useMnemonics(true); by default the setting is false and setting mnemonics has no effect on the Mac. - Now JMenuItem and Menu components return the String set by setActionCommand. - Starting to add some documentation and comments. - Using setSelected on JRadioButtonMenuItem now works correctly. Version 0.30 - The MacOS L&F don't need any more the patched swingall.jar, the standard swing library from the Swing can be used safely. - Added the Mac L&F in the swing.properties file (what a fault before...). - Both the Mac and the MacOS are registered L&Fs (the MacOS only if the macos is in the classpath of the program and loaded before the swingall.jar). - Changed the package name from com.sun.java.swing.plaf.macos to it.unitn.ing.swing.plaf.macos This was necessary to respect the standard naming convention. The MacOS L&F is not a package distribuited by Sun or Sun representative. Using the swing.properties file, you need just to use the new one provide in the package, otherwise just change the MacOS L&F calls in your program. Version 0.29 (Internal version, not released) Version 0.28 - Corrected another bug in the MacOSTreeUI; some icons changed for a better look. - Hacked again the swingall.jar to permit the use of 'alt'+key characters. Will works only for the MacOS, unchanged for the other L&Fs. Version 0.27 - Corrected a bug in the MacOSTreeUI causing incorrect mouse event behaviour and another not checking properly null pointer for icons (thanks to David Hobley). Version 0.26 - Corrected a bug that was using the JMenuItem.getText() as return action command instead of the correct actionCommand string. - The doublearrows separation line now is visible. Version 0.25 - Corrected a bug preventing it to work on Mac OS version prior to 8.5. Version 0.24 - Recompiled for the Swing version 1.1.1 final - The MacOS L&F now recognise if the arrows are both at one end in the ScrollBar (only when the MacOS L&F is loaded the first time by the application and MacOS 8.5 or later). There is a cosmetic bug preventing to see the separation black line between the arrows. Also the thumb is proportional in this case. - Mnemonics are translated to use the apple (command) button instead of the ctrl button as modifier. Version 0.23 - Waiting for the next Swing release...... - Corrected bug in the JFileChooser causing a wrong creation of the directory tree in the first appearance of the MacOS filechooser. - Corrected a bug causing the disappearing of some JSeparators. - Now the command action in the Menu is not altered and constrained to the menu label. Version 0.22 - Swing 1.1.1 beta2 compatible. - JScrollPane have a Mac border. Version 0.21 - More Icons in the iconFactory (David Himelright) for speed improvement and appearance support. Arrows in the JTree, RadioButtons. - SplitPanel support when the panels don't have a border (added a bump by Michael Heuer). This is at the moment a very quick hack with direct cut-n-paste from the MetalL&F. - SpliPanel bumper in MacOS frameBar style (it's an acceptable style?). - Added TreeNode and TreeLeaf Icons to the IconFactory (LL). Now the selected node and leaf change color. Due to a bug in the MRJ the Node Icon (a folder icon) is not represented correctly (some white spots). - JFileChooser fixed. Missing support to show only visible files, the eject button and the filter comboBox. Filtering is only extension based. ------------ Know issues -------------- - Icons not supported (not visibles) in the menuBar - In the menuBar Alt, Cmd and Ctrl KeyEvents are translated in the Mac Option Key modifier. The Shift is supported as an addition to the modifiers. - All the modifiers and icons are supported and not translated if the menuBar is bounded to the frame (using jmenubar.setPrincipalMenuBar(false);); but in this case the jmenubar will appear in the frame and not on top of the screen. - The creation of Menu and MenuItems cause the creation of some listener. Thus the modification of some menu Component properties may cause the generation of some Events. It is adviced to add the listener for menu actions after the setting of the Menu Components has finished (it's a good programming practice in any case). - Work with the standard swingall.jar from Swing only if the macos.jar is loaded by the JVM before the swingall.jar; see above in this document. - Radiobuttons and checkBoxes don't have the final appearance but the old Mac style. When icons will be supported also the appearance will be the one for the MacOS. -------------------------------------- Send bugs or suggestions to: Luca.Lutterotti@ing.unitn.it