java介面出不來 有代码求真相
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
public class yonghu {
public static void main(String[] args){
Display display=new Display();
Shell shell3=new Shell(display);
shell3.setBounds(200, 200, 500, 300);
TabFolder tabFolder=new TabFolder(shell3,SWT.NONE);
tabFolder.setBounds(0, 0, 500, 300);
TabItem tabItem1=new TabItem(tabFolder,SWT.NONE);
tabItem1.setText("用户查询");{
Composite composite1=new Composite(tabFolder,SWT.NONE);
composite1.setBounds(0, 0, 500, 300);
tabItem1.setControl(composite1);
Label lb3=new Label(composite1,SWT.NONE);
lb3.setText("请输入用户账号:");
lb3.setBounds(50, 50, 100, 25);
lb3.pack();
Text text3=new Text(composite1,SWT.BORDER);
text3.setBounds(50, 100, 100, 25);
Button bt4=new Button(composite1,SWT.NONE);
bt4.setText("查询");
bt4.setBounds(200,100 , 60,25); }
TabItem tabItem2=new TabItem(tabFolder,SWT.NONE);
tabItem2.setText("2");{
Composite composite2=new Composite(tabFolder,SWT.NONE);
composite2.setBounds(0, 0, 500, 300);
tabItem1.setControl(composite2);
}
TabItem tabItem3=new TabItem(tabFolder,SWT.NONE);
tabItem3.setText("3");{
Composite composite3=new Composite(tabFolder,SWT.NONE);
composite3.setBounds(0, 0, 500, 300);
tabItem1.setControl(composite3);
}
shell3.open();
while (!shell3.isDisposed()){
if(!display.readAndDispatch()){
display.sleep();
}
}
display.dispose();
}
}
代码
红色部分出不来 为什么 ???
------解决方案--------------------你都没把他们加入到容器里面
------解决方案--------------------tabItem1.setControl(composite2);
tabItem1.setControl(composite3);
LZ编码时细心一点,
这两行copy后,忘记改了