警告 paint queue size exceeded, please watch the amount of repaint calls 错误
Warning paint queue size exceeded, please watch the amount of repaint calls Error
我在 table 中有大约 50 多行。如果我将它们显示在 table 中,如下所示,"Warning paint queue size exceeded, please watch the amount of repaint calls"
无限显示错误警告。如果我将行限制为 15 或 20,那么它可以工作 normally.How 我可以解决错误吗?
更新:如果我将 "showTableData(f)" 保留在 beforeMain 中,则不会出现警告,但如果我将其注释掉并保留在 postMain 中,则会出现警告。这是为什么?
@Override
protected void beforeMain(Form f) {
// showTableData(f);
// f.revalidate();
}
Container wrapContainer;
Container containerTableDataGroup;
String detailId = "";
@Override
protected void postMain(Form f) {
showTableData(f); //keeping table data here gives warnings
f.forceRevalidate();
}
public void showTableData(Form f) {
f.setScrollableY(true);
wrapContainer = new Container();
GroupConnection gc = new GroupConnection();
for (int i = 0; i < 200; i++) {
Container tableNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea tableNameData = new TextArea();
tableNameData.setText("tableNameData");
stylingTextArea(tableNameData);
tableNameData.setActAsLabel(true);
tableNameDataContainer.add(tableNameData);
Container inaugurationDateDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea inaugurationDateData = new TextArea();
inaugurationDateData.setText("inaugurationDate");
stylingTextArea(inaugurationDateData);
inaugurationDateData.setActAsLabel(true);
inaugurationDateDataContainer.add(inaugurationDateData);
Container areaCodeDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea areaCodeData = new TextArea();
areaCodeData.setText("areaCodeData");
stylingTextArea(areaCodeData);
areaCodeData.setActAsLabel(true);
areaCodeDataContainer.add(areaCodeData);
Container clubAbbrNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea clubAbbrNameData = new TextArea();
clubAbbrNameData.setText("clubAbbrNameData");
stylingTextArea(clubAbbrNameData);
clubAbbrNameData.setActAsLabel(true);
clubAbbrNameDataContainer.add(clubAbbrNameData);
Container clubCharterDateDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea clubCharterDateData = new TextArea();
clubCharterDateData.setText("clubCharterDateData");
stylingTextArea(clubCharterDateData);
clubCharterDateData.setActAsLabel(true);
clubCharterDateDataContainer.add(clubCharterDateData);
TableLayout tl1 = new TableLayout(1, 5);
containerTableDataGroup = new Container(tl1);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(30), tableNameDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(20), inaugurationDateDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(15), areaCodeDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(15), clubAbbrNameDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(20), clubCharterDateDataContainer);
wrapContainer.add(containerTableDataGroup);
}
f.add(wrapContainer);
wrapContainer.revalidate();
}
public void stylingTextArea(TextArea textAreaName) {
textAreaName.setUIID("styleTextArea");
textAreaName.getAllStyles().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
textAreaName.getAllStyles().setPadding(0, 0, 0, 0);
textAreaName.getAllStyles().setAlignment(Component.CENTER);
textAreaName.setEditable(false);
textAreaName.setGrowByContent(true);
textAreaName.setGrowLimit(2);
}
更新 2:
如果我使用 addToQueue 在 beforeForm 方法中保持连接,则会显示空白屏幕。如果我使用 addToQueueAndWait,无限进度只会在很短的时间内显示,仅在几秒钟后显示数据(smtimes 需要更多时间来显示)。我在 postForm 和 addToQueue 的连接请求方法中使用了 actionlistener 回调,但同样在 beforeForm 中不起作用。
protected void beforeGroups(Form f) {
groupConnection();
wrapContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for (Map<String, Object> element : response) {
String tableName = (String) element.get("name");
. . . . . . .
. . . . . . .
}
}
void groupConnection() {
ConnectionRequest connectionRequest = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jSONParser = new JSONParser();
Map<String, Object> parsedData = jSONParser.parseJSON(new InputStreamReader(input));
response = (ArrayList<Map<String, Object>>) parsedData.get("root");
}
};
connectionRequest.setUrl(allUrl.groupsUrl);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
connectionRequest.setDisposeOnCompletion(d);
NetworkManager.getInstance().addToQueue(connectionRequest);//blank screen if addToQueueAndWait isnot used here
}
更新 3:
@Override
protected void beforeAbc(Form f) {
minuteConnection(f);
}
void minuteConnection(Form f) {
ConnectionRequest connectionRequest = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jSONParser = new JSONParser();
Map<String, Object> parsedData = jSONParser.parseJSON(new InputStreamReader(input));
responsee = (ArrayList<Map<String, Object>>) parsedData.get("root");
}
@Override
protected void postResponse() {
int i = 0;
wrapContainerMeeting = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for (Map<String, Object> element : responsee) {
String minuteId = (String) element.get("meetingNumberId");
String tblId = (String) element.get("tbladmin_id");
String tableName = (String) element.get("name");
String totalMembers = (String) element.get("continousMeetingNumber");
String totalMeetingYearly = (String) element.get("meetingForYear");
String minuteDate = (String) element.get("meetingDate");
Container tableNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea tableNameDataMeeting = new TextArea(tableName);
tableNameDataContainer.add(tableNameDataMeeting);
Container inaugurationDateDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea inaugurationDateDataMeeting = new TextArea(totalMembers);
inaugurationDateDataContainer.add(inaugurationDateDataMeeting);
Container areaCodeDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea areaCodeData = new TextArea(totalMeetingYearly);
areaCodeDataContainer.add(areaCodeData);
Container clubAbbrNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea clubAbbrNameData = new TextArea(minuteDate);
clubAbbrNameDataContainer.add(clubAbbrNameData);
}
f.add(wrapContainerMeeting);
}
};
AllUrl allUrl = new AllUrl();
connectionRequest.setUrl(allUrl.abcUrl);
connectionRequest.setPost(false);//keeping this line or deleting doesnt affect anything
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
connectionRequest.setDisposeOnCompletion(d);
NetworkManager.getInstance().addToQueue(connectionRequest);
}
您为添加的每一行都调用 revalidate
,这是非常过分的...
您需要在添加完所有内容后执行一次此操作。
我在 table 中有大约 50 多行。如果我将它们显示在 table 中,如下所示,"Warning paint queue size exceeded, please watch the amount of repaint calls" 无限显示错误警告。如果我将行限制为 15 或 20,那么它可以工作 normally.How 我可以解决错误吗?
更新:如果我将 "showTableData(f)" 保留在 beforeMain 中,则不会出现警告,但如果我将其注释掉并保留在 postMain 中,则会出现警告。这是为什么?
@Override
protected void beforeMain(Form f) {
// showTableData(f);
// f.revalidate();
}
Container wrapContainer;
Container containerTableDataGroup;
String detailId = "";
@Override
protected void postMain(Form f) {
showTableData(f); //keeping table data here gives warnings
f.forceRevalidate();
}
public void showTableData(Form f) {
f.setScrollableY(true);
wrapContainer = new Container();
GroupConnection gc = new GroupConnection();
for (int i = 0; i < 200; i++) {
Container tableNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea tableNameData = new TextArea();
tableNameData.setText("tableNameData");
stylingTextArea(tableNameData);
tableNameData.setActAsLabel(true);
tableNameDataContainer.add(tableNameData);
Container inaugurationDateDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea inaugurationDateData = new TextArea();
inaugurationDateData.setText("inaugurationDate");
stylingTextArea(inaugurationDateData);
inaugurationDateData.setActAsLabel(true);
inaugurationDateDataContainer.add(inaugurationDateData);
Container areaCodeDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea areaCodeData = new TextArea();
areaCodeData.setText("areaCodeData");
stylingTextArea(areaCodeData);
areaCodeData.setActAsLabel(true);
areaCodeDataContainer.add(areaCodeData);
Container clubAbbrNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea clubAbbrNameData = new TextArea();
clubAbbrNameData.setText("clubAbbrNameData");
stylingTextArea(clubAbbrNameData);
clubAbbrNameData.setActAsLabel(true);
clubAbbrNameDataContainer.add(clubAbbrNameData);
Container clubCharterDateDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea clubCharterDateData = new TextArea();
clubCharterDateData.setText("clubCharterDateData");
stylingTextArea(clubCharterDateData);
clubCharterDateData.setActAsLabel(true);
clubCharterDateDataContainer.add(clubCharterDateData);
TableLayout tl1 = new TableLayout(1, 5);
containerTableDataGroup = new Container(tl1);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(30), tableNameDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(20), inaugurationDateDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(15), areaCodeDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(15), clubAbbrNameDataContainer);
containerTableDataGroup.add(tl1.createConstraint().widthPercentage(20), clubCharterDateDataContainer);
wrapContainer.add(containerTableDataGroup);
}
f.add(wrapContainer);
wrapContainer.revalidate();
}
public void stylingTextArea(TextArea textAreaName) {
textAreaName.setUIID("styleTextArea");
textAreaName.getAllStyles().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
textAreaName.getAllStyles().setPadding(0, 0, 0, 0);
textAreaName.getAllStyles().setAlignment(Component.CENTER);
textAreaName.setEditable(false);
textAreaName.setGrowByContent(true);
textAreaName.setGrowLimit(2);
}
更新 2: 如果我使用 addToQueue 在 beforeForm 方法中保持连接,则会显示空白屏幕。如果我使用 addToQueueAndWait,无限进度只会在很短的时间内显示,仅在几秒钟后显示数据(smtimes 需要更多时间来显示)。我在 postForm 和 addToQueue 的连接请求方法中使用了 actionlistener 回调,但同样在 beforeForm 中不起作用。
protected void beforeGroups(Form f) {
groupConnection();
wrapContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for (Map<String, Object> element : response) {
String tableName = (String) element.get("name");
. . . . . . .
. . . . . . .
}
}
void groupConnection() {
ConnectionRequest connectionRequest = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jSONParser = new JSONParser();
Map<String, Object> parsedData = jSONParser.parseJSON(new InputStreamReader(input));
response = (ArrayList<Map<String, Object>>) parsedData.get("root");
}
};
connectionRequest.setUrl(allUrl.groupsUrl);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
connectionRequest.setDisposeOnCompletion(d);
NetworkManager.getInstance().addToQueue(connectionRequest);//blank screen if addToQueueAndWait isnot used here
}
更新 3:
@Override
protected void beforeAbc(Form f) {
minuteConnection(f);
}
void minuteConnection(Form f) {
ConnectionRequest connectionRequest = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jSONParser = new JSONParser();
Map<String, Object> parsedData = jSONParser.parseJSON(new InputStreamReader(input));
responsee = (ArrayList<Map<String, Object>>) parsedData.get("root");
}
@Override
protected void postResponse() {
int i = 0;
wrapContainerMeeting = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for (Map<String, Object> element : responsee) {
String minuteId = (String) element.get("meetingNumberId");
String tblId = (String) element.get("tbladmin_id");
String tableName = (String) element.get("name");
String totalMembers = (String) element.get("continousMeetingNumber");
String totalMeetingYearly = (String) element.get("meetingForYear");
String minuteDate = (String) element.get("meetingDate");
Container tableNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea tableNameDataMeeting = new TextArea(tableName);
tableNameDataContainer.add(tableNameDataMeeting);
Container inaugurationDateDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea inaugurationDateDataMeeting = new TextArea(totalMembers);
inaugurationDateDataContainer.add(inaugurationDateDataMeeting);
Container areaCodeDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea areaCodeData = new TextArea(totalMeetingYearly);
areaCodeDataContainer.add(areaCodeData);
Container clubAbbrNameDataContainer = new Container(new FlowLayout(Component.CENTER, Component.CENTER));
TextArea clubAbbrNameData = new TextArea(minuteDate);
clubAbbrNameDataContainer.add(clubAbbrNameData);
}
f.add(wrapContainerMeeting);
}
};
AllUrl allUrl = new AllUrl();
connectionRequest.setUrl(allUrl.abcUrl);
connectionRequest.setPost(false);//keeping this line or deleting doesnt affect anything
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
connectionRequest.setDisposeOnCompletion(d);
NetworkManager.getInstance().addToQueue(connectionRequest);
}
您为添加的每一行都调用 revalidate
,这是非常过分的...
您需要在添加完所有内容后执行一次此操作。