软件设计模式与体系结?- 百度文库 ر

.

txtEmailAddr;

2private JLabel lblCustomerName, lblAddress,lblZip, lblCellphone, lblSSN, lblEmailAddr;

3txtEmailAddr=new JTextField(20);

4lblEmailAddr= new JLabel(\

5UIPanel.add(lblEmailAddr);

6gridbag.setConstraints(lblEmailAddr, gbc);

7public String getEmailAddr(){

8String emailaddr = getEmailAddr();

return txtEmailAddr.getText(); gbc.gridx = 1; gbc.gridy = 5;

gridbag.setConstraints(txtEmailAddr, gbc); gbc.gridx = 0; gbc.gridy = 6;

UIPanel.add(txtEmailAddr);

}

-

.

9if(cusInfo.isValidEmailAddr(emailaddr)==false){

dataTextArea.append(\ } else{

dataTextArea.append(\ }

ʵ

ʵС᡿

-

.

ͨͻ˿ԵͬһӿڣԿͻ˵͸ġ򵥡ֱӡգִִ࣬͸ûҪһµ⣻Ŀͨһе࣬޸ԭд룻 һ԰Ѷͬ䵽ͬһĿ꣬Ҳ˵ͬһ԰඼䵽Ŀӿڡڶ˵ʵֹ̱Ƚϸӡ

ʵ

Žģʽ

ʵݡ

3.14еʵಿУEllipsoid࣬ʵļ㡣

Ӵ롿

1ࣺ

public class Ellipsoid implements GeoForm{

private double aRadius; private double bRadius;

-

.

private double cRadius;

public Ellipsoid (double aRadius, double bRadius, double cRadius){ this.aRadius = aRadius; this.bRadius = bRadius;

this.cRadius = cRadius;

}

public double computeVolume(){

double volume = 1.3333333*3.1415926* aRadius* cRadius;

return volume; } }

2GUI

1private JTextField txtEllipsoidRadius_a; private JTextField txtEllipsoidRadius_b; private JTextField txtEllipsoidRadius_c;

2public static final String ELLIPSOID = \

3cmbGeoForm.addItem(ELLIPSOID);

4else if(selection.equals(ELLIPSOID) ){

String a_radius = txtEllipsoidRadius_a.getText();

-

bRadius*