| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 584 人关注过本帖
标题:单击 "Internal Frame"没有反应 请指教
只看楼主 加入收藏
事过境迁
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2006-8-2
收藏
 问题点数:0 回复次数:1 
单击 "Internal Frame"没有反应 请指教

//DesktopTest.java
//Demonstating JDesktopPane
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DesktopTest extends JFrame{
public DesktopTest(){
super("Using a JDesktopPane");

JMenuBar bar=new JMenuBar();
JMenu addMenu=new JMenu("Add");
JMenuItem newFrame=new JMenuItem("Internal Frame");
addMenu.add(newFrame);
bar.add(addMenu);
setJMenuBar(bar);

final JDesktopPane theDesktop=new JDesktopPane();
getContentPane().add(theDesktop);

newFrame.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
JInternalFrame aframe=new JInternalFrame("Internal Frame",true,true,true,true);
//内部窗口标题栏,能否改变内部窗大小,能否关闭内部窗,能否最大化,能否最小化

Container c=aframe.getContentPane();
MyJPanel panel=new MyJPanel();

c.add(panel,BorderLayout.CENTER);
aframe.setSize(panel.getImageWidthHeight().width,panel.getImageWidthHeight().height);
aframe.setOpaque(true); //窗口不透明
theDesktop.add(aframe);
}
}
);

setSize(500,400);
show();
}

public static void main(String args[]){
DesktopTest app=new DesktopTest();

app.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
}
}

class MyJPanel extends JPanel{
private ImageIcon imgIcon;

public MyJPanel(){
imgIcon=new ImageIcon("buganim.gif");
}

public void paintComponent(Graphics g){
super.paintComponent(g);
imgIcon.paintIcon(this,g,0,0);
}

public Dimension getImageWidthHeight(){
return new Dimension(imgIcon.getIconWidth(),imgIcon.getIconHeight());
}
}

搜索更多相关主题的帖子: Frame 单击 Internal 指教 
2007-05-07 17:21
事过境迁
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2006-8-2
收藏
得分:0 
没人?
2007-05-08 21:50
快速回复:单击 "Internal Frame"没有反应 请指教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024028 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved