请问:是这样吗?
void InputField_focusGained(FocusEvent e) {
InputField.grabFocus();
InputField.setBackground(Color.red);
}
void InputField_focusGained(FocusEvent e) {
InputField.grabFocus();
InputField.setBackground(Color.red);
}
调试欢乐多
InputField.setBackground(Color.white);
} void InputField_focusGained(FocusEvent e) {
InputField.setBackground(Color.orange);
}
现在我可以在InputField中输入,但是InputField的background确实white!!!
天哪~~~~~这到底是为什么?为什么不是orange呢????
失败!!!
不行还是:
“现在我可以在InputField中输入,但是InputField的background确实white!!!
天哪~~~~~这到底是为什么?为什么不是orange呢????
失败!!!”
jTextField1.setBackground(Color.cyan);
jTextField1.grabFocus();
} void jTextField1_focusLost(FocusEvent e) {
jTextField1.setBackground(Color.blue);
} void jTextField2_mouseEntered(MouseEvent e) {
jTextField2.setBackground(Color.red);
jTextField1.grabFocus();
} void jTextField2_mouseExited(MouseEvent e) {
jTextField2.setBackground(Color.green);
}
我试了一下可以呀
window.addWindowListener(new WindowAdpter(){
public void windowOpened(WindowEvent e) {
textField.requestFocus();
}
});
我是这样解决的,不过不知道对楼主的例子可不可行。
void this_windowOpened(WindowEvent e) {
if(!InputField.requestDefaultFocus()){
anOptionPane.showMessageDialog(this,"员工"+UserIDStr+"您好,祝您工作愉快!","系统提示",JOptionPane.YES_OPTION); }
InputField.grabFocus();
}