SWT 无法弹出第二个窗口 30
第一个窗口可以显示,但是单击button无法弹出第二个窗口这是程序:packagelangya;importorg.eclipse.swt.SWT;importorg.e...
第一个窗口可以显示,但是单击button无法弹出第二个窗口
这是程序:
package langya;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.*;
public class lang{
private Button button;
private Shell shell;
private Display display;
public lang(){
super();
display=new Display();
shell=new Shell(display);
shell.setSize(500,200);
button = new Button(shell, SWT.NONE);
button.setText("button1");
button.setBounds(115, 125, 105, 30);
button.addMouseListener(new MouseAdapter(){
public void mouseDown(MouseEvent e){
lang one = new lang();
one.other();
}
});
}
public void other() {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
public void start(){
shell.open();
while(!shell.isDisposed()){
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public static void main(String[] args)
{
lang button=new lang();
button.start();
}
}
搞定了 展开
这是程序:
package langya;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.*;
public class lang{
private Button button;
private Shell shell;
private Display display;
public lang(){
super();
display=new Display();
shell=new Shell(display);
shell.setSize(500,200);
button = new Button(shell, SWT.NONE);
button.setText("button1");
button.setBounds(115, 125, 105, 30);
button.addMouseListener(new MouseAdapter(){
public void mouseDown(MouseEvent e){
lang one = new lang();
one.other();
}
});
}
public void other() {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
public void start(){
shell.open();
while(!shell.isDisposed()){
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public static void main(String[] args)
{
lang button=new lang();
button.start();
}
}
搞定了 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询