社区
Java SE
帖子详情
请教窗口事件中的void windowIconified(windowEvent e)方法是干什么用的?
ashui11
2003-10-15 08:45:48
谢谢
...全文
410
3
打赏
收藏
请教窗口事件中的void windowIconified(windowEvent e)方法是干什么用的?
谢谢
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
imagex
2003-10-15
打赏
举报
回复
windowActivated(WindowEvent e) 窗口得到焦点时触发
windowClosed(WindowEvent e) 窗口关闭之后触发
windowClosing(WindowEvent e) 窗口关闭时触发
windowDeactivated(WindowEvent e) 窗口失去焦点时触发
windowOpened(WindowEvent e) 窗口打开之后触发
windowDeiconified(WindowEvent e) 楼上
windowIconified(WindowEvent e) 楼上
quanch
2003-10-15
打赏
举报
回复
窗口最小化时触发的事件。
LoveRose
2003-10-15
打赏
举报
回复
Invoked when a window is changed from a normal to a minimized state. For many platforms, a minimized window is displayed as the icon specified in the window's iconImage property.
基于java开发的五子棋游戏
java开发的小游戏
Window
Listener接口所有
方法
1.public
void
window
Closed(
Window
Event
e){}
窗口
被完全关闭时调用的
方法
2. public
void
window
Deactivated(
Window
Event
e){}
窗口
失去活性时调用的
方法
3.public
void
window
Activated(
Window
Event
e){}
窗口
被完全激活时调用的
方法
4. public
void
window
Iconified
(
Window
Event
e){}
窗口
被最小化时调用的
方法
5. public
void
window
De
iconified
(
Window
Event
e){}
窗口
被从最小化还原时调用的
方法
6. public
void
window
Opened(
Window
Event
e){}
窗口
被完全激活时调用的
方法
7.public
void
window
Closing(
Window
Event
e){}
窗口
的关闭按钮被点击时调用的
方法
java图形界面开发-
事件
监听
6.2.4
事件
适配器 适配器类实现一个对应的所有接口,只是
方法
为空。 public abstract class
Window
Adapter implements
Window
Listener { public
void
window
Opened(
Window
Event
e) {} public
void
window
Activated(
Window
Event
e) {} public
void
window
Deactivated(
Window
Event
e) {} public
void
window
Closed(
Window
Event
e) {} public
void
window
Closing(
Window
Event
e) {} public
void
window
Iconified
(
Window
Event
e) {} public
void
window
De
iconified
(
Window
Event
e) {} } 表6.1 Listener接口与对应的适配器(Adapter)类 接口名称 适配器名称 ComponentListener ComponentAdapter ContainerListener ContainerAdapter FocusListener FocusAdapter KeyListener KeyAdapter MouseListener MouseAdapter MouseMotionListener MouseMotionAdapter
Window
Listener
Window
Adapter (7)鼠标运动
事件
鼠标运动
事件
发生在鼠标移过某个组件时。 任何组件都可以产生这些
事件
,通过接口 MouseMotionListener 实现。 该接口有两个
方法
: mouseDragged(Mouse
Event
) mouseMove(Mouse
Event
) MouseMotionListener 没有自己的
事件
类型,替代它的是 Mouse
Event
。 被用在 Mouse
Event
对象上的
方法
它都可以使用: getClickCount( ) 返回鼠标被单击次数(整数) getPoint( ) 返回鼠标被单击位置的 x ,y 坐标 getX( ) 返回 x 位置 getY( ) 返回 y 位置 (8)
窗口
事件
(
Window
Event
)
窗口
事件
发生在用户打开或关闭一个诸如 Frame 或
Window
的
窗口
时。任何组件都可以产生这些
事件
,为了支持它们,类必须实现接口:
Window
Listener。 接口
Window
Listener
中
有七个
方法
:
window
Activated(
Window
Event
)
窗口
被激活
window
Closed (
Window
Event
)
窗口
已关闭
window
Closing (
Window
Event
)
窗口
正在关闭
window
Deactivated (
Window
Event
)
窗口
失效
window
De
iconified
(
Window
Event
)
窗口
正常化时
window
Iconified
(
Window
Event
)
窗口
最小化时
window
Opened (
Window
Event
)
窗口
被打开 (5)键盘
事件
(Key
Event
) 发生在键盘上的某个键被按下时。 类为了能够处理这些
事件
必须实现接口 KeyListener 。 每个产生一个键盘
事件
的组件上要调用
方法
addKeyListener( ) 在接口 KeyListener
中
有三个
方法
: public
void
keyPressed(Key
Event
evt) { //…… } public
void
keyReleased(Key
Event
evt) { //…… } public
void
keyTyped(Key
Event
evt) { //…… } 在 Key
Event
对象上可以使用的
方法
: getKeyChar( ) 返回与
事件
相关的键盘字符的 Unicode 码 . . . . . . . . . . . . . .
Window
Event
&Mouse
Event
.pptx
15.2
Window
Event
&Mouse
Event
课前测试创建Btn
Event
Frame类,继承JFrame类,设计并展示出如下框架(
窗口
):(1)框架
中
间有个文本显示为“确定”,名称叫okbtn的按钮;(2)给btn按钮添加监听器,希望单击该按钮,能在控制台输出“大家好!”,要求用内部匿名类处理;(3)该框架大小 :水平宽为300象素,高为100象素;(4)该框架在屏幕
中
央显示;(5)单击框架“关闭”按钮,默认退出系统。处理
Window
Event
s(
窗口
事件
)在
窗口
打开、关闭、最大化、最小化时会触发
Window
Event
事件
window
事件
由
Window
Listener接口处理
Window
Listener接口有7个函数分别对应7种
窗口
事件
public
void
window
Opened(
Window
Event
e) ;//打开
窗口
public
void
window
Closing(
Window
Event
e) ; //正在关闭
窗口
public
void
window
Closed(
Window
Event
e) ;//关闭
窗口
public
void
window
Iconified
Java 版蛋疼游戏,开发工具:MyEclipse
开发工具:MyEclipse 将下面的图片添加到MyEclipse的src文件夹下,第一幅图片名1.gif,第二幅图片名4.gif =================================================================================== import java.awt.*; import java.awt.
event
.*; import javax.swing.*; public class FirstFrame extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; JDialog jd; JButton jb; ImageIcon a; //插入图片 JLabel jl,jl1,jl2; SecondFrame jf2; public FirstFrame(){ Container wc=this.getContentPane(); wc.setLayout(null); a=new ImageIcon("src/1.gif"); //插入图片 jb=new JButton(a); jb.setBounds(45,45,410,160); jb.addActionListener(this); wc.add(jb); jl=new JLabel("点击上面的动感水果人,进入少林水果六人阵!"); jl.setBounds(120,230,280,20); jl.setForeground(Color.BLUE); wc.add(jl); jl1=new JLabel("这是一个具有挑战的
窗口
游戏,相信你会玩得很开心!"); jl1.setBounds(100,300, 320, 20); jl1.setForeground(Color.RED); wc.add(jl1); jl2=new JLabel("让我们开始挑战吧!"); jl2.setBounds(200,320,130, 20); jl2.setForeground(Color.RED); wc.add(jl2); this.setTitle("蛋疼游戏 1.0版"); this.setUndecorated(true); this.setSize(500, 400); this.setLocationRelativeTo(null); //让
窗口
居
中
this.setVisible(true); this.setDefaultCloseOperation(EXIT_ON_CLOSE); } @Override public
void
actionPerformed(Action
Event
e){ jf2=new SecondFrame(); jf2.
window
s2(); jf2.Realize(); this.setVisible(false); } } //第一个窗体 =================================================================================== import java.awt.*; import java.awt.
event
.*; import javax.swing.*; public class SecondFrame extends JFrame implements ActionListener,
Window
Listener { JLabel jl; JButton jb; ThirdFrame jf3; private static final long serialVersionUID = 2L; public
void
window
s2(){ this.setUndecorated(true); // 去掉
窗口
的装饰 this.getRootPane().set
Window
DecorationStyle(JRootPane.PLAIN_DIALOG); // 设置这个只有关闭按钮,禁止最大化按钮,同时还能实现最大化。 this.setTitle("第一关"); this.setSize(500, 400); this.setVisible(true); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.add
Window
Listener(this); } public
void
Realize(){ Container wc=this.getContentPane(); wc.setLayout(null); jl=new JLabel("这是第一关想办法找到第二关的入口"); jl.setBounds(130, 90, 500, 50); jl.setForeground(Color.BLUE); wc.add(jl); jb=new JButton("第二关入口"); jb.setBounds(300, 500, 100, 30); jb.setForeground(Color.BLUE); jb.addActionListener(this); wc.add(jb); } public
void
actionPerformed(Action
Event
e) { jf3=new ThirdFrame(); jf3.
window
s3(); jf3.Realize(); this.setVisible(false); } @Override public
void
window
Activated(
Window
Event
e) {} @Override public
void
window
Closed(
Window
Event
e) {} @Override public
void
window
Closing(
Window
Event
e) { JOptionPane.showMessageDialog(null, " 修行不够!!闯关失败!!!", "失败!!!", 2); } @Override public
void
window
Deactivated(
Window
Event
e) {} @Override public
void
window
De
iconified
(
Window
Event
e) {} @Override public
void
window
Iconified
(
Window
Event
e) {} @Override public
void
window
Opened(
Window
Event
e) {} } //第二个窗体 ............................
幻灯片java手动播放
import java.awt.*; import java.awt.
event
.*; import java.applet.*; import java.net.*; import java.io.*; public class SR_Slider extends Frame implements ActionListener,
Window
Listener, Runnable { public static
void
main(String Pagli[]) { new SR_Slider(); } Thread time; //new thread File fl; URL dir; MediaTracker mt; //here you can use an array Image p1, p2, p3, p4, p5, p6, p7; About ab; //instance of About class Panel bottom; AudioClip b_n, rfs; Toolkit tk; Dimension dim; Button back, next, refresh, auto, abt, ext; Color sky; Font f; int count, x; public SR_Slider() { setTitle("SR-Slider 1.0"); setLayout(new BorderLayout()); bottom = new Panel(); time = new Thread(this); sky = new Color(0,140,255); //color - skyblue f = new Font("Courier",Font.BOLD,16); count = 0; x = 0; mt=new MediaTracker(this); try { //getting all images and add them to the MediaTracker p1 = Toolkit.getDefaultToolkit().getImage("Image/p1.jpg"); mt.addImage(p1, 0); p2 = Toolkit.getDefaultToolkit().getImage("Image/p2.jpg"); mt.addImage(p2, 1); p3 = Toolkit.getDefaultToolkit().getImage("Image/p3.jpg"); mt.addImage(p3, 2); p4 = Toolkit.getDefaultToolkit().getImage("Image/p4.jpg"); mt.addImage(p4, 3); p5 = Toolkit.getDefaultToolkit().getImage("Image/p5.jpg"); mt.addImage(p5, 4); p6 = Toolkit.getDefaultToolkit().getImage("Image/p6.jpg"); mt.addImage(p6, 5); p7 = Toolkit.getDefaultToolkit().getImage("Image/p7.jpg"); mt.addImage(p7, 6); fl = new File("user.dir"); dir = fl.toURL(); b_n = Applet.newAudioClip(new URL(dir, "Sound/bk_nxt.au")); rfs = Applet.newAudioClip(new URL(dir, "Sound/rfsh.au")); } catch(MalformedURLException e) { //do nothing! } //designing back button back=new Button("Back"); back.setFont(f); back.setBackground(sky); back.setForeground(Color.white); //designing next button next=new Button("Next"); next.setFont(f); next.setBackground(sky); next.setForeground(Color.white); //designing refresh button refresh=new Button("Reset"); refresh.setFont(f); refresh.setBackground(sky); refresh.setForeground(Color.white); //designing auto button auto=new Button("SlideShow"); auto.setFont(f); auto.setBackground(sky); auto.setForeground(Color.white); //designing abt button abt=new Button("About"); abt.setFont(f); abt.setBackground(sky); abt.setForeground(Color.white); //designing ext button ext=new Button("Exit"); ext.setFont(f); ext.setBackground(sky); ext.setForeground(Color.white); //adding ActionListener to all buttons back.addActionListener(this); next.addActionListener(this); refresh.addActionListener(this); auto.addActionListener(this); abt.addActionListener(this); ext.addActionListener(this); //adding all components to the Frame bottom.add(back); bottom.add(next); bottom.add(refresh); bottom.add(auto); bottom.add(abt); bottom.add(ext); add(bottom, BorderLayout.SOUTH); add
Window
Listener(this); tk = this.getToolkit(); dim = tk.getScreenSize(); //getting the current screen resolution setBounds(dim.width/6, dim.height/6, 540, 420); setResizable(false); setVisible(true); } public
void
paint(Graphics g) { if(count < 1) g.drawImage(p1, 0, 0, this); if(count == 1) g.drawImage(p2, 0, 0, this); if(count == 2) g.drawImage(p3, 0, 0, this); if(count == 3) g.drawImage(p4, 0, 0, this); if(count == 4) g.drawImage(p5, 0, 0, this); if(count == 5) g.drawImage(p6, 0, 0, this); if(count == 6) g.drawImage(p7, 0, 0, this); } public
void
update(Graphics g) { paint(g); } public
void
actionPerformed(Action
Event
ae) { if(ae.getSource() == ext) { dispose(); setVisible(false); System.exit(0); } if(ae.getSource() == next) { b_n.play(); if(count < 7) { count++; repaint(); } } if(ae.getSource() == back) { b_n.play(); if(count == 0) count=0; if(count > 0) { count--; repaint(); } } if(ae.getSource() == refresh) { rfs.play(); time.suspend(); //suspends the thread count=0; repaint(); } if(ae.getSource() == auto) { b_n.play(); if(x < 1) { time.start(); x++; } else { time.resume(); //resumes the thread } } if(ae.getSource() == abt) { ab = new About(); } } public
void
run() { try { for(int i=1;i>0;i++) { b_n.play(); time.sleep(3000); count++; if(count > 6) { time.suspend(); //suspends the thread count = 0; } repaint(); } } catch(InterruptedException e) { //do nothing! } } //handling
window
event
s public
void
window
Closing(
Window
Event
we) { dispose(); setVisible(false); System.exit(0); } public
void
window
Closed(
Window
Event
we) { //do nothing! } public
void
window
Opened(
Window
Event
we) { //do nothing! } public
void
window
Activated(
Window
Event
we) { //do nothing! } public
void
window
Deactivated(
Window
Event
we) { //do nothing! } public
void
window
Iconified
(
Window
Event
we) { //do nothing! } public
void
window
De
iconified
(
Window
Event
we) { //do nothing! } class About extends Frame implements
Window
Listener { Font f, f2; private About() { setTitle("About"); setLayout(new FlowLayout()); f = new Font("Verdana", Font.BOLD, 20); f2 = new Font("Verdana", Font.PLAIN, 12); add
Window
Listener(this); tk = this.getToolkit(); dim = tk.getScreenSize(); //getting the current screen resolution setBounds(dim.width/4, dim.height/4, 300, 190); setResizable(false); setVisible(true); } public
void
paint(Graphics g) { g.setColor(Color.red); g.setFont(f); g.drawString("SR-Slider 1.0", 10, 60); g.setColor(Color.black); g.setFont(f2); g.drawString("Author: 雪碧的朋友", 10, 90); g.drawString("email:jing_feng70@163.com", 10, 110); g.drawString("谢谢使用", 10, 130); g.drawString("(C) ShuvoRim Pvt. Ltd.", 10, 150); g.drawString("All rights reserved.", 10, 170); } //handling
window
event
s public
void
window
Closing(
Window
Event
we) { dispose(); setVisible(false); } public
void
window
Closed(
Window
Event
we) { //do nothing! } public
void
window
Opened(
Window
Event
we) { //do nothing! } public
void
window
Activated(
Window
Event
we) { //do nothing! } public
void
window
Deactivated(
Window
Event
we) { //do nothing! } public
void
window
Iconified
(
Window
Event
we) { //do nothing! } public
void
window
De
iconified
(
Window
Event
we) { //do nothing! } } }
Java SE
62,614
社区成员
307,327
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章