日期:2014-05-20 浏览次数:21187 次
<bean id="productManangerView" class="com.star.client.form.view.ProductManageView">
<property name="productService" ref="productService"></property>
</bean>
//...省略不必要的代码
private ProductSearchForm productSearchForm = new ProductSearchForm();//搜索面板
private IProductService productService;
public void setProductService(IProductService productService) {
this.productService = productService;
}
/**
* 无参构造
*/
private ProductManageView() {
addComponent();
addListener();
addObserver();
init();
}
/**
* 内部控件初始化
*/
private void addComponent() {
JTabbedPane pane = new JTabbedPane(JTabbedPane.TOP);// 服务产品管理面板
JTabbedPane productPane = new JTabbedPane(JTabbedPane.TOP);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
JPanel leftPanel = new JPanel(new BorderLayout());
JPanel rightPanel = new JPanel(new BorderLayout());
splitPane.setDividerSize(5);
splitPane.setDividerLocation(380);
splitPane.setEnabled(false);
productSearchForm.setProductService(productService); //注意这里!为搜索面板set了服务接口,我的问题就发生在这里
leftPanel.add(productSearchForm.getControl(), BorderLayout.NORTH);
leftPanel.add(productDisplayer.getControl(), BorderLayout.CENTER);
productForm.setFormEnable(false);
productPane.addTab("产品信息", productForm.getControl());
JPanel buttonPanel = new JPanel();
buttonPanel.add(addButton);
buttonPanel.add(updateButton);
buttonPanel.add(deleteButton);
rightPanel.add(productPane);
rightPanel.add(buttonPanel, BorderLayout.SOUTH);
splitPane.setLeftComponent(leftPanel);
splitPane.setRightComponent(rightPanel);
pane.addTab("服务产品管理 ", splitPane);
this.add(pane);
addDialog.setProductService(productService);
updateDialog.setProductService(productService);
}
public void showView(){
this.setVisible(true);
}
//...省略不必要的代码
ProductManageView productView = (ProductManageView) context.getBean("productManangerView");
productView.showView();
/**
* 无参构造
*/
private Product、、ManageView() {
//addComponent();
//addListener();
//addObserver();
//init();
}
public void showView(){
addComponent();
addListener();
addObserver();
init();
this.setVisible(true);
}
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="fru" class="cn.mldn.lxh.demo01.Orange"></bean>
<bean id="simple" class="cn.mldn.lxh.demo02.SimpleBean">
<constructor-arg index="0">
<value>LiXingHua</value>
</constructor-arg>
<constructor-arg index="1" value="www.MLDN.cn"></constructor-arg>
</bean>
</beans>