src/windows/native/sun/windows/awt_Choice.cpp

Print this page

        

*** 77,94 **** BOOL AwtChoice::sm_isMouseMoveInList = FALSE; static const UINT MINIMUM_NUMBER_OF_VISIBLE_ITEMS = 8; /************************************************************************* * AwtChoice class methods */ AwtChoice::AwtChoice() { m_hList = NULL; m_listDefWindowProc = NULL; - m_selectedItem = -1; } LPCTSTR AwtChoice::GetClassName() { return TEXT("COMBOBOX"); /* System provided combobox class */ } --- 77,97 ---- BOOL AwtChoice::sm_isMouseMoveInList = FALSE; static const UINT MINIMUM_NUMBER_OF_VISIBLE_ITEMS = 8; + namespace { + jfieldID selectedIndexID; + } + /************************************************************************* * AwtChoice class methods */ AwtChoice::AwtChoice() { m_hList = NULL; m_listDefWindowProc = NULL; } LPCTSTR AwtChoice::GetClassName() { return TEXT("COMBOBOX"); /* System provided combobox class */ }
*** 100,110 **** AwtComponent::Dispose(); } AwtChoice* AwtChoice::Create(jobject peer, jobject parent) { - JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject target = NULL; AwtChoice* c = NULL; RECT rc; --- 103,112 ----
*** 436,449 **** MsgRouting AwtChoice::WmNotify(UINT notifyCode) { if (notifyCode == CBN_SELCHANGE) { ! int selectedItem = (int)SendMessage(CB_GETCURSEL); ! if (selectedItem != CB_ERR && m_selectedItem != selectedItem){ ! m_selectedItem = selectedItem; ! DoCallback("handleAction", "(I)V", selectedItem); } } else if (notifyCode == CBN_DROPDOWN) { if (m_hList == NULL) { COMBOBOXINFO cbi; --- 438,455 ---- MsgRouting AwtChoice::WmNotify(UINT notifyCode) { if (notifyCode == CBN_SELCHANGE) { ! int selectedIndex = (int)SendMessage(CB_GETCURSEL); ! ! JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); ! jobject target = GetTarget(env); ! int previousIndex = env->GetIntField(target, selectedIndexID); ! ! if (selectedIndex != CB_ERR && selectedIndex != previousIndex){ ! DoCallback("handleAction", "(I)V", selectedIndex); } } else if (notifyCode == CBN_DROPDOWN) { if (m_hList == NULL) { COMBOBOXINFO cbi;
*** 693,702 **** --- 699,717 ---- * WChoicePeer native methods */ extern "C" { + JNIEXPORT void JNICALL + Java_java_awt_Choice_initIDs(JNIEnv *env, jclass cls) + { + TRY; + selectedIndexID = env->GetFieldID(cls, "selectedIndex", "I"); + DASSERT(selectedIndexID); + CATCH_BAD_ALLOC; + } + /* * Class: sun_awt_windows_WChoicePeer * Method: select * Signature: (I)V */