下面列出了javax.swing.DefaultComboBoxModel#getSelectedItem ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void validateState() {
final DefaultComboBoxModel queries = getQueries();
setQuerySelected( queries.getSelectedItem() != null );
if ( queries.getSelectedItem() == null ) {
setPreviewPossible( false );
return;
}
final DataSetQuery o = (DataSetQuery) queries.getSelectedItem();
if ( o == null || StringUtils.isEmpty( o.getQueryName() ) ) {
setPreviewPossible( false );
return;
}
setPreviewPossible( true );
}
private void updateStatisticsComboBox() {
String newName = Statistic.GRANULARITY_MAXIMUM.getName(gui.getGranularity());
@SuppressWarnings("unchecked")
DefaultComboBoxModel<Object> model = (DefaultComboBoxModel<Object>) ((JComboBox<Object>) statsPanel
.getComponent(1)).getModel();
boolean reselect = false;
if (model.getSelectedItem() == model.getElementAt(4)) {
reselect = true;
}
model.removeElementAt(4);
model.insertElementAt(newName, 4);
if (reselect) {
model.setSelectedItem(newName);
}
}
private void cbComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbComboBoxActionPerformed
DefaultComboBoxModel<ConnectionParamSet> model
= (DefaultComboBoxModel<ConnectionParamSet>) cbComboBox.getModel();
ConnectionParamSet cb = (ConnectionParamSet) model.getSelectedItem();
if (cb != null) {
textFieldDescription.setText(cb.getDescription());
textFieldServer.setText(cb.getHost());
textFieldPort.setText(String.valueOf(cb.getPort()));
}
}
public void propertyChange(final PropertyChangeEvent aEvent)
{
final DataSourceDialogModel theDialogModel = (DataSourceDialogModel) aEvent.getSource();
final DefaultComboBoxModel theConnections = theDialogModel.getConnections();
final Object theConnection = theConnections.getSelectedItem();
if (theConnection != null)
{
dataSourceList.setSelectedValue(theConnection, true);
}
else
{
dataSourceList.clearSelection();
}
}
public void contentsChanged(final ListDataEvent e)
{
final DefaultComboBoxModel connections = getConnections();
final DataSetComboBoxModel<String> queries = getQueries();
setConnectionSelected(connections.getSelectedItem() != null);
setQuerySelected(queries.getSelectedItem() != null);
if (connections.getSelectedItem() == null)
{
setPreviewPossible(false);
return;
}
if (queries.getSelectedItem() == null)
{
setPreviewPossible(false);
return;
}
final DataSetQuery o = (DataSetQuery) queries.getSelectedItem();
if (o == null || StringUtils.isEmpty(o.getQueryName()))
{
setPreviewPossible(false);
return;
}
setPreviewPossible(true);
}
public void componentOpened() {
// TODO add custom code on component opening
aModel = OpenSimDB.getInstance().getCurrentModel();
if (aModel==null){
jModelNameLabel.setText("No Models");
hasModel=false;
coords = null; // Don't keep reference to old model's coordinates to avoid memory leak'
mapCoordinates2Sliders.clear();
updateAvailability();
updatePosesPopup();
return;
}
else if (aModel instanceof ModelForExperimentalData){
jModelNameLabel.setText("");
coords = null; // Don't keep reference to old model's coordinates to avoid memory leak'
mapCoordinates2Sliders.clear();
hasModel = false;
updateAvailability();
updatePosesPopup();
return;
}
openSimContext = OpenSimDB.getInstance().getContext(aModel);
hasModel=true;
if (ViewDB.getInstance().getModelSavedSettings(aModel)==null)
modelHasFile = false;
else{
modelHasFile=true;
prefs=ViewDB.getInstance().getModelSavedSettings(aModel).getPrefs();
}
jModelNameLabel.setText(aModel.getName());
if (aModel.getNumCoordinates()==0) return;
coords = aModel.getCoordinateSet();
updateAvailability();
Vector<String> coordinateGroupNames = new Vector<String>();
for(int i=0; i<coords.getNumGroups(); i++)
coordinateGroupNames.add(coords.getGroup(i).getName());
groupsComboBoxModel = new DefaultComboBoxModel(coordinateGroupNames);
jCoordinateGroupsComboBox.setModel(groupsComboBoxModel);
String currentGroupName= (String)groupsComboBoxModel.getSelectedItem();
//currentGroup = coords.getGroup(currentGroupName);
// Create CoordinateSliderWithBox for each coordinate and add them to the ScrollPane
updateDisplayGroup();
ViewDB.getInstance().updateModelDisplay(OpenSimDB.getInstance().getCurrentModel());
updatePosesPopup();
}