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

📄 beanpanel.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            if (Debug.debugging("beanpanel"))                Debug.output("BP::BeanHelper:error " + message);            e.printStackTrace();        }        public void error(String message) {            if (Debug.debugging("beanpanel"))                Debug.output("BP::BeanHelper:error " + message);        }    }    private class MyCellRenderer implements ListCellRenderer {        public Component getListCellRendererComponent(JList list, Object value, // value                                                                                // to                                                                                // display                                                      int index, // cell                                                                 // index                                                      boolean isSelected, // is                                                                          // the                                                                          // cell                                                                          // selected                                                      boolean cellHasFocus) // the                                                                            // list                                                                            // and                                                                            // the                                                                            // cell                                                                            // have                                                                            // the                                                                            // focus        {            String s = value.toString();            JLabel label = new JLabel(s);            label.setHorizontalAlignment(JLabel.LEFT);            int i = beanLabels.indexOf(s);            ImageIcon icon = (ImageIcon) beanIcons.get(i);            label.setIcon(icon);            if (isSelected) {                label.setBackground(list.getSelectionBackground());                label.setForeground(list.getSelectionForeground());            } else {                label.setBackground(list.getBackground());                label.setForeground(list.getForeground());            }            label.setEnabled(list.isEnabled());            label.setFont(list.getFont());            label.setOpaque(true);            return label;        }    }    /* DnD Listeners */    private class ComponentDragSourceListener implements DragSourceListener {        public void dragDropEnd(DragSourceDropEvent dsde) {            if (Debug.debugging("beanpanel"))                Debug.output("dragDropEnd (drag)");        }        public void dragEnter(DragSourceDragEvent dsde) {            if (Debug.debugging("beanpanel"))                Debug.output("dragEnter (drag)");            int action = dsde.getDropAction();            if (action == DnDConstants.ACTION_MOVE) {                dsde.getDragSourceContext().setCursor(customCursor);            } else {                dsde.getDragSourceContext()                        .setCursor(DragSource.DefaultCopyNoDrop);            }        }        public void dragOver(DragSourceDragEvent dsde) {            if (Debug.debugging("beanpanel"))                Debug.output("dragOver (drag)");            int action = dsde.getDropAction();            if (action == DnDConstants.ACTION_MOVE) {                dsde.getDragSourceContext().setCursor(customCursor);            } else {                dsde.getDragSourceContext()                        .setCursor(DragSource.DefaultCopyNoDrop);            }        }        public void dropActionChanged(DragSourceDragEvent dsde) {            if (Debug.debugging("beanpanel"))                Debug.output("dropActionChanged (drag)");            int action = dsde.getDropAction();            if (action == DnDConstants.ACTION_MOVE) {                dsde.getDragSourceContext().setCursor(customCursor);            } else {                dsde.getDragSourceContext()                        .setCursor(DragSource.DefaultCopyNoDrop);            }        }        public void dragExit(DragSourceEvent dse) {            if (Debug.debugging("beanpanel"))                Debug.output("dragExit (drag)");            dse.getDragSourceContext().setCursor(DragSource.DefaultCopyNoDrop);        }    }    private class ComponentDragGestureListener implements DragGestureListener {        ComponentDragSourceListener tdsl;        public ComponentDragGestureListener(ComponentDragSourceListener tdsl) {            this.tdsl = tdsl;        }        public void dragGestureRecognized(DragGestureEvent dge) {            if (Debug.debugging("beanpanel"))                Debug.output("dragGestureRecognized");            JList list = (JList) tabbedPane.getComponentAt(tabbedPane.getSelectedIndex());            String label = null;            label = (String) list.getSelectedValue();            if (label != null) {                int index = beanLabels.indexOf(label);                if (index == -1) {                    System.out.println("ERROR> BP::dragGestureRecognized: "                            + "no beanlabel found for label=" + label);                    return;                }//                JarInfo ji = (JarInfo) beanJars.get(index);                String beanName = (String) beanNames.get(index);                Object bean = null;                try {                    bean = Beans.instantiate(null, beanName);                    if (Debug.debugging("beanpanel"))                        Debug.output("Instantiated bean: " + bean);                    setDragCursor(index);                } catch (Exception ex) {                    System.out.println("ERROR> BP::dragGestureRecognized: "                            + " error instantiating bean");                    ex.printStackTrace();                    return;                }                BeanInfo bi = (BeanInfo) beanInfos.get(index);                Vector beanTransferData = new Vector();                beanTransferData.add(bean);                beanTransferData.add(bi);                beanTransferData.add(new Boolean(false));                dragSource.startDrag(dge,                        customCursor,                        new DefaultTransferableObject(beanTransferData),                        tdsl);                revalidate();                repaint();            }        }    }    private class MouseEventForwarder extends MouseInputAdapter {        public void mousePressed(MouseEvent e) {            Component comp = (Component) e.getSource();            Container parent = comp.getParent();            if (parent != null) {                Point newPoint = SwingUtilities.convertPoint(comp,                        e.getPoint(),                        parent);                e.translatePoint(newPoint.x - e.getX(), newPoint.y - e.getY());                MouseEvent me = new MouseEvent(parent, e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());                parent.dispatchEvent(me);            }        }        public void mouseReleased(MouseEvent e) {            Component comp = (Component) e.getSource();            Container parent = comp.getParent();            if (parent != null) {                Point newPoint = SwingUtilities.convertPoint(comp,                        e.getPoint(),                        parent);                e.translatePoint(newPoint.x - e.getX(), newPoint.y - e.getY());                MouseEvent me = new MouseEvent(parent, e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());                parent.dispatchEvent(me);            }        }        public void mouseDragged(MouseEvent e) {            Component comp = (Component) e.getSource();            Container parent = comp.getParent();            if (parent != null) {                Point newPoint = SwingUtilities.convertPoint(comp,                        e.getPoint(),                        parent);                e.translatePoint(newPoint.x - e.getX(), newPoint.y - e.getY());                MouseEvent me = new MouseEvent(parent, e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());                parent.dispatchEvent(me);            }        }    }    private static void setDefaultIcon() {        if (BeanPanel.defaultBeanIcon == null) {            URL url = BeanPanel.class.getResource("bluebean.gif");            if (url != null)                BeanPanel.defaultBeanIcon = new ImageIcon(url);        }    }    private static void augmentBeanInfoSearchPath() {        if (Debug.debugging("beanpanel"))            Debug.output("Enter> augmentBeanInfoSearchPath");        String beanInfoPath = System.getProperty("bean.infos.path");        if (Debug.debugging("beanpanel"))            Debug.output("beanInfoPath=" + beanInfoPath);        if (beanInfoPath == null                || (beanInfoPath = beanInfoPath.trim()).length() == 0)            return;        String[] oldPath = java.beans.Introspector.getBeanInfoSearchPath();        Vector newPath = new Vector();        if (oldPath != null && oldPath.length > 0)            newPath.addAll(Arrays.asList(oldPath));        if (Debug.debugging("beanpanel"))            Debug.output("oldPath=" + newPath);        StringTokenizer st = new StringTokenizer(beanInfoPath, ", ");        while (st.hasMoreTokens()) {            String path = st.nextToken();            if (newPath.contains(path))                continue;            newPath.add(path);        }        java.beans.Introspector.setBeanInfoSearchPath((String[]) newPath.toArray(new String[0]));        if (Debug.debugging("beanpanel"))            Debug.output("UPDATED> beanInfo search path to: " + newPath);        if (Debug.debugging("beanpanel"))            Debug.output("Exit> augmentBeanInfoSearchPath");    }    public static void main(String[] args) {        Properties props = new Properties();        props.setProperty("beanpanel.beans.path", "");        props.setProperty("beanpanel.tabs", "tab1 tab2 tab3");        props.setProperty("beanpanel.tab1.name", "Generic");        props.setProperty("beanpanel.tab1.beans",                "com.bbn.openmap.examples.beanbox.SimpleBeanObject");        props.setProperty("beanpanel.tab2.name", "Container");        props.setProperty("beanpanel.tab2.beans",                "com.bbn.openmap.examples.beanbox.SimpleBeanContainer");        props.setProperty("beanpanel.tab3.name", "Military");        props.setProperty("beanpanel.tab3.beans",                "com.bbn.openmap.examples.beanbox.Fighter");        BeanPanel bp = new BeanPanel(props);        JFrame beanFrame = new JFrame("Bean Box");        beanFrame.getContentPane().add(bp);        beanFrame.pack();        beanFrame.setVisible(true);        try {            Thread.sleep(2000);            beanFrame.setVisible(false);            Thread.sleep(2000);            beanFrame.setVisible(true);        } catch (InterruptedException e) {            e.printStackTrace();        }    }}

⌨️ 快捷键说明

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