兄弟,你好像没有加入focus 的监听。
解决方案 »
- 把控制台的输入,写入到文件,这样写有什么不对
- 权限问题,权限要细化到增删改查?
- 你懂classpath吗
- 求助?? 在线等
- 象MSN那样弹出的非IE窗口中有网页,JAVA中怎么在JFRAME中嵌入网页
- MEEEjava.lang.NullPointerException
- 千年难遇的问题!j2sdk装不了!求助!
- *.java to *.class
- <jsp:setProperty name="PageHeaderInfo" property="*" />是给所有的属性设值,那具体的每个属性得到的值是多少?
- 怎么样将String转换成double?
- 请教一个关于StringBuffer与String 用于字符窜的效率问题。谢谢
- 一个JAVA的求助:
///////////////////////////////////////
inOutDlg.addFocusListener(this);//在此处希望框架获得焦点事件
//////////////////////////////////////////////
我在Jbuilder8.0(JDK1.3.1)运行是正确的
但在1.4.1 command模式下就得不到焦点呜呜,高手指教呀!
It is important to note that only AWT listeners which conform to the Serializable protocol will be saved when the object is stored. If an AWT object has listeners that aren't ed serializable, they will be dropped at writeObject time. Developers will need, as always, to consider the implications of making an object serializable. One situation to watch out for is this:
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable;
class MyApp implements ActionListener, Serializable
{
BigObjectThatShouldNotBeSerializedWithAButton bigOne;
Button aButton = new Button();
MyApp()
{
// Oops, now aButton has a listener with a reference
// to bigOne!
aButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
System.out.println("Hello There");
}
}
In this example, serializing aButton by itself will cause MyApp and everything it refers to to be serialized as well. The problem is that the listener is serializable by coincidence, not by design. To separate the decisions about MyApp and the ActionListener being serializable one can use a nested class, as in the following example:
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable; class MyApp java.io.Serializable
{
BigObjectThatShouldNotBeSerializedWithAButton bigOne;
Button aButton = new Button(); class MyActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Hello There");
}
}
MyApp()
{
aButton.addActionListener(new MyActionListener());
}
}
他建议实现WindowFocusListener
有哪位高手能解释一下WindowFocusListener和FocusListener的区别吗?
谢谢!代码改为:
class MyDialogFrame extends Frame
implements ActionListener,WindowFocusListener增加事件监听者改为
inOutDlg.addWindowFocusListener(this);这样的话两个实现的事件处理操作分别改为
public void windowGainedFocus(WindowEvent e) //handle of the FocusEvent!
{
getMeg.setText("Dialog\""+((Dialog)e.getComponent()).getTitle() +"\"get the focus!");
}
/////////////////////////////////////////////////////////public void windowLostFocus(WindowEvent e){}