本文整理汇总了C++中AwtTextComponent::SetText方法的典型用法代码示例。如果您正苦于以下问题:C++ AwtTextComponent::SetText方法的具体用法?C++ AwtTextComponent::SetText怎么用?C++ AwtTextComponent::SetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AwtTextComponent
的用法示例。
在下文中一共展示了AwtTextComponent::SetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _SetText
void AwtTextComponent::_SetText(void *param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetTextStruct *sts = (SetTextStruct *)param;
jobject self = sts->textcomponent;
jstring text = sts->text;
AwtTextComponent *c = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
c = (AwtTextComponent *)pData;
if (::IsWindow(c->GetHWnd()))
{
int length = env->GetStringLength(text);
WCHAR* buffer = new WCHAR[length + 1];
env->GetStringRegion(text, 0, length, reinterpret_cast<jchar*>(buffer));
buffer[length] = 0;
c->CheckLineSeparator(buffer);
c->RemoveCR(buffer);
c->SetText(buffer);
delete[] buffer;
}
ret:
env->DeleteGlobalRef(self);
env->DeleteGlobalRef(text);
delete sts;
}
示例2: PDATA
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_setText (JNIEnv *env,
jobject thisObj,
jstring text)
{
CHECK_PEER(thisObj);
AwtTextComponent* c = PDATA(AwtTextComponent, thisObj);
int length = env->GetStringLength(text);
#ifndef UNICODE
TCHAR* buffer = new TCHAR[length * 2 + 1];
buffer = TO_WSTRING(text);
#else
WCHAR* buffer = new WCHAR[length + 1];
env->GetStringRegion(text, 0, length, (jchar*)buffer);
buffer[length] = 0; //or it should be TEXT('\0') or L'\0'???
#endif
buffer = AwtTextComponent::AddCR(buffer, length);
c->SetText(buffer);
/* Fix for TCK bug: setText() does not generate valueChangedEvent */
if (env->IsInstanceOf(c->GetTarget(), WCachedIDs.java_awt_TextAreaClass)) {
c->WmNotify(EN_CHANGE);
}
delete[] buffer;
}