use of javax.swing.DefaultComboBoxModel in project gephi by gephi.
the class EdgeTypePanel method initComponents.
private void initComponents() {
comboBox = new javax.swing.JComboBox();
setLayout(new java.awt.BorderLayout());
comboBox.setModel(new DefaultComboBoxModel());
add(comboBox, java.awt.BorderLayout.CENTER);
}
use of javax.swing.DefaultComboBoxModel in project gephi by gephi.
the class UIExporterPDFPanel method setup.
public void setup(PDFExporter pdfExporter) {
DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) pageSizeCombo.getModel();
PageSizeItem pageSize = new PageSizeItem(pdfExporter.getPageSize());
int index = 0;
if ((index = comboBoxModel.getIndexOf(pageSize)) == -1) {
comboBoxModel.setSelectedItem(customSizeString);
} else {
pageSize = (PageSizeItem) comboBoxModel.getElementAt(index);
comboBoxModel.setSelectedItem(pageSize);
}
setPageSize(pageSize);
setMargins(pdfExporter.getMarginTop(), pdfExporter.getMarginBottom(), pdfExporter.getMarginLeft(), pdfExporter.getMarginRight());
setOrientation(pdfExporter.isLandscape());
}
use of javax.swing.DefaultComboBoxModel in project openblocks by mikaelhg.
the class AutoCompletePanel method updateMenu.
/**
* Updates the menu such that it can display
* all the possible blocks that match the user-generated pattern
* (the user-generated pattern is entered within AutoCompletePanel.editor)
*/
private void updateMenu() {
//resize to display entire text in editor
if (this.editor.getPreferredSize().width > preferredWidth) {
this.setSize(this.editor.getPreferredSize().width, preferredHeight);
} else {
this.setSize(preferredWidth, preferredHeight);
}
//get matching blocks
String text = editor.getText().trim();
List<TextualFactoryBlock> matchingBlocks;
// two "+" blocks, otherwise get the blocks matching the input text
try {
Float.valueOf(text);
matchingBlocks = BlockUtilities.getDigits(workspace, text);
} catch (NumberFormatException e) {
if (text.equals(TypeBlockManager.PLUS_OPERATION_LABEL)) {
matchingBlocks = BlockUtilities.getPlusBlocks(workspace, text);
} else {
matchingBlocks = BlockUtilities.getAllMatchingBlocks(workspace, text);
}
}
//update menu and repaint
menu.setModel(new DefaultComboBoxModel(matchingBlocks.toArray()));
this.revalidate();
this.repaint();
}
use of javax.swing.DefaultComboBoxModel in project pcgen by PCGen.
the class NameGenPanel method loadCatalogDD.
//GEN-LAST:event_jButton1ActionPerformed
private void loadCatalogDD() {
try {
String catKey = (String) cbCategory.getSelectedItem();
String sexKey = (String) cbSex.getSelectedItem();
RuleSet oldRS = (RuleSet) cbCatalog.getSelectedItem();
String catalogKey = "";
if (oldRS != null) {
catalogKey = oldRS.getTitle();
}
List<RuleSet> cats = categories.get(catKey);
List<RuleSet> sexes = categories.get("Sex: " + sexKey);
List<RuleSet> join = new ArrayList<>(cats);
join.retainAll(sexes);
join.sort(new DataElementComperator());
Vector<RuleSet> catalogs = new Vector<>();
int oldSelected = -1;
int n = 0;
for (final RuleSet rs : join) {
if (rs.getUsage().equals("final")) {
catalogs.add(rs);
if (rs.getTitle().equals(catalogKey)) {
oldSelected = n;
}
n++;
}
}
ComboBoxModel catalogModel = new DefaultComboBoxModel(catalogs);
cbCatalog.setModel(catalogModel);
if (oldSelected >= 0)
cbCatalog.setSelectedIndex(oldSelected);
} catch (Exception e) {
Logging.errorPrint(e.getMessage(), e);
}
}
use of javax.swing.DefaultComboBoxModel in project pcgen by PCGen.
the class DefaultsPanel method applyOptionValuesToControls.
/**
* @see pcgen.gui2.prefs.PreferencesPanel#initPreferences()
*/
@Override
public void applyOptionValuesToControls() {
final GameMode gameMode = SettingsHandler.getGame();
final String xpTableName = gameMode.getDefaultXPTableName();
List<String> xpTableNames = gameMode.getXPTableNames();
xpTableCombo.removeAllItems();
for (String name : xpTableNames) {
xpTableCombo.addItem(name);
}
xpTableCombo.setSelectedItem(xpTableName);
final String characterType = gameMode.getDefaultCharacterType();
List<String> characterTypes = gameMode.getCharacterTypeList();
characterTypeCombo.removeAllItems();
for (String name : characterTypes) {
characterTypeCombo.addItem(name);
}
characterTypeCombo.setSelectedItem(characterType);
final String previewSheet = UIPropertyContext.getInstance().initProperty(DEFAULT_PREVIEW_SHEET_KEY + gameMode, gameMode.getDefaultPreviewSheet());
String previewDir = ConfigurationSettings.getPreviewDir();
File sheetDir = new File(previewDir, gameMode.getCharSheetDir());
if (sheetDir.exists() && sheetDir.isDirectory()) {
String[] files = sheetDir.list((path, filename) -> {
File file = new File(path, filename);
return file.isFile() && !file.isHidden();
});
//String[] files = sheetDir.list();
previewSheetCombo.removeAllItems();
previewSheetCombo.setModel(new DefaultComboBoxModel(files));
previewSheetCombo.sortItems();
previewSheetCombo.setSelectedItem(previewSheet);
}
}
Aggregations