有两个窗体father和son ,我想要的效果是father里有一个按钮,点这个按钮实例化son这个窗体,但任务栏应该只有father这个进程。代码如下:father:
public class father { protected Shell shell;
public static void main(String[] args) {
try {
father window = new father();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
protected void createContents() {
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application"); final Button button = new Button(shell, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent arg0) {
openson() ; }
});
button.setText("button");
button.setBounds(70, 90, 48, 22); final Button button_1 = new Button(shell, SWT.NONE);
button_1.setText("button");
button_1.setBounds(70, 139, 48, 22);
//
}
public void openson()
{son mySon=new son(this);
mySon.open();
} }
son:
public class son { private Table table;
protected Shell shell;
son(){
}
father father;
son(father father){
this.father=father; }
public static void main(String[] args) {
try {
son window = new son();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
protected void createContents() {
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application"); table = new Table(shell, SWT.BORDER);
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setBounds(10, 68, 100, 100);
//
}}
现在是点击father的按钮后出现两个进程,一个是father的一个是son的,请问如何才能只显示一个进程?
public class father { protected Shell shell;
public static void main(String[] args) {
try {
father window = new father();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
protected void createContents() {
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application"); final Button button = new Button(shell, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent arg0) {
openson() ; }
});
button.setText("button");
button.setBounds(70, 90, 48, 22); final Button button_1 = new Button(shell, SWT.NONE);
button_1.setText("button");
button_1.setBounds(70, 139, 48, 22);
//
}
public void openson()
{son mySon=new son(this);
mySon.open();
} }
son:
public class son { private Table table;
protected Shell shell;
son(){
}
father father;
son(father father){
this.father=father; }
public static void main(String[] args) {
try {
son window = new son();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
protected void createContents() {
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application"); table = new Table(shell, SWT.BORDER);
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setBounds(10, 68, 100, 100);
//
}}
现在是点击father的按钮后出现两个进程,一个是father的一个是son的,请问如何才能只显示一个进程?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货