} else { frameActions.show(frame.getDesktopPane(), event.getX(), event.getY());
} else { Point p = FrameWrapper.this.getLocationOnScreen(); int h = frameActions.getPreferredSize().height; frameActions.show(frame.getDesktopPane(), p.x, p.y - h);
        public FrameWrapper(JInternalFrame iFrame) {            this.frame = iFrame;            this.setText(iFrame.getTitle());            this.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent event) {                    try {                        JInternalFrame frame = FrameWrapper.this.frame;                        frame.setIcon(false);                        frame.getDesktopPane().setSelectedFrame(frame);                    } catch (PropertyVetoException ex) {                        //igonre                    }                }            });            this.frame.addInternalFrameListener(new InternalFrameListener() {                public void internalFrameActivated(InternalFrameEvent event) {                    FrameWrapper.this.setBackground(Color.WHITE);                }                public void internalFrameClosed(InternalFrameEvent event) {                    remove(FrameWrapper.this);                    revalidate();                    repaint();                }                public void internalFrameClosing(InternalFrameEvent event) {                    remove(FrameWrapper.this);                    revalidate();                    repaint();                }                public void internalFrameDeactivated(InternalFrameEvent event) {                    FrameWrapper.this.setBackground(Color.LIGHT_GRAY);                }                public void internalFrameDeiconified(InternalFrameEvent event) {                    //To change body of implemented methods use File | Settings | File Templates.                }                public void internalFrameIconified(InternalFrameEvent event) {                    //To change body of implemented methods use File | Settings | File Templates.                }                public void internalFrameOpened(InternalFrameEvent event) {                    //To change body of implemented methods use File | Settings | File Templates.                }            });            final JPopupMenu frameActions = new JPopupMenu();            JMenuItem minimize = new JMenuItem("Minimize");            frameActions.add(minimize);            minimize.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent event) {                    try {                        frame.setIcon(true);                    }catch(PropertyVetoException e){                        //ignore                    }                }            });            JMenuItem maximize = new JMenuItem("Maximize");            frameActions.add(maximize);            maximize.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent event) {                    try {                        frame.setMaximum(true);                    }catch(PropertyVetoException e){                        //ignore                    }                }            });            JMenuItem close = new JMenuItem("Close");            frameActions.add(close);            close.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent event) {                    try {                        frame.setClosed(true);                    }catch(PropertyVetoException e){                        //ignore                    }                }            });            this.addMouseListener(new MouseAdapter() {                    public void mousePressed(MouseEvent event) {                        if(event.getButton() == MouseEvent.BUTTON2){                            if (frameActions .isShowing()) {                                frameActions .setVisible(false);                            } else {                                                                frameActions.show(frame.getDesktopPane(), event.getX(), event.getY());                            }                        }                    }                });        }