⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helppopupbase.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
字号:
/* * HelpPopupBase.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.executequery.gui.help;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Component;import java.awt.Font;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseEvent;import javax.swing.BorderFactory;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.Popup;import javax.swing.PopupFactory;import javax.swing.SwingUtilities;import org.executequery.GUIUtilities;import org.underworldlabs.swing.GlassCapturePanel;import org.underworldlabs.swing.GlassPaneSelectionListener;import org.underworldlabs.swing.LinkButton;/** * * @author   Takis Diakoumis * @version  $Revision: 1.5 $ * @date     $Date: 2006/09/06 09:30:58 $ */public class HelpPopupBase extends JPanel                            implements ActionListener,                                      GlassPaneSelectionListener {        /** the popup owner */    private Component owner;        /** the owner's original glass pane */    private Component ownersGlassPane;        /** the temp glass pane added to the owner */    private GlassCapturePanel glassPane;        public HelpPopupBase(String title,                          Component viewComponent,                          MouseEvent e) {        this(title, viewComponent, null, e);    }    public HelpPopupBase(String title,                          Component viewComponent,                          Component owner,                          MouseEvent event) {        super(new GridBagLayout());                this.owner = owner;                if (owner instanceof JDialog) {            JDialog dialog = (JDialog)owner;            ownersGlassPane = dialog.getGlassPane();            glassPane = new GlassCapturePanel(dialog.getContentPane());            dialog.setGlassPane(glassPane);            glassPane.setVisible(true);        }        glassPane.addGlassPaneSelectionListener(this);                JLabel titleLabel = new JLabel(title);        Font font = titleLabel.getFont();        titleLabel.setFont(font.deriveFont(Font.BOLD));        LinkButton linkButton = new LinkButton("Hide");        linkButton.setAlignmentX(LinkButton.RIGHT);        linkButton.addActionListener(this);                GridBagConstraints gbc = new GridBagConstraints();        gbc.insets.top = 3;        gbc.insets.bottom = 3;        gbc.insets.left = 4;        gbc.insets.right = 5;        gbc.gridy = 0;        gbc.gridx = 0;        gbc.anchor = GridBagConstraints.NORTHWEST;        add(new JLabel(GUIUtilities.loadIcon("TipOfTheDay16.gif")), gbc);        gbc.gridx++;        gbc.insets.left = 0;        gbc.weightx = 1.0;        add(titleLabel, gbc);        gbc.gridx++;        gbc.insets.right = 5;        gbc.anchor = GridBagConstraints.EAST;        add(linkButton, gbc);        gbc.gridx = 0;        gbc.gridy++;        gbc.weighty = 1.0;        gbc.insets.left = 5;        gbc.insets.right = 5;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.gridwidth = GridBagConstraints.REMAINDER;        gbc.fill = GridBagConstraints.BOTH;        add(viewComponent, gbc);                setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));        showPopup(event);    }    public void glassPaneSelected(MouseEvent e) {        int id = e.getID();        switch(id) {            case MouseEvent.MOUSE_PRESSED:            case MouseEvent.MOUSE_CLICKED:            case MouseEvent.MOUSE_DRAGGED:            case MouseEvent.MOUSE_RELEASED:                hidePopup();                return;        }    }        public void actionPerformed(ActionEvent e) {        hidePopup();    }        public void hidePopup() {        try {            if (popup != null) {                popup.hide();            }            popup = null;        }        finally {            if (glassPane != null) {                glassPane.setVisible(false);            }            // replace the original glass pane            if (ownersGlassPane != null) {                if (owner instanceof JDialog) {                    JDialog dialog = (JDialog)owner;                    dialog.setGlassPane(ownersGlassPane);                }            }        }    }        /** the popup panel */    private Popup popup;        public void showPopup(MouseEvent event) {        if (owner == null) {            owner = GUIUtilities.getParentFrame();        }                Point p = SwingUtilities.convertPoint(                                    (Component)event.getSource(),                                     event.getX(),                                     event.getY(),                                     owner);                popup = PopupFactory.getSharedInstance().getPopup(owner, this, p.x, p.y);        popup.show();    }                public void setViewComponent(Component c) {        add(c, BorderLayout.CENTER);    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -