???今天在修改Editor的實現方式時出現了不能顯示的問題,經多次跟蹤調試發現問題如下,現記錄在此,已備不時之需:
???在實現方法public void createPartControl(Composite parent)時需要以下幾個設置,保證Editor的顯示。
1、parent.setLayout(new FillLayout());? //保證Editor中的內容全部顯示在parent中
2、??
???Composite shell = new Composite(parent, SWT.EMBEDDED | SWT.MAX??| SWT.SCROLL_PAGE);
??shell.setLayout(new FillLayout()); //這里也必須設置Layout
3、
??Frame mainframe = SWT_AWT.new_Frame(shell);
??mainframe.setVisible(true); //如果要嵌入Swing/AWT的UI界面必須設置為可見
4、
??JPanel mainPanel = new JPanel();
??mainPanel.setBackground(Color.WHITE);
???mainframe.add(mainPanel);
??mainPanel.repaint();//其中加入的Panel必須repaint
OK,That's All