java编程用到swt,打开文件夹的方法的参数是什么 5
publicclassserverextendsShell{privateListlist;/***Launchtheapplication*@paramargs*/pu...
public class server extends Shell {
private List list;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
Display display = Display.getDefault();
server shell = new server(display, SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the shell
* @param display
* @param style
*/
public server(Display display, int style) {
super(display, style);
createContents();
setLayout(new FillLayout());
}
/**
* Create contents of the window
*/
protected void createContents() {
setText("SWT Application");
setSize(500, 375);
final Composite composite = new Composite(this, SWT.NONE);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
composite.setLayout(gridLayout);
list = new List(composite, SWT.BORDER);
final GridData gd_list = new GridData(SWT.FILL, SWT.BOTTOM, false, false, 3, 1);
gd_list.heightHint = 227;
gd_list.widthHint = 396;
list.setLayoutData(gd_list);
final Button open = new Button(composite, SWT.NONE);
open.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
//打开文件夹,这里的参数是什么???
FileDialog fileDialog = new FileDialog();
}
});
final GridData gd_open = new GridData(SWT.LEFT, SWT.CENTER, false, true);
gd_open.widthHint = 152;
open.setLayoutData(gd_open);
open.setText("打开");
final Button submit = new Button(composite, SWT.NONE);
final GridData gd_submit = new GridData(SWT.FILL, SWT.CENTER, false, true);
gd_submit.widthHint = 169;
submit.setLayoutData(gd_submit);
submit.setText("确定");
final Button exit = new Button(composite, SWT.NONE);
final GridData gd_exit = new GridData(SWT.LEFT, SWT.CENTER, false, true);
gd_exit.widthHint = 151;
exit.setLayoutData(gd_exit);
exit.setText("退出");
//
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
我知道是父类,但是我是初学者,不知道在这个程序里应该写什么,参数到底是什么啊?晕 展开
private List list;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
Display display = Display.getDefault();
server shell = new server(display, SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the shell
* @param display
* @param style
*/
public server(Display display, int style) {
super(display, style);
createContents();
setLayout(new FillLayout());
}
/**
* Create contents of the window
*/
protected void createContents() {
setText("SWT Application");
setSize(500, 375);
final Composite composite = new Composite(this, SWT.NONE);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
composite.setLayout(gridLayout);
list = new List(composite, SWT.BORDER);
final GridData gd_list = new GridData(SWT.FILL, SWT.BOTTOM, false, false, 3, 1);
gd_list.heightHint = 227;
gd_list.widthHint = 396;
list.setLayoutData(gd_list);
final Button open = new Button(composite, SWT.NONE);
open.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
//打开文件夹,这里的参数是什么???
FileDialog fileDialog = new FileDialog();
}
});
final GridData gd_open = new GridData(SWT.LEFT, SWT.CENTER, false, true);
gd_open.widthHint = 152;
open.setLayoutData(gd_open);
open.setText("打开");
final Button submit = new Button(composite, SWT.NONE);
final GridData gd_submit = new GridData(SWT.FILL, SWT.CENTER, false, true);
gd_submit.widthHint = 169;
submit.setLayoutData(gd_submit);
submit.setText("确定");
final Button exit = new Button(composite, SWT.NONE);
final GridData gd_exit = new GridData(SWT.LEFT, SWT.CENTER, false, true);
gd_exit.widthHint = 151;
exit.setLayoutData(gd_exit);
exit.setText("退出");
//
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
我知道是父类,但是我是初学者,不知道在这个程序里应该写什么,参数到底是什么啊?晕 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询