Topic: 菜鸟求助~关于window接口

  Print this page

1.菜鸟求助~关于window接口 Copy to clipboard
Posted by: naughty009
Posted on: 2005-06-04 14:47

请使用准确的文字描述作为标题
廢話不要多說
讀[加贴须知] 提高发问技巧



原标题 : 菜鸟求助~~~在线等~~急~~~谢谢~!

程序如下:

import java.awt.*;
import javax.swing.*;

import java.awt.event.*;
import MyWindowListener;

public class MyColor2 extends JFrame implements ActionListener
{
private JButton changeColor;
private Color color = Color.lightGray;
private Container c;

public MyColor2()
{
super("MyColor2:使用JColorChooser元件");
c = getContentPane();
c.setLayout(new FlowLayout());
changeColor = new JButton("改变背景颜色");
changeColor.addActionListener(this);
c.add(changeColor);
setSize(300,80);
show();
}
public void actionPerformed(ActionEvent e)
{
color = JColorChooser.showDialog(this,"选色",color);
if(color == null) color = Color.lightGray;
c.setBackground(color);
c.repaint();
}
public static void main(String args[])
{
MyColor2 app = new MyColor2();
app.addWindowListener(new MyWindowListener());
}
}

import MyWindowListener;这里错了~~~请问如何增加这个窗口监听呀?
要对准这行的app.addWindowListener(new MyWindowListener());
请问如何做得到呀?谢谢啦~!有其它方法的也说说吧~尽量详尽点~!谢谢啦~!

2.Re:菜鸟求助~~~在线等~~急~~~谢谢~!关于window接口 [Re: naughty009] Copy to clipboard
Posted by: mesocool
Posted on: 2005-06-04 15:20

MyWindowListener() 在哪里呢

3.Re:菜鸟求助~~~在线等~~急~~~谢谢~!关于window接口 [Re: naughty009] Copy to clipboard
Posted by: naughty009
Posted on: 2005-06-04 15:43

我就是想知道如何做一个MyWindowListener() 的监听器~~~~

4.Re:菜鸟求助~~~在线等~~急~~~谢谢~!关于window接口 [Re: naughty009] Copy to clipboard
Posted by: coucoo
Posted on: 2005-06-04 16:09

既然要做,那你import MyWindowListener;这里是怎么回事?我真的是爱莫能助,同是菜鸟啊。我也是正等着别人帮忙的人,唉,只能给你提出疑问,抱歉了!

5.Re:菜鸟求助~~~在线等~~急~~~谢谢~!关于window接口 [Re: naughty009] Copy to clipboard
Posted by: mesocool
Posted on: 2005-06-04 16:18

app.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
   ...
}
  });


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923