1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * 23 * ident "%Z%%M% %I% %E% SMI" 24 * 25 * Copyright(c) 1999 by Sun Microsystems, Inc. 26 * All rights reserved. 27 * 28 * pmHelpFrame.java 29 * Container for help subsystem GUI 30 */ 31 32package com.sun.admin.pm.client; 33 34import java.lang.*; 35import java.awt.*; 36import java.awt.event.*; 37import java.util.*; 38import java.io.*; 39import javax.swing.JPanel; 40import javax.swing.border.*; 41import javax.swing.*; 42import com.sun.admin.pm.server.*; 43 44 45public class pmHelpFrame extends pmFrame { 46 47 protected pmHelpController theController = null; 48 public pmButton dismiss = null; // expose for default button hacks 49 50 public pmHelpFrame() { 51 super(pmUtility.getResource("SPM:Help")); 52 53 theController = new pmHelpController(this); 54 getContentPane().add("Center", theController.getTopPane()); 55 56 dismiss = new pmButton( 57 pmUtility.getResource("Dismiss")); 58 dismiss.setMnemonic( 59 pmUtility.getIntResource("Dismiss.mnemonic")); 60 dismiss.addActionListener(new ActionListener() { 61 public void actionPerformed(ActionEvent e) { 62 hideHelp(); 63 } 64 }); 65 66 JPanel p = new JPanel(); 67 p.add(dismiss); 68 69 getContentPane().add("South", p); 70 71 this.pack(); 72 this.setVisible(false); 73 this.repaint(); 74 75 // default button is dismiss 76 // getRootPane().setDefaultButton(dismiss); 77 dismiss.setAsDefaultButton(); 78 79 // handle Esc as dismiss 80 getRootPane().registerKeyboardAction(new ActionListener() { 81 public void actionPerformed(ActionEvent e) { 82 Debug.message("HELP: dismiss action"); 83 hideHelp(); 84 }}, 85 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), 86 JComponent.WHEN_IN_FOCUSED_WINDOW); 87 } 88 89 90 public void hideHelp() { 91 this.setVisible(false); 92 } 93 94 95 public void showHelp(String tag) { 96 theController.showHelpItem(tag); 97 this.setVisible(true); 98 this.repaint(); 99 } 100 101} 102