bạn có thể chèn các mã dưới đây vào hình thức của init
phương pháp. Nếu bạn có bất kỳ câu hỏi nào về mã, đừng ngần ngại hỏi!
public void init()
{
#define.CACHE_OWNER ('MyForm')
#define.CACHE_KEY_INSTANCE ('Instance')
FormRun existingForm()
{
;
if (infolog.globalCache().isSet(#CACHE_OWNER, #CACHE_KEY_INSTANCE))
{
return infolog.globalCache().get(
#CACHE_OWNER, #CACHE_KEY_INSTANCE);
}
return null;
}
void registerThisForm()
{
;
infolog.globalCache().set(#CACHE_OWNER, #CACHE_KEY_INSTANCE, this);
}
boolean isAlreadyOpened()
{
;
return existingForm() ? !existingForm().closed() : false;
}
void activateExistingForm()
{
;
existingForm().activate(true);
}
;
super();
if (isAlreadyOpened())
{
activateExistingForm();
this.close();
}
else
{
registerThisForm();
}
}
Điều này hoạt động tốt. Tôi đã phải thay đổi phương thức kích hoạt thành element.existingForm(). SetActive(); Lệnh activate() không mang biểu mẫu gốc về phía trước. Cám ơn rất nhiều! – Brad