Example usage for com.jgoodies.binding.adapter ComboBoxAdapter ComboBoxAdapter

List of usage examples for com.jgoodies.binding.adapter ComboBoxAdapter ComboBoxAdapter

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter ComboBoxAdapter ComboBoxAdapter.

Prototype

public ComboBoxAdapter(E[] items, ValueModel selectionHolder) 

Source Link

Document

Constructs a ComboBoxAdapter for the specified List of items and the given selection holder.

Usage

From source file:ambit2.dbui.QueryStoredResultsEditor.java

License:Open Source License

protected JComponent createFieldnameComponent() {
    RowsModel<IStoredQuery> rows = new RowsModel<IStoredQuery>(queries);

    ComboBoxAdapter<IStoredQuery> adapter = new ComboBoxAdapter<IStoredQuery>(rows,
            presentationModel.getModel("fieldname"));
    final JComboBox box = new JComboBox(adapter);

    box.setEditable(true);//from  w w w .  j a v a  2  s .co m
    box.getEditor().getEditorComponent().addKeyListener(new KeyListener() {
        public void keyTyped(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
        }

        public void keyReleased(KeyEvent e) {
            if ((KeyEvent.VK_ENTER == e.getKeyCode()) || (KeyEvent.VK_DOWN == e.getKeyCode()))
                try {
                    searchStoredQuery.setValue(box.getEditor().getItem().toString());
                    queries.setQuery(searchStoredQuery);
                } catch (Exception x) {
                    x.printStackTrace();
                }
        }
    });

    return box;
}

From source file:com.salas.bb.dialogs.AdvancedPreferencesPanel.java

License:Open Source License

private void initComponents(ValueModel triggerChannel) {
    chShowTipsBox = ComponentsFactory.createCheckBox(
            Strings.message("userprefs.tab.general.show.tip.of.the.day"), new ToggleButtonAdapter(
                    new BufferedValueModel(TipOfTheDayDialog.showingTipsModel(), triggerChannel)));

    String msg = Strings.message("userprefs.tab.general.check.for.new.versions");
    if (ApplicationLauncher.isAutoUpdatesEnabled()) {
        chDoUpdatesCheck = ComponentsFactory.createCheckBox(msg,
                new ToggleButtonAdapter(new BufferedValueModel(
                        new PropertyAdapter(userPrefs, UserPreferences.PROP_CHECKING_FOR_UPDATES_ON_STARTUP),
                        triggerChannel)));
    } else {//from  w w  w  .ja v  a2  s .co m
        msg = msg.replaceAll("&", "");
        chDoUpdatesCheck = new JCheckBox(msg);
        chDoUpdatesCheck.setSelected(true);
        chDoUpdatesCheck.setEnabled(false);
    }

    chAlwaysUseEnglish = ComponentsFactory
            .createCheckBox(Strings.message("userprefs.tab.advanced.always.use.english"),
                    new ToggleButtonAdapter(new BufferedValueModel(
                            new PropertyAdapter(userPrefs, UserPreferences.PROP_ALWAYS_USE_ENGLISH),
                            triggerChannel)));

    tfInternetBrowser = new JTextField();
    tfInternetBrowser.setDocument(new DocumentAdapter(new BufferedValueModel(
            new PropertyAdapter(userPrefs, UserPreferences.PROP_INTERNET_BROWSER), triggerChannel)));

    if (BrowserLauncher.isUsingJWSBrowser()) {
        tfInternetBrowser.setEnabled(false);
        tfInternetBrowser.setToolTipText(Strings.message("userprefs.tab.advanced.browser.tooltip.disabled"));
    } else {
        tfInternetBrowser.setEnabled(true);
        tfInternetBrowser.setToolTipText(Strings.message("userprefs.tab.advanced.browser.tooltip.enabled"));
    }

    initProxyComponents(triggerChannel);

    SpinnerModelAdapter spinModelFeedSelectionDelay = new SpinnerModelAdapter(new BoundedRangeAdapter(
            new BufferedValueModel(new PropertyAdapter(userPrefs, UserPreferences.PROP_FEED_SELECTION_DELAY),
                    triggerChannel),
            0, 0, 1000));
    spinModelFeedSelectionDelay.setStepSize(100);

    chAAText = createCheckBox(userPrefs, Strings.message("userprefs.tab.advanced.antialiased.fonts"),
            UserPreferences.PROP_AA_TEXT);

    // The following code registers listener on Apply/Accept actions to track down
    // changes in BlogStarz limits. If changes are detected then channel list is
    // repainted.

    saveInitialLimits();
    triggerChannel.addValueChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (Boolean.TRUE.equals(evt.getNewValue()))
                doRepaintChannelList();
        }
    });

    chShowUnreadButtonMenu = createCheckBox(userPrefs,
            Strings.message("userprefs.tab.advanced.show.the.unread.buttons.menu"),
            UserPreferences.PROP_SHOW_UNREAD_BUTTON_MENU);

    SpinnerModelAdapter spinModelFeedImportLimit = new SpinnerModelAdapter(new BoundedRangeAdapter(
            new BufferedValueModel(new PropertyAdapter(userPrefs, UserPreferences.PROP_FEED_IMPORT_LIMIT),
                    triggerChannel),
            1, 1, UserPreferences.MAX_FEED_IMPORT_LIMITATION));
    spinModelFeedImportLimit.setStepSize(100);
    spinFeedImportLimit = new JSpinner(spinModelFeedImportLimit);

    initGuideComponents(triggerChannel);

    chHideOldArticles = createCheckBox(feedRS,
            Strings.message("userprefs.tab.articles.hide.articles.older.than"), "suppressingOlderThan");
    chDisplayFullTitles = createCheckBox(feedRS, Strings.message("userprefs.tab.articles.display.full.titles"),
            "displayingFullTitles");
    chSortingAscending = createCheckBox(feedRS,
            Strings.message("userprefs.tab.articles.sort.earlier.articles.first"), "sortingAscending");

    tfSuppressOlderThan = new JTextField();
    tfSuppressOlderThan.setDocument(new DocumentAdapter(
            new BufferedValueModel(new PropertyAdapter(feedRS, "suppressOlderThanString"), triggerChannel)));

    chCopyLinksInHREFFormat = createCheckBox(userPrefs,
            Strings.message("userprefs.tab.articles.use.href.format.for.links.copied.to.clipboard"),
            UserPreferences.PROP_COPY_LINKS_IN_HREF_FORMAT);
    chBrowseOnTitleDblClick = createCheckBox(userPrefs,
            Strings.message("userprefs.tab.articles.browse.on.double.click.over.the.title"),
            UserPreferences.PROP_BROWSE_ON_DBL_CLICK);

    chShowAppIconInSystray = createCheckBox(userPrefs,
            Strings.message("userprefs.tab.advanced.show.appicon.in.systray"),
            UserPreferences.PROP_SHOW_APPICON_IN_SYSTRAY);
    chMinimizeToSystray = createCheckBox(userPrefs,
            Strings.message("userprefs.tab.advanced.minimize.to.systray"),
            UserPreferences.PROP_MINIMIZE_TO_SYSTRAY);

    // Dock icon
    ValueModel modeModel = new BufferedValueModel(
            new BIDModeToStringConverter(new PropertyAdapter(userPrefs, UserPreferences.PROP_DIB_MODE)),
            triggerChannel);

    cbBIDMode = new JComboBox(new ComboBoxAdapter(BIDModeToStringConverter.MODES, modeModel));
}

From source file:com.salas.bb.remixfeeds.editor.PostEditor.java

License:Open Source License

/**
 * Sets the target blog./*from w  ww . ja v a  2 s.  c om*/
 *
 * @param targetBlog   the target blog.
 */
public void setTargetBlog(TargetBlog targetBlog) {
    this.targetBlog = targetBlog;

    // Initialize the arrays
    cbCategories = new JComboBox();
    categories = new ArrayListModel();
    category = targetBlog.getDefaultCategory();

    initCategories(targetBlog, targetBlog.getDefaultCategory());
    PropertyAdapter adapter = new PropertyAdapter(this, "category", true);
    cbCategories = new JComboBox(new ComboBoxAdapter((ListModel) categories, adapter));
    setDraft(targetBlog.isDraft());

    updateTitle(new TargetBlog[] { targetBlog });
}

From source file:com.salas.bb.remixfeeds.prefs.BlogDetailsPreferencesPanel.java

License:Open Source License

/**
 * Binds components to the properties of the preferences proxy.
 *
 * @param parent parent dialog.//from ww w . j av a 2s  .c  om
 */
private void initComponents(JDialog parent) {
    vmURL = new BufferedValueModel(new PropertyAdapter(proxy, TargetBlog.PROP_API_URL, true), trigger);
    vmUser = new BufferedValueModel(new PropertyAdapter(proxy, TargetBlog.PROP_USER, true), trigger);
    vmPass = new BufferedValueModel(new PropertyAdapter(proxy, TargetBlog.PROP_PASSWORD, true), trigger);

    tfTitle.setDocument(new DocumentAdapter(new PropertyAdapter(proxy, TargetBlog.PROP_TITLE, true)));
    tfURL.setDocument(new DocumentAdapter(vmURL));
    tfURLSummary.setDocument(new DocumentAdapter(
            new URLSummaryConverter(new PropertyAdapter(proxy, TargetBlog.PROP_API_URL, true))));
    tfURLSummary.setEditable(false);
    tfUser.setDocument(new DocumentAdapter(vmUser));
    tfPassword.setDocument(new DocumentAdapter(vmPass));

    taDescription = ComponentsFactory.createInstructionsArea("");

    loadCategoriesLookup();

    ValueModel mdlDefaultCategory = new PropertyAdapter(proxy, TargetBlog.PROP_DEFAULT_CATEGORY, true);
    ComboBoxAdapter adapter = new ComboBoxAdapter((ListModel) lmdlCategories, mdlDefaultCategory);
    cbDefaultCategory = new JComboBox(adapter);

    ValueModel mdlBlog = new PropertyAdapter(proxy, TargetBlog.PROP_BLOG, true);
    adapter = new ComboBoxAdapter((ListModel) lmdlBlogs, mdlBlog);
    cbBlog = new JComboBox(adapter);

    ValueModel mdlDraft = new PropertyAdapter(proxy, TargetBlog.PROP_DRAFT, true);
    rbPublic.setModel(new RadioButtonAdapter(mdlDraft, Boolean.FALSE));
    rbDraft.setModel(new RadioButtonAdapter(mdlDraft, Boolean.TRUE));

    Collection apis = WeblogAPIs.getWeblogAPIs();
    ValueModel mdlAPIs = new PropertyAdapter(proxy, TargetBlog.PROP_API_TYPE, true);
    vmAPI = new BufferedValueModel(mdlAPIs, trigger);
    adapter = new ComboBoxAdapter(apis.toArray(), vmAPI);
    cbWeblogAPIType = new JComboBox(adapter);
    vmAPI.addPropertyChangeListener(new WeblogTypeChangeListener());

    btnSetup = new JButton(new SetupAction(parent));
    btnFetchCategories = new JButton();
    actFetchCategories = new FetchCategoriesAction(); // It uses btnFetchCategories (hence the order)
    btnFetchCategories.setAction(actFetchCategories);
    btnFetchBlogs = new JButton();
    actFetchBlogs = new FetchBlogsAction(); // It uses btnFetchBlogs (hence the order)
    btnFetchBlogs.setAction(actFetchBlogs);

    // Templates
    Set<String> templateNames = Templates.getUserTemplates().keySet();
    lmTemplateNames = new ArrayListModel(templateNames);

    ValueModel mdlTemplates = new PropertyAdapter(proxy, TargetBlog.PROP_TEMPLATE_NAME, true);
    cbTemplate = new JComboBox(new ComboBoxAdapter((ListModel) lmTemplateNames, mdlTemplates));
    btnTemplateEditor = new JButton(new TemplateEditorAction());

    proxy.addPropertyChangeListener(TargetBlogProxy.PROP_BLOG_PREFERENCES, this);
    updateViewState();
}

From source file:com.salas.bb.whatshot.Dialog.java

License:Open Source License

/**
 * Creates search dialog./* w  w w  .  ja  va2  s . c o  m*/
 *
 * @param owner     dialog's parent frame.
 * @param engine    engine to use.
 * @param set       guides set to pick the guides from.
 * @param listener  selection listener.
 */
public Dialog(Frame owner, Engine engine, final GuidesSet set, ActionListener listener) {
    super(owner, Strings.message("whatshot.dialog.title"));
    guidesSet = set;

    pnlProgress = new ProgressPanel(Strings.message("whatshot.inprogress"));
    scrollPanel = buildResultsPanel();

    setModal(false);

    // Only unread selector
    Preferences prefs = Application.getUserPreferences();
    ValueModel mdlOnlyUnread = new PreferencesAdapter(prefs, PROP_WH_UNREAD_ONLY, false);
    chOnlyUnread = ComponentsFactory.createCheckBox(Strings.message("whatshot.unreadonly"),
            new ToggleButtonAdapter(mdlOnlyUnread));

    // Time options
    ValueModel mdlTimeOption = new AbstractConverter(
            new PreferencesAdapter(prefs, PROP_WH_TIME_OPTION, TimeOption.THIS_WEEK.getCode())) {
        public Object convertFromSubject(Object o) {
            return TimeOption.fromCode((Integer) o);
        }

        public void setValue(Object o) {
            TimeOption to = (TimeOption) o;
            subject.setValue(to.getCode());
        }
    };
    cbTimeOptions = new JComboBox(new ComboBoxAdapter(TimeOption.OPTIONS, mdlTimeOption));

    // Starz selector
    ValueModel mdlStarz = new PreferencesAdapter(prefs, PROP_WH_STARZ, 1);
    starz = new StarsSelectionComponent(new BoundedRangeAdapter(mdlStarz, 0, 1, 5));

    // Make toolbar fonts smaller
    UifUtilities.smallerFont(chOnlyUnread);
    UifUtilities.smallerFont(cbTimeOptions);

    // Setup button
    btnSetup = new JButton(Strings.message("whatshot.setup"));
    btnSetup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            SetupDialog sd = new SetupDialog(GlobalModel.SINGLETON.getUserPreferences());
            sd.open();
        }
    });

    UifUtilities.smallerFont(btnSetup);

    // Results model and list
    model = new ListModel(engine, mdlStarz, mdlOnlyUnread, mdlTimeOption);
    onSetupChange();

    itemsList = new ResultsList(model) {
        @Override
        protected ResultGroupPanel createGroupPanel(ResultGroup group) {
            return new ResultGroupPanel(group.getName(), group.getName(), GROUP_COLOR_1, GROUP_COLOR_2);
        }
    };
    itemsList.addActionListener(listener);

    // Start populating
    SwingWorker scanner = model.scan();
    scanner.addPropertyChangeListener(new ScannerListener());
    scanner.execute();
}

From source file:com.starillon.ibtradetools.ui.spreadcalc.SpreadStrategySelector.java

private void initModels() {
    //---- monthList ----
    monthList.setModel(new DefaultComboBoxModel(ContractMonth.MONTH_LIST));
    int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    List<Integer> years = Lists.newArrayList();
    for (int i = 0; i < 10; ++i) {
        years.add(currentYear + i);/*from   www  .ja va  2s  . co  m*/
    }
    yearList.setModel(new DefaultComboBoxModel(years.toArray()));

    ValueModel selectionHolder = new ValueHolder("Select Strategy");
    List<SpreadStrategy> strategies = Lists.newArrayList();
    strategies.add(SpreadStrategy.BEAR_PUT_SPREAD);
    strategies.add(SpreadStrategy.BULL_PUT_SPREAD);
    strategies.add(SpreadStrategy.BEAR_CALL_SPREAD);
    strategies.add(SpreadStrategy.BULL_CALL_SPREAD);

    strategyList.setModel(new ComboBoxAdapter(strategies, selectionHolder));
}

From source file:de.comicdb.comicdbcore.bean.ComicTopComponent.java

License:Open Source License

/** This method is called from within the constructor to
 * initialize the form.//from  w w  w  .jav  a  2  s .  co m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    popupMenu = new javax.swing.JPopupMenu();
    jLabelName = new javax.swing.JLabel();
    jTextFieldName = BasicComponentFactory.createTextField(adapter.getBufferedModel("name"));
    jLabelNr = new javax.swing.JLabel();
    jLabelComicType = new javax.swing.JLabel();
    jComboBoxComicType = new javax.swing.JComboBox();
    jLabelCoverPrice = new javax.swing.JLabel();
    jTextFieldCoverPrice = BasicComponentFactory
            .createFormattedTextField(adapter.getBufferedModel("coverprice"), new DecimalFormat("##0.00"));
    jLabelPrice = new javax.swing.JLabel();
    jTextFieldPrice = BasicComponentFactory.createFormattedTextField(adapter.getBufferedModel("price"),
            new DecimalFormat("##0.00"));
    jLabelCoverDate = new javax.swing.JLabel();
    jTextFieldCoverDate = BasicComponentFactory.createFormattedTextField(adapter.getBufferedModel("coverdate"),
            new SimpleDateFormat(java.util.ResourceBundle.getBundle("de/comicdb/comicdbcore/bean/Bundle")
                    .getString("format.date")));
    jLabelQuantity = new javax.swing.JLabel();
    jButtonCoverDate = new javax.swing.JButton();
    jLabelCost = new javax.swing.JLabel();
    jTextFieldCost = BasicComponentFactory.createFormattedTextField(adapter.getBufferedModel("cost"),
            new DecimalFormat("##0.00"));
    jLabelPayDate = new javax.swing.JLabel();
    jTextFieldPayDate = BasicComponentFactory.createFormattedTextField(adapter.getBufferedModel("paydate"),
            new SimpleDateFormat(java.util.ResourceBundle.getBundle("de/comicdb/comicdbcore/bean/Bundle")
                    .getString("format.date")));
    jButtonPayDate = new javax.swing.JButton();
    jLabelModified = new javax.swing.JLabel();
    jTextFieldModified = BasicComponentFactory.createFormattedTextField(adapter.getBufferedModel("modified"),
            new SimpleDateFormat(java.util.ResourceBundle.getBundle("de/comicdb/comicdbcore/bean/Bundle")
                    .getString("format.date")));
    jPanel2 = new javax.swing.JPanel();
    jLabelCondition = new javax.swing.JLabel();
    jPanelNotes = new javax.swing.JPanel();
    jScrollPaneNotes = new javax.swing.JScrollPane();
    jTextAreaNotes = BasicComponentFactory.createTextArea(adapter.getBufferedModel("notes"));
    jPanelStories = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTableStorys = new javax.swing.JTable();
    jTextFieldNr = BasicComponentFactory.createIntegerField(adapter.getBufferedModel("nr"));
    jTextFieldCondition = jTextFieldCondition = BasicComponentFactory
            .createIntegerField(adapter.getBufferedModel("condition"));
    jTextFieldQuantity = BasicComponentFactory.createIntegerField(adapter.getBufferedModel("quantity"));
    jLabelPageCount = new javax.swing.JLabel();
    jTextFieldPageCount = BasicComponentFactory.createIntegerField(adapter.getBufferedModel("pagecount"));
    jLabelCoverType = new javax.swing.JLabel();
    jComboBoxCoverType = new javax.swing.JComboBox();
    jLabelState = new javax.swing.JLabel();
    jComboBoxState = new javax.swing.JComboBox();
    jScrollPane2 = new javax.swing.JScrollPane();
    jPanelImage = new ImagePanel();
    jPanel1 = new javax.swing.JPanel();
    jButtonAccept = new javax.swing.JButton();
    jButtonCancel = new javax.swing.JButton();
    jPanel3 = new javax.swing.JPanel();
    jButtonChooseImage = new javax.swing.JButton();
    jButtonDeleteImage = new javax.swing.JButton();

    setLayout(new java.awt.GridBagLayout());

    org.openide.awt.Mnemonics.setLocalizedText(jLabelName, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_NAME"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
    add(jLabelName, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
    add(jTextFieldName, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelNr,
            java.util.ResourceBundle.getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_NR"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelNr, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelComicType, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_TYPE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelComicType, gridBagConstraints);

    jComboBoxComicType.setModel(new ComboBoxAdapter(comicTypes, adapter.getBufferedModel("comictype")));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jComboBoxComicType, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelCoverPrice, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_COVER_PRICE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelCoverPrice, gridBagConstraints);

    jTextFieldCoverPrice.setColumns(10);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldCoverPrice, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelPrice, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_PRICE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelPrice, gridBagConstraints);

    jTextFieldPrice.setColumns(10);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldPrice, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelCoverDate, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_COVER_DATE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelCoverDate, gridBagConstraints);

    jTextFieldCoverDate.setColumns(10);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldCoverDate, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelQuantity, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_QUANTITY"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelQuantity, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jButtonCoverDate, "...");
    jButtonCoverDate.setEnabled(false);
    jButtonCoverDate.setMaximumSize(new java.awt.Dimension(18, 18));
    jButtonCoverDate.setMinimumSize(new java.awt.Dimension(18, 18));
    jButtonCoverDate.setPreferredSize(new java.awt.Dimension(18, 18));
    jButtonCoverDate.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonCoverDateActionPerformed(evt);
        }
    });

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 4);
    add(jButtonCoverDate, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelCost, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_COST"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelCost, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldCost, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelPayDate, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_PAYDATE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelPayDate, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldPayDate, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jButtonPayDate, "...");
    jButtonPayDate.setEnabled(false);
    jButtonPayDate.setMaximumSize(new java.awt.Dimension(18, 18));
    jButtonPayDate.setMinimumSize(new java.awt.Dimension(18, 18));
    jButtonPayDate.setPreferredSize(new java.awt.Dimension(18, 18));
    jButtonPayDate.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonPayDateActionPerformed(evt);
        }
    });

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 4);
    add(jButtonPayDate, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelModified,
            java.util.ResourceBundle.getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_MODIFIED"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 11;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelModified, gridBagConstraints);

    jTextFieldModified.setEditable(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 11;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 0.5;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldModified, gridBagConstraints);

    org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 832, Short.MAX_VALUE));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 28, Short.MAX_VALUE));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 10;
    gridBagConstraints.gridwidth = 6;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(jPanel2, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelCondition, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_CONDITION"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelCondition, gridBagConstraints);

    jPanelNotes.setLayout(new java.awt.BorderLayout());

    jPanelNotes.setBorder(javax.swing.BorderFactory.createTitledBorder(java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_NOTES")));
    jTextAreaNotes.setColumns(20);
    jTextAreaNotes.setRows(5);
    jScrollPaneNotes.setViewportView(jTextAreaNotes);

    jPanelNotes.add(jScrollPaneNotes, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 9;
    gridBagConstraints.gridwidth = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
    add(jPanelNotes, gridBagConstraints);

    jPanelStories.setLayout(new java.awt.BorderLayout());

    jPanelStories.setBorder(javax.swing.BorderFactory.createTitledBorder(java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_STORIES")));
    jScrollPane1.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            jScrollPane1MousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            jScrollPane1MouseReleased(evt);
        }
    });

    jTableStorys.setModel(new StoryTableModel(new SelectionInList(adapter.getBufferedModel("storys"))));
    jTableStorys.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            jTableStorysMousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            jTableStorysMouseReleased(evt);
        }
    });

    jScrollPane1.setViewportView(jTableStorys);

    jPanelStories.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.gridwidth = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
    add(jPanelStories, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldNr, gridBagConstraints);

    jTextFieldCondition.setColumns(4);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 0.5;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldCondition, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldQuantity, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelPageCount, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_PAGECOUNT"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelPageCount, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jTextFieldPageCount, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelCoverType, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_COVERTYPE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelCoverType, gridBagConstraints);

    jComboBoxCoverType.setModel(new ComboBoxAdapter(coverTypes, adapter.getBufferedModel("covertype")));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jComboBoxCoverType, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jLabelState, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("LBL_COMIC_STATE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
    add(jLabelState, gridBagConstraints);

    jComboBoxState.setModel(new ComboBoxAdapter(State.getStates(), adapter.getBufferedModel("state")));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
    add(jComboBoxState, gridBagConstraints);

    org.jdesktop.layout.GroupLayout jPanelImageLayout = new org.jdesktop.layout.GroupLayout(jPanelImage);
    jPanelImage.setLayout(jPanelImageLayout);
    jPanelImageLayout.setHorizontalGroup(jPanelImageLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 372, Short.MAX_VALUE));
    jPanelImageLayout.setVerticalGroup(jPanelImageLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 333, Short.MAX_VALUE));
    jScrollPane2.setViewportView(jPanelImage);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 9;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.25;
    gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 4);
    add(jScrollPane2, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jButtonAccept, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("button.accept"));
    jButtonAccept.setEnabled(false);
    jButtonAccept.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonAcceptActionPerformed(evt);
        }
    });

    jPanel1.add(jButtonAccept);

    org.openide.awt.Mnemonics.setLocalizedText(jButtonCancel, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("button.cancel"));
    jButtonCancel.setEnabled(false);
    jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonCancelActionPerformed(evt);
        }
    });

    jPanel1.add(jButtonCancel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 11;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    add(jPanel1, gridBagConstraints);

    org.openide.awt.Mnemonics.setLocalizedText(jButtonChooseImage, java.util.ResourceBundle
            .getBundle("de/comicdb/comicdbcore/bean/Bundle").getString("button.choose"));
    jButtonChooseImage.setEnabled(false);
    jButtonChooseImage.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonChooseImageActionPerformed(evt);
        }
    });

    jPanel3.add(jButtonChooseImage);

    org.openide.awt.Mnemonics.setLocalizedText(jButtonDeleteImage,
            java.util.ResourceBundle.getBundle("de/comicdb/comicdbcore/Bundle").getString("BTN_DELETE"));
    jButtonDeleteImage.setEnabled(false);
    jButtonDeleteImage.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonDeleteImageActionPerformed(evt);
        }
    });

    jPanel3.add(jButtonDeleteImage);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 9;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 4);
    add(jPanel3, gridBagConstraints);

}

From source file:fi.smaa.jsmaa.gui.RankSelectorGroup.java

License:Open Source License

@SuppressWarnings("serial")
private JComboBox createComboBox(Rank r) {
    ValueModel valueModel = new PropertyAdapter<Rank>(r, Rank.PROPERTY_RANK, true);
    JComboBox chooser = new JComboBox(new ComboBoxAdapter<Rank>(listModel, valueModel));
    chooser.setToolTipText("Rank in descending order, 1 is the best/most important, 2 the second, etc.");

    chooser.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            comboBoxSelected((JComboBox) e.getSource());
        }//from  w w w . j av  a  2  s .  c  o m
    });
    return chooser;
}

From source file:org.archiviststoolkit.model.ModelUtil.java

License:Open Source License

public static void bindModelToView(ArrayList fieldsToBind, DomainObject model) {

    BeanAdapter adapter = new BeanAdapter(model, true);
    ValueModel valueModel = null;/*from   w ww.  jav a2  s .c  o  m*/
    Object field = null;
    ATFieldInfo fieldInfo;
    String fieldName = "";
    ComboBoxAdapter comboBoxAdapter = null;

    for (int i = 0; i < fieldsToBind.size(); i++) {
        field = fieldsToBind.get(i);
        fieldName = ((JComponent) field).getName();
        valueModel = adapter.getValueModel(fieldName);
        if (!ignoreArray.contains(fieldName)) {
            if (field instanceof JFormattedTextField) {
                Bindings.bind((JFormattedTextField) field, valueModel);
            } else if (field instanceof JTextComponent) {
                //                  Bindings.bind((JTextComponent) field, valueModel);
            } else if (field instanceof JCheckBox) {
                Bindings.bind((JCheckBox) field, valueModel);
            } else if (field instanceof JComboBox) {
                fieldInfo = ATFieldInfo.getFieldInfo(model.getClass().getName() + "." + fieldName);
                if (fieldInfo != null) {
                    Vector<String> values = LookupListUtils.getLookupListValues(fieldInfo.getLookupList());
                    if (values != null) {
                        comboBoxAdapter = new ComboBoxAdapter(values, valueModel);
                        ((JComboBox) field).setModel(comboBoxAdapter);
                    }
                }
            } else {
                System.out.println(fieldName + " not bound");
            }
        }
    }

}

From source file:org.surveyforge.runner.Frame.java

License:Open Source License

private JComponent createDataEntryComponent(QuestionnaireElement element) {
    if (element.getRegisterDataElement().getComponentElements().isEmpty()) {
        // Simple question
        String propertyName = Frame.computePropertyName(element.getRegisterDataElement());
        ValueDomain valueDomain = element.getRegisterDataElement().getValueDomain();
        if (valueDomain instanceof QuantityValueDomain) {
            QuantityValueDomain quantityValueDomain = (QuantityValueDomain) valueDomain;
            // JTextField field = new JTextField( quantityValueDomain.getPrecision( ) );
            JFormattedTextField field = BasicComponentFactory
                    .createIntegerField(this.getDataModel().getModel(propertyName));
            field.setColumns(quantityValueDomain.getPrecision());
            field.addFocusListener(this.controller.getSelectionController());
            field.setInputVerifier(this.controller.getValidationController());

            this.elementToComponentMap.put(element, field);
            this.componentToElementMap.put(field, element);
            return field;
        } else if (valueDomain instanceof ClassificationValueDomain) {
            final ClassificationValueDomain classificationValueDomain = (ClassificationValueDomain) valueDomain;
            JPanel classificationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            // JComboBox classificationCombo = new JComboBox( classificationValueDomain.getLevel( ).getItems( ).toArray( ) );
            JComboBox classificationCombo = new JComboBox(
                    new ComboBoxAdapter(classificationValueDomain.getLevel().getItems(),
                            new Frame.ClassificationConverter(classificationValueDomain.getLevel(),
                                    this.dataModel.getModel(propertyName))));

            // JTextField classificationCode = new JTextField( 5 );
            JTextField classificationCode = BasicComponentFactory
                    .createTextField(this.dataModel.getModel(propertyName));
            classificationCode.setColumns(5);

            classificationCode.addFocusListener(this.controller.getSelectionController());
            classificationCode.setInputVerifier(this.controller.getValidationController());

            classificationPanel.add(classificationCombo);
            classificationPanel.add(classificationCode);
            this.elementToComponentMap.put(element, classificationPanel);
            this.componentToElementMap.put(classificationCode, element);
            return classificationPanel;
        } else {/* ww w.ja  v a2  s  . c  o  m*/
            // TODO: Throw an exception?
            return new JTextField("TODO", 10);
        }
    } else {
        // Compuond question
        return new JTextField("TODO", 10);
    }
}