我目前正在使用Java中的Netbeans创建GUI。当我使用另一个框架中的JTextField
加载包含该文本字段的JFrame
时,如何使JButton
自动填充包含当前系统日期?
答案 0 :(得分:2)
#include <tesseract/capi.h>
#include <windows.h>
void ReadFromScreen(RECT rc)
{
HWND hWndDesktop = GetDesktopWindow();
HDC hDC = GetDC(hWndDesktop);
#define BITS_PER_PIXEL 32
#define BYTES_PER_PIXEL (BITS_PER_PIXEL / 8)
int nWidth = rc.right - rc.left;
int nHeight = rc.bottom - rc.top;
BITMAPINFO bi;
memset(&bi, 0, sizeof(bi));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = nWidth;
bi.bmiHeader.biHeight = -nHeight;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = BITS_PER_PIXEL;
bi.bmiHeader.biCompression = BI_RGB;
void* pixels;
HBITMAP hBitmap = ::CreateDIBSection(0, &bi, DIB_RGB_COLORS, &pixels, NULL, 0);
HDC hMemDC = CreateCompatibleDC(NULL);
SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC, 0, 0, nWidth, nHeight, hDC, rc.left, rc.top, SRCCOPY);
int nDataSize = nWidth * nHeight * BYTES_PER_PIXEL;
TessBaseAPISetImage(pTessBaseAPI, (const unsigned char*)pixels, nWidth, nHeight, BYTES_PER_PIXEL, BYTES_PER_PIXEL * nWidth);
if (TessBaseAPIRecognize(pTessBaseAPI, NULL) != 0)
{
return;
}
char* szText = TessBaseAPIGetUTF8Text(pTessBaseAPI);
// Todo something with szText
TessDeleteText(szText);
DeleteObject(hBitmap);
DeleteDC(hMemDC);
}
,在构造时用当前日期/时间填充它。 JTextField
; - 顺便提一下new JSpinner(new SpinnerDateModel())
默认 到当前日期!以下是使用微调器/微调器日期模型的示例。
new SpinnerDateModel()