救命啊

qiang925 2008-03-02 05:54:51
Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText("图像处理");
GridLayout gridLayout = new GridLayout(5,true);

Composite composite = new Composite(shell, SWT.BORDER);
composite.setLayout(gridLayout);

GridData da = new GridData();
da.horizontalSpan = 2;
da.horizontalAlignment = SWT.FILL;

Button bt = new Button(composite,SWT.PUSH);
bt.setText("5");
bt.setLayoutData(da);

shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

为什么这样不能显示按键5出来,运行通过是没有问题
我是想问下,在面板composite中建立一个GridLayout,在里面再建一个GridData,是不是可以上面那样的,谢谢
如果不,那应该怎么办,我就是想在shell中建个面板,在面板中建立一个GridLayout,,再创建一个按钮!
...全文
69 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
YEYUI 2008-03-03
  • 打赏
  • 举报
回复
import java.awt.*;
import javax.swing.*;
public class shell(){
}
JButton jbutton=new JButton("按钮");/
Panbel P=new Panble("面板");
public shell(){
super();
this.add(P);
p.setLayout(new GridLayout(int i,int y));
p.add(jbutton);

}
public void main(String args[]){
new shell();
}

qiang925 2008-03-02
  • 打赏
  • 举报
回复
我用的是eclipse+swt,不要弄awt和swing的代码来哦,谢谢

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧