本文整理汇总了Java中javax.swing.DefaultComboBoxModel.setSelectedItem方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultComboBoxModel.setSelectedItem方法的具体用法?Java DefaultComboBoxModel.setSelectedItem怎么用?Java DefaultComboBoxModel.setSelectedItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultComboBoxModel
的用法示例。
在下文中一共展示了DefaultComboBoxModel.setSelectedItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: btnProjectActionPerformed
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void btnProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProjectActionPerformed
JFileChooser chooser = ProjectChooser.projectChooser();
int res = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this));
if (res == JFileChooser.APPROVE_OPTION) {
File fil = chooser.getSelectedFile();
FileObject fo = FileUtil.toFileObject(fil);
if (fo != null) {
try {
Project p = ProjectManager.getDefault().findProject(fo);
DefaultComboBoxModel model = (DefaultComboBoxModel)comProject.getModel();
model.addElement(p);
model.setSelectedItem(p);
if (EMPTY == model.getElementAt(0)) {
model.removeElement(EMPTY);
}
} catch (IOException exc) {
ErrorManager.getDefault().notify(exc);
}
}
}
}
示例2: setupLoad
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
* Setup load.
*/
private void setupLoad() {
// --- Load the current SimulationSetup ---------------------
currSimSetup = currProject.getSimulationSetups().getCurrSimSetup();
if ( currSimSetup==null ) {
SimulationSetups setups = currProject.getSimulationSetups();
String currSimSetupName = currProject.getSimulationSetupCurrent();
setups.setupLoadAndFocus(SimNoteReason.SIMULATION_SETUP_LOAD, currSimSetupName, false);
currSimSetup = currProject.getSimulationSetups().getCurrSimSetup();
}
// --- Load the current DefaultListModel laden --------------
this.jListModelAgents2Start = this.currSimSetup.getAgentDefaultListModel(this.jListModelAgents2Start, SimulationSetup.AGENT_LIST_ManualConfiguration);
this.getJListStartList().setModel(this.jListModelAgents2Start);
// --- Set the ComboBoxModel for the StartList Selector -----
DefaultComboBoxModel<String> cbm = currSimSetup.getComboBoxModel4AgentLists();
cbm.setSelectedItem(SimulationSetup.AGENT_LIST_ManualConfiguration);
this.getJComboBoxStartLists().setModel(cbm);
this.setJListStartListEmptySelection();
}
示例3: ClassNamePanel
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
* Creates new form ClassNamePanel
*/
public ClassNamePanel(Project project, FileObject anchor, String initialName) {
this.project = project;
this.anchor = anchor;
initComponents();
Project openProjects[] = OpenProjects.getDefault().getOpenProjects();
Arrays.sort( openProjects, new ProjectByDisplayNameComparator());
DefaultComboBoxModel projectsModel = new DefaultComboBoxModel( openProjects );
projectSelector.setModel( projectsModel );
if (project != null) {
projectSelector.setSelectedItem( project );
projectSelector.setEnabled(false);
projectLabel.setEnabled(false);
} else if (projectsModel.getSize() > 0) {
this.project = (Project)projectsModel.getElementAt(0);
projectsModel.setSelectedItem(this.project);
}
projectSelector.setRenderer(new ProjectCellRenderer());
locationSelect.setRenderer(new GroupCellRenderer());
packageSelect.setRenderer(PackageView.listRenderer());
updateRoots();
updatePackages();
selectInitialPackage();
ActionListener al = this::actionPerformed;
locationSelect.addActionListener(al);
packageSelect.addActionListener(al);
packageSelect.getEditor().addActionListener(al);
projectSelector.addActionListener(al);
className.getDocument().addDocumentListener(this);
if (initialName != null) {
className.setText(initialName);
}
}
示例4: setConfigValues
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void setConfigValues() {
ConfigIO cfg = ConfigIO.getInstance();
if (cfg.getUsername() != null) {
userInput.setText(cfg.getUsername());
}
if (cfg.getPassword() != null) {
pwdInput.setText(cfg.getPassword());
}
if (cfg.getPassword() != null) {
pwdInput.setText(cfg.getPassword());
}
if (cfg.isMasterPwdEnabled()) {
useMasterPasswordInput.setSelected(true);
setMasterPwdInputEnabled(true);
}
else{
useMasterPasswordInput.setSelected(false);
setMasterPwdInputEnabled(false);
}
if (cfg.getMasterPassword() != null) {
masterPwdInput.setText(cfg.getMasterPassword());
}
if (cfg.getServerUrl() != null) {
serverInput.setText(cfg.getServerUrl());
}
if (cfg.getStoragePath() != null) {
pathInput.setText(cfg.getStoragePath());
}
if (cfg.getScreenId() != null) {
ScreenModel screen = Util.getScreen(cfg.getScreenId());
DefaultComboBoxModel<ScreenModel> screenBoxModel = new DefaultComboBoxModel<ScreenModel>(
(ScreenModel[]) Util.getScreens());
screenBoxModel.setSelectedItem(screen);
screenBox.setModel(screenBoxModel);
}
if (cfg.getAuthMethod() != null) {
AuthModel authModel = Util.getAuthModel(cfg.getAuthMethod());
DefaultComboBoxModel<AuthModel> authBoxModel = new DefaultComboBoxModel<AuthModel>(
(AuthModel[]) Util.getAuthMethods());
authBoxModel.setSelectedItem(authModel);
authBox.setModel(authBoxModel);
}
if (cfg.isUseDarkIcon()) {
darkIconInput.setSelected(true);
}
else{
darkIconInput.setSelected(false);
}
// set screen position
ScreenPosition pos = Util.getScreenPosition(cfg.getScreenPositionId());
DefaultComboBoxModel<ScreenPosition> cornerBoxModel = new DefaultComboBoxModel<ScreenPosition>(
(ScreenPosition[]) Util.getScreenPositions());
cornerBoxModel.setSelectedItem(pos);
hotCornerBox.setModel(cornerBoxModel);
}
示例5: afterCreate
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
* Чтоб не дублировать код
*
* @param str список пользователей
*/
private void afterCreate(Object[] users) {
jLabel1.setText(getLocaleMessage("jLabel1.text"));
jLabel2.setText(getLocaleMessage("jLabel2.text"));
buttonEnter.setText(getLocaleMessage("pressOK.Action.text"));
buttonExit.setText(getLocaleMessage("pressCancel.Action.text"));
FAbout.loadVersionSt();
labelName.setText(FAbout.NAME_);
DefaultComboBoxModel m = new DefaultComboBoxModel(users);
comboBoxUser.setModel(m);
final File f = new File("temp/lusr");
if (f.exists()) {
String str = "";
try (FileInputStream fis = new FileInputStream(f); Scanner s = new Scanner(
new InputStreamReader(fis, "UTF-8"))) {
while (s.hasNextLine()) {
final String line = s.nextLine().trim();
str += line;
}
} catch (IOException ex) {
}
if (!"".equals(str) && str.matches("-?\\d+(\\.\\d+)?")) {
for (int i = 0; i < m.getSize(); i++) {
if (((QUser) (m.getElementAt(i))).getId().equals(Long.parseLong(str))) {
m.setSelectedItem(m.getElementAt(i));
break;
}
}
}
}
//привязка помощи к форме.
final Helper helper = Helper.getHelp(
level == LEVEL_ADMIN ? "ru/apertum/qsystem/client/help/admin.hs"
: "ru/apertum/qsystem/client/help/client.hs");
helper.enableHelpKey(qPanel1, "loginning");
addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
labelLavel.setLocation(2, getHeight() - 15);
labelServer.setLocation(5, getHeight() - 45);
}
});
}