Search in sources :

Example 11 with DefaultComboBoxModel

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);
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 12 with DefaultComboBoxModel

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());
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 13 with DefaultComboBoxModel

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();
}
Also used : TextualFactoryBlock(edu.mit.blocks.renderable.TextualFactoryBlock) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 14 with DefaultComboBoxModel

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);
    }
}
Also used : DataElementComperator(pcgen.core.doomsdaybook.DataElementComperator) RuleSet(pcgen.core.doomsdaybook.RuleSet) ArrayList(java.util.ArrayList) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Vector(java.util.Vector) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ComboBoxModel(javax.swing.ComboBoxModel) FileNotFoundException(java.io.FileNotFoundException) DataConversionException(org.jdom2.DataConversionException)

Example 15 with DefaultComboBoxModel

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);
    }
}
Also used : GameMode(pcgen.core.GameMode) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) File(java.io.File)

Aggregations

DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)119 JComboBox (javax.swing.JComboBox)22 JPanel (javax.swing.JPanel)21 JLabel (javax.swing.JLabel)17 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 JButton (javax.swing.JButton)15 Insets (java.awt.Insets)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)12 Dimension (java.awt.Dimension)11 JTextField (javax.swing.JTextField)11 JCheckBox (javax.swing.JCheckBox)10 JScrollPane (javax.swing.JScrollPane)10 ArrayList (java.util.ArrayList)9 Vector (java.util.Vector)9 JList (javax.swing.JList)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 BorderLayout (java.awt.BorderLayout)8 ItemEvent (java.awt.event.ItemEvent)8