JFrame frame = new JFrame("title");
..........//JFrame 得其他处理
JDesktopPane desktop = new JDesktopPane();
MyInternalFrame myframe = new MyInternalFrame();
myframe.setVisible(true); //necessary as of 1.3
desktop.add(myframe);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
frame.getContentPane().add(desktop,BorderLayout.CENTER);class MyInternalFrame extends JInternalFrame
{
MyInternaleFrame()
{
super("title",true,true,true);
setSize(300,400);
setLocation(400,400);
addMouseListener(new MyMouseListener());
addMouseMotionListener(new MyMouseListener());}}如何在MyInternalFrame中响应鼠标事件? 我是如上面得程序注册鼠标监听器,可是不能响应鼠标事件啊?
请帮帮忙

解决方案 »

  1.   

    InternalFrame 需要鼠标事件监听吗??
    你要实现什么效果出来哦?
      

  2.   

    增加一个JPanel,在JPanel中添加处理鼠标等事件
      

  3.   

    我想做像photoshop那样的画图程序,然后在每个子窗口中进行绘画。
    我试着把InternalFrame加在了JFrame的中央(CENTER),然后在JFrame的北部(NORTH)加了工具兰。
    我又创建了一个类派生自JPanel,用来在它上面画图,然后将此类加在InternalFrame中,可是画图时连工具栏也画出来了。
    还有一个问题是:派生自JComponent的类不能设置背景颜色,怎么回事啊?
    唉,面对庞大的Swing体系结构,不理解其中底层的机理,进行编程真是寸步难行啊。哪里有什么讲述Swing各个类的深层含义的资料吗?