本文整理汇总了C++中JAWT::GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ JAWT::GetComponent方法的具体用法?C++ JAWT::GetComponent怎么用?C++ JAWT::GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JAWT
的用法示例。
在下文中一共展示了JAWT::GetComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
/*
* Class: MyCanvas
* Method: paint
* Signature: (Ljava/awt/Graphics;)V
*/
JNIEXPORT void JNICALL Java_MyCanvas_paint
(JNIEnv* env, jobject canvas, jobject graphics)
{
JAWT awt;
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
JAWT_X11DrawingSurfaceInfo* dsi_x11;
jboolean result;
jint lock;
GC gc;
jobject ref;
/* Get the AWT */
awt.version = JAWT_VERSION_1_4;
if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
printf("AWT Not found\n");
return;
}
/* Lock the AWT */
awt.Lock(env);
/* Unlock the AWT */
awt.Unlock(env);
/* Get the drawing surface */
ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL) {
printf("NULL drawing surface\n");
return;
}
/* Lock the drawing surface */
lock = ds->Lock(ds);
printf("Lock value %d\n", (int)lock);
if((lock & JAWT_LOCK_ERROR) != 0) {
printf("Error locking surface\n");
awt.FreeDrawingSurface(ds);
return;
}
/* Get the drawing surface info */
dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == NULL) {
printf("Error getting surface info\n");
ds->Unlock(ds);
awt.FreeDrawingSurface(ds);
return;
}
/* Get the platform-specific drawing info */
dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
/* Now paint */
gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
XSetForeground(dsi_x11->display, gc, 0);
XFillRectangle(dsi_x11->display, dsi_x11->drawable, gc,
5, 5, 90, 90);
XFreeGC(dsi_x11->display, gc);
ref = awt.GetComponent(env, (void*)(dsi_x11->drawable));
if (!(*env)->IsSameObject(env, ref, canvas)) {
printf("Error! Different objects!\n");
}
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
}
示例2: printf
JNIEXPORT void JNICALL Java_MyCanvas_paint
(JNIEnv* env, jobject canvas, jobject graphics)
{
/* Get the AWT */
JAWT awt;
awt.version = JAWT_VERSION_1_4;
if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
printf("AWT Not found\n");
return;
}
/* Lock the AWT */
awt.Lock(env);
/* Unlock the AWT */
awt.Unlock(env);
/* Get the drawing surface */
JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL) {
printf("NULL drawing surface\n");
return;
}
/* Lock the drawing surface */
jint lock = ds->Lock(ds);
printf("Lock value %d\n", (int)lock);
if((lock & JAWT_LOCK_ERROR) != 0) {
printf("Error locking surface\n");
return;
}
/* Get the drawing surface info */
JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == NULL) {
printf("Error getting surface info\n");
ds->Unlock(ds);
return;
}
/* Get the platform-specific drawing info */
JAWT_Win32DrawingSurfaceInfo* dsi_win =
(JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
/* Now paint */
PAINTSTRUCT ps;
/* Do not use the HDC returned from BeginPaint()!! */
::BeginPaint(dsi_win->hwnd, &ps);
HBRUSH hbrush = (HBRUSH)::GetStockObject(BLACK_BRUSH);
RECT rect;
rect.left = 5;
rect.top = 5;
rect.right = 95;
rect.bottom = 95;
::FillRect(dsi_win->hdc, &rect, hbrush);
::EndPaint(dsi_win->hwnd, &ps);
jobject ref = awt.GetComponent(env, (void*)(dsi_win->hwnd));
if (!env->IsSameObject(ref, canvas)) {
printf("Error! Different objects!\n");
}
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
}