public class BasicMemorySection {
private FormToolkit toolkit;
private Form form;
private String title;
private int style;
private IndexerDetail detail;
private AssetServer server; public BasicMemorySection(String title, Form form, int style) {
this.title = title;
this.form = form;
this.style = style;
} public Section createMemoryContent() {
IndexerDetail detail=new IndexerDetail();
AssetServer server=new AssetServer();
final ServerMonitorService service = (ServerMonitorService) ModelFactory
.getModel().getService(ServerMonitorService.class.getName());
detail = service.getIndexerDetail(server);
GridData gd21 = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);

toolkit = new FormToolkit(form.getDisplay());
Section memorySection = toolkit.createSection(form.getBody(), style);
memorySection.setText(title);
memorySection.setLayoutData(gd21);

Composite client = toolkit.createComposite(memorySection);
client.setLayout(new FormLayout());
memorySection.setClient(client); Composite client1 = toolkit.createComposite(client);
FormData data = new FormData();
data.top = data.left = new FormAttachment(2);
data.width = 400;
data.height = 250;
client1.setLayoutData(data);
client1.setLayout(new FillLayout()); Map<String, String> map = new HashMap<String, String>();
map.put("未用", detail.getMemoryFree());
map.put("已用", detail.getMemoryUsed());
new SOCChart(client1, SupportSWF.PIE_3D, "感染范围", "100%", "100%",
cn.antvision.soldier.portal.server.moniter.util.ChartUtil
.getPieChartData(map, "MB"), null);
return memorySection;
}}
谁能告诉我怎么修改detail才不是空的

解决方案 »

  1.   

    报空指针异常,检查完说是detail值为空,我搞不明白,问题就出在map.put("未用", detail.getMemoryFree());
    at cn.antvision.soldier.portal.server.moniter.icomposite.BasicMemorySection.createMemoryContent(BasicMemorySection.java:64)
    我觉得我说的很明白了就是帮忙看看detail怎么就没值了
      

  2.   

    service.getIndexerDetail(server);
    看看是不是这里返回Null了