📄 orderdialog.java
字号:
/*
* Created on 2005-6-12
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package bomb;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import java.util.Properties;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class OrderDialog extends CustomerDialog {
private static Label pTime = null;
private static Label pName = null;
private static Label mTime = null;
private static Label mName = null;
private static Label aTime = null;
private static Label aName = null;
Properties prop = null;
public OrderDialog(Shell parent){
super(parent,"扫雷英雄排行榜");
prop = new Properties();
try{
// prop.load(new FileInputStream("E:\\eclipse3\\workspace\\bomb\\src\\bomb\\order.properties"));
prop.load(this.getClass().getResourceAsStream("order.properties"));
}catch(IOException e){
e.printStackTrace();
}
this.setInit();
}
/* (non-Javadoc)
* @see bomb.CustomerDialog#addControls(org.eclipse.swt.widgets.Shell)
*/
public void addControls( Shell shell) {
// TODO Auto-generated method stub
GridLayout layout = new GridLayout(3,true);
shell.setLayout(layout);
Label labP = new Label(shell,SWT.NONE);
labP.setText( "初级");
GridData dataL = new GridData();
dataL.horizontalAlignment = SWT.CENTER;
labP.setLayoutData(dataL);
pTime = new Label(shell,SWT.NONE);
GridData dataM = new GridData();
dataM.horizontalAlignment = SWT.CENTER;
pTime.setLayoutData(dataM);
pName = new Label(shell,SWT.NONE);
GridData dataR = new GridData();
dataR.horizontalAlignment = SWT.CENTER;
pName.setLayoutData(dataR);
Label labM = new Label(shell,SWT.NONE);
labM.setText( "中级");
GridData dataL2 = new GridData();
dataL2.horizontalAlignment = SWT.CENTER;
labM.setLayoutData(dataL2);
mTime = new Label(shell,SWT.NONE);
GridData dataM2 = new GridData();
dataM2.horizontalAlignment = SWT.CENTER;
mTime.setLayoutData(dataM2);
mName = new Label(shell,SWT.NONE);
GridData dataR2 = new GridData();
dataR2.horizontalAlignment = SWT.CENTER;
mName.setLayoutData(dataR2);
Label labA = new Label(shell,SWT.NONE);
labA.setText( "高级");
GridData dataL3 = new GridData();
dataL3.horizontalAlignment = SWT.CENTER;
labA.setLayoutData(dataL3);
aTime = new Label(shell,SWT.NONE);
GridData dataM3 = new GridData();
dataM3.horizontalAlignment = SWT.CENTER;
aTime.setLayoutData(dataM3);
aName = new Label(shell,SWT.NONE);
GridData dataR3 = new GridData();
dataR3.horizontalAlignment = SWT.CENTER;
aName.setLayoutData(dataR3);
Button bReset = new Button(shell,SWT.PUSH);
GridData dataB1 = new GridData();
dataB1.horizontalAlignment = SWT.CENTER;
bReset.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent event){
processReset();
}
});
bReset.setText("重新计分");
bReset.setLayoutData(dataB1);
Label lab = new Label(shell,SWT.NONE);
GridData dataT1 = new GridData();
dataT1.horizontalAlignment = SWT.FILL;
lab.setLayoutData(dataT1);
Button ok = new Button(shell,SWT.PUSH);
GridData dataO1 = new GridData();
dataO1.horizontalAlignment = SWT.CENTER;
ok.setText( "确定");
ok.setLayoutData(dataO1);
ok.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
process();
}
});
}
private void process(){
this.getShell().close();
}
private void processReset(){
setPT("999");
setPN("匿名");
setMT("999");
setMN("匿名");
setAT("999");
setAN("匿名");
save();
}
public void setPT(String pt){
pTime.setText( pt);
}
public void setPN(String pn){
pName.setText( pn);
}
public void setAT(String at){
System.out.println(at);
aTime.setText( at);
}
public void setAN(String an){
aName.setText( an);
}
public void setMT(String mt){
mTime.setText( mt);
}
public void setMN(String mn){
mName.setText( mn);
}
public void setInit(){
pTime.setText(prop.getProperty("primaryTime","999") );
pName.setText(prop.getProperty( "primaryName","匿名"));
mTime.setText(prop.getProperty("middleTime","999") );
mName.setText(prop.getProperty( "middleName","匿名"));
aTime.setText(prop.getProperty("advanceTime","999") );
aName.setText(prop.getProperty( "advanceName","匿名"));
}
private void save(){
prop.setProperty("primaryTime",pTime.getText());
//prop.setProperty("primaryName",pName.getText());
prop.setProperty("middleTime",mTime.getText());
// prop.setProperty("middleName",mName.getText());
prop.setProperty("advanceTime",aTime.getText());
// prop.setProperty("advanceName",aName.getText());
try{
prop.store(new FileOutputStream("order.properties"),"record");
}catch(Exception ioe){
ioe.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -