📄 jmguicombobox.java
字号:
package jm.framework.gui.container;
import javax.swing.JComponent;
import jm.framework.gui.module.JMComboBox;
import jm.framework.gui.module.JMPanel;
import jm.util.JM2DArray;
import jm.util.JMVector;
/**
* <p>Title: JM 整合Swing控件,使用配置信息</p>
*
* <p>Copyright: Copyright (c) 2004-2006</p>
*
* <p>Company: 1SHome</p>
*
* <p>@author Spook</p>
*
* @since 1.3
* @see JDK 1.5.0.6
*/
public class JMGUIComboBox extends JMGUIAbstractContralPanel {
/**
*
*/
private static final long serialVersionUID = 6412706488560784659L;
public JMGUIComboBox () {
super(new JMPanel());
}
/**
* 初始化
* @throws Exception
* @todo Implement this jm.framework.gui.module.JMContralComponent method
*/
@SuppressWarnings("unchecked")
public void load () throws Exception {
ValueComponent = new JMVector<JComponent>(5);
//类型不正确或者为NULL
if ((DataSource == null)||!(DataSource instanceof JMVector)) {
throw new Exception("DataSource is error");
}
JMVector<JM2DArray> _dataSource_ = (JMVector<JM2DArray>) DataSource;
JMComboBox _component_ = null;
JM2DArray _data_ = null;
for(int d = 0; d < _dataSource_.size(); d++){
_data_ = _dataSource_.get(d);
//列不足
if (_data_.colCount() < 2) {
throw new Exception("DataSource is error, the colCount < 2");
}
_component_ = new JMComboBox();
for (int i = 0; i < _data_.rowCount(); i++) {
_component_.addItem(_data_.getStringValue(i, 1));
if (Value.size() > d &&
_data_.getStringValue(i, 0).equals(Value.get(d))) {
_component_.setSelectedIndex(i);
}
if (Request) {
_component_.setBackground(getRequestColor());
}
}
RootPanel.add(_component_);
ValueComponent.add(_component_);
}
super.load();
}
/**
* 获得显示控件的内容
*
* @return JMVector
* @todo Implement this jm.framework.gui.module.JMContralComponent method
*/
@SuppressWarnings("unchecked")
public JMVector<String> getValue () {
Value = new JMVector<String>();
JMVector<JM2DArray> _dataSource_ = (JMVector<JM2DArray>) DataSource;
JComponent _valueComponent_ = null;
JM2DArray _data_ = null;
for (int i =0;i < ValueComponent.size();i++) {
_data_ = _dataSource_.get(i);
_valueComponent_ = ValueComponent.get(i);
int index = ((JMComboBox)_valueComponent_).getSelectedIndex();
try{
Value.add(_data_.getStringValue(index, 0));
}catch(Exception e){
Value.add("");
}
}
return Value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -