0
我正在使用RCP 3.x並嘗試創建一個我想要的完整左側佈局。我嘗試了很多組合,但似乎沒有任何工作。這是截圖。 Eclipse-RCP視圖未全屏顯示
這裏是代碼片段,我用來創建這個
public MonitorView(final Composite parent)
{
super(parent);
setDisplayName(I18N("Visual Monitoring of iCommand"));
setLayout(new GridLayout());
final Composite composite=GUIToolkit.newComposite(parent, SWT.NONE, new GridData(SWT.TOP,SWT.LEFT,false,false,0,0));
GridLayout layout=new GridLayout();
composite.setLayout(layout);
CreatePartControl(parent);
}
private void CreatePartControl(Composite parent)
{
// TODO Auto-generated method stub
final Composite c =new Composite(parent,SWT.NONE);
final Canvas canvas=new Canvas(parent,SWT.NONE);
Color red = display.getSystemColor(SWT.COLOR_RED);
canvas.setBackground(red);
c.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent event)
{
int offset_x=130;
int offset_y=70;
int j=0,i=0,n=3,x,y;
DrawRoundedRectangle d= new DrawRoundedRectangle();
//for loop for column 1.Placing elements column wise.
for(i=0;i<n;i++)
{ x=0;y=offset_y*j;
d.drawrectangle(event, x, y, j);
j++;
x=0;y=offset_y*j;
d.drawrectangle(event, x, y, j);
j++;
}
j=0;int flag=6;
//for loop for drawing column 2
for(i=0;i<n;i++)
{
x=offset_x; y=offset_y*j;
d.drawrectangle(event, x, y, flag);
j++;flag++;
x=offset_x;y=offset_y*j;
d.drawrectangle(event, x, y, flag);
flag++;
j++;
}
}
});
}
爲什麼認爲從左邊開始,爲什麼在畫布上是紅色的只能從右側..爲什麼矩形的背景也不是紅色。
僅供參考。這裏是drawRoundedRectangle的代碼。
void drawrectangle(PaintEvent event, int x,int y,int j)
{
event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
event.gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
Font font = new Font(Display.getCurrent(),"Arial",font_size,SWT.BOLD | SWT.ITALIC);
event.gc.setFont(font);
event.gc.drawRoundRectangle(initial_pos_x+x,initial_pos_y+y,width_of_rect,height_of_rect,arc_width,arc_height);
event.gc.fillRoundRectangle(initial_pos_x+adjust_pos_x+x,initial_pos_y+adjust_pos_y+y,width_of_rect+adjust_width_x,height_of_rect+adjust_height_y,arc_width,arc_height);
event.gc.drawText(Services_name.get(j), text_x+x,text_y+y);
}
[編輯]:經過修改@ greg449告訴這裏的result.It沒有意義爲什麼當我做了必要的邏輯變化
感謝您的解釋,他們是在他們的邏輯最好,但包括你的變化後,我得到的東西無法解釋。請參閱問題中的編輯。再次感謝 – 2015-04-01 06:20:39
您可能沒有在各種控件上設置足夠的佈局和佈局數據。用修改後的代碼問一個新問題。 – 2015-04-01 06:57:11
我通過使用填充佈局解決了這個問題。但觀點仍然在右...任何想法?我應該爲此添加一個新問題嗎? – 2015-04-01 07:47:04