Strange Problem about rcp quit unexpectedly. [message #466219] |
Mon, 16 April 2007 15:50 |
Eclipse User |
|
|
|
Originally posted by: haoniukun.gmail.com
Dear all,
I've just wrote such an RCP application.
But it always quit unexpectedly at startup.
Would anyone please help to point out my mistake?
Thanks in advance.
private void createMainCanvas() {
try {
MainCanvas = new Canvas(top, SWT.DOUBLE_BUFFERED);
MainCanvas.setLayout(new GridLayout());
MainCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
setLabel();
paintLabel(e.gc);
}
});
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder documentBuilder = builderFactory
.newDocumentBuilder();
Document phoneBookDoc = documentBuilder.parse(new File("book.xml"));
NodeList phoneNodeBook = phoneBookDoc.getElementsByTagName("name");
List<String> nameList = null;
if (phoneNodeBook.getLength() == 0) {
System.out.println("book error");
return;
}
total = phoneNodeBook.getLength();
for (int i = 0; i < phoneNodeBook.getLength(); i++) {
nameList.add(phoneNodeBook.item(i).getTextContent());
System.out.println(i);
}
buttonLabel = new CLabel(MainCanvas, SWT.CENTER);
buttonLabel.setText("PAGE " + pageNumber + " / " + (total / 4 + 1));
buttonLabel.setFont(new Font(Display.getDefault(), "MS UI Gothic",
12, SWT.NORMAL));
buttonLabel.setBounds(new Rectangle(100, 100, 100, 100));
buttonLabel.setBackground(Display.getCurrent().getSystemColo r(
SWT.COLOR_BLACK));
buttonLabel.setForeground(Display.getCurrent().getSystemColo r(
SWT.COLOR_BLUE));
buttonLabel.addMouseListener(buttonMouse);
} catch (Exception e) {
e.printStackTrace();
}
}
I'm sure that my xml is parsed successfully. And if I delete the
buttonLabel. It works fine.
And another problem. I don't have trim on my window.
And if I quit the program by program manager on my system,an error
messagebox popup shows that I'm wrong.
How can I avoid this?
Any help is highly appreciated.
|
|
|
Powered by
FUDForum. Page generated in 0.03083 seconds