Example usage for com.jgoodies.binding.adapter BasicComponentFactory createIntegerField

List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createIntegerField

Introduction

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

Prototype

public static JFormattedTextField createIntegerField(ValueModel valueModel) 

Source Link

Document

Creates and returns a formatted text field that is bound to the Integer value of the given ValueModel.

Usage

From source file:ambit2.db.results.test.AmbitRowsEventTest.java

License:Open Source License

public static void main(String[] args) {
    // http://www.java2s.com/Code/Java/Swing-Components/JGoodiesBindingSelectionInListModelExample.htm
    try {//  w w w .  j  av a2 s. c  o  m
        final AmbitRows<Dictionary> dictionary = new AmbitRows<Dictionary>() {
            /**
             * 
             */
            private static final long serialVersionUID = 6274513733204291475L;

            @Override
            protected synchronized IQueryRetrieval createNewQuery(Dictionary target) throws AmbitException {
                TemplateQuery q = new TemplateQuery();
                q.setValue(target.getTemplate());
                return q;
            }
        };

        final AmbitRows<Property> properties = new AmbitRows<Property>() {
            @Override
            protected synchronized IQueryRetrieval createNewQuery(Property target) throws AmbitException {
                QueryField q = new QueryField();
                q.setFieldname(target);
                return q;
            }

        };
        dictionary.addPropertyChangeListener(dictionary.getPropertyname(), properties);
        dictionary.addPropertyChangeListener("status", properties);

        AmbitRowsEventTest test = new AmbitRowsEventTest();
        test.setUpDatabase(test.getTestDatabase());
        IDatabaseConnection c = test.getConnection("localhost", "ambit2", "3306", "guest", "guest");
        dictionary.setConnection(c.getConnection());
        properties.setConnection(c.getConnection());

        DictionaryObjectQuery q = new DictionaryObjectQuery();
        q.setValue("Dataset");

        PropertyChangeSupport ps = new PropertyChangeSupport(test);
        ps.addPropertyChangeListener("topquery", dictionary);
        ps.firePropertyChange(new QueryChangeEvent(test, "topquery", null, q));

        final QueryField qf = new QueryField();
        properties.addPropertyChangeListener(properties.getPropertyname(), new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {

                try {
                    IQueryRetrieval r = properties.process((Property) evt.getNewValue());
                    qf.setFieldname(((QueryField) r).getFieldname());
                } catch (AmbitException x) {
                    x.printStackTrace();
                }
            }
        });

        ListModel listModel = new RowsModel<Dictionary>(dictionary);
        ValueModel selectedItemHolder1 = new ValueHolder();
        SelectionInList<Dictionary> selectionInList = new SelectionInList<Dictionary>(listModel,
                selectedItemHolder1);

        final JList jlist = new JList();
        Bindings.bind(jlist, selectionInList);

        BeanAdapter beanAdapter = new BeanAdapter(selectionInList);
        ValueModel nameModel = beanAdapter.getValueModel("template");
        ValueModel parentModel = beanAdapter.getValueModel("parentTemplate");

        ListModel listModel2 = new RowsModel<Property>(properties);
        ValueModel selectedItemHolder2 = new ValueHolder();
        SelectionInList<Property> selectionInList2 = new SelectionInList<Property>(listModel2,
                selectedItemHolder2);

        BeanAdapter beanAdapter2 = new BeanAdapter(qf);
        ValueModel fieldnameModel = beanAdapter2.getValueModel("fieldname");
        // ValueModel conditionModel =
        // beanAdapter2.getValueModel("condition");
        ValueModel valueModel = beanAdapter2.getValueModel("value");

        selectionInList.addPropertyChangeListener("value", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                try {
                    dictionary.process((Dictionary) evt.getNewValue());
                } catch (Exception x) {
                    x.printStackTrace();
                }

            }
        });

        selectionInList2.addPropertyChangeListener("value", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                try {

                } catch (Exception x) {
                    x.printStackTrace();
                }

            }
        });
        JPanel p = new JPanel();

        p.add(BasicComponentFactory.createTextField(nameModel));
        p.add(BasicComponentFactory.createTextField(parentModel));

        p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
        p.add(new JLabel("Dictionary"));
        p.add(new JScrollPane(jlist));
        // p.add(new JComboBox(new
        // ComboBoxAdapter<Dictionary>(selectionInList)));
        p.add(new JLabel("Properties"));
        final JComboBox combo = new JComboBox(new ComboBoxAdapter<Property>(selectionInList2));
        p.add(combo);
        p.add(BasicComponentFactory.createTextField(fieldnameModel));
        // p.add(BasicComponentFactory.createTextField(conditionModel));
        p.add(BasicComponentFactory.createIntegerField(valueModel));

        properties.addPropertyChangeListener("status", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                combo.setEnabled((Boolean) evt.getNewValue());
            }
        });
        JOptionPane.showMessageDialog(null, p);
        c.close();

    } catch (Exception x) {
        x.printStackTrace();
    }
}

From source file:ambit2.ui.table.PageNavigator.java

License:Open Source License

public JComponent buildPanel(final IPageNavigator pageable) {
    FormLayout layout = new FormLayout(
            "pref, 1dlu,pref,1dlu, fill:25dlu:grow,1dlu,pref, 1dlu,fill:25dlu:grow,1dlu,pref, 1dlu,pref, 1dlu,fill:25dlu:grow",
            "pref");

    PresentationModel<IPageNavigator> presentationModel = new PresentationModel<IPageNavigator>(pageable);

    label = new JLabel("Page");
    currentPage = BasicComponentFactory
            .createIntegerField(presentationModel.getModel(IPageNavigator.PROPERTY_PAGE));
    currentPage.setToolTipText("Current page");

    allPages = BasicComponentFactory/*from   ww  w  . java2 s  .c o m*/
            .createIntegerField(presentationModel.getModel(IPageNavigator.PROPERTY_MAXPAGES));
    allPages.setToolTipText("All pages");
    allPages.setEditable(false);

    pageSize = BasicComponentFactory
            .createIntegerField(presentationModel.getModel(IPageNavigator.PROPERTY_PAGESIZE));
    pageSize.setToolTipText("Records per page");

    prevPage = new JButton(new AbstractAmbitAction("<", "images/resultset_previous.png", "Previous page") {
        public void actionPerformed(ActionEvent e) {
            pageable.previousPage();
        }
    });
    nextPage = new JButton(new AbstractAmbitAction("<", "images/resultset_next.png", "Next page") {
        public void actionPerformed(ActionEvent e) {
            pageable.nextPage();
        }
    });
    PanelBuilder panel = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();
    //"pref, 1dlu,pref,1dlu,fill:25dlu:grow,1dlu,pref, 1dlu,fill:25dlu:grow, 1dlu,pref, 1dlu,fill:25dlu:grow",        
    panel.add(label, cc.xy(1, 1));
    panel.add(prevPage, cc.xy(3, 1));
    panel.add(currentPage, cc.xy(5, 1));
    panel.add(new JLabel("/"), cc.xy(7, 1));
    panel.add(allPages, cc.xy(9, 1));
    panel.add(nextPage, cc.xy(11, 1));
    panel.add(pageSize, cc.xy(13, 1));

    return panel.getPanel();
}

From source file:ambit2.ui.table.RecordNavigator.java

License:Open Source License

public JComponent buildPanel(final IRecordNavigator navigator) {
    FormLayout layout = new FormLayout(
            "pref, 1dlu,pref,1dlu,fill:25dlu:grow,1dlu,pref,1dlu,fill:25dlu:grow,1dlu,pref", "pref");

    PresentationModel<IRecordNavigator> presentationModel = new PresentationModel<IRecordNavigator>(navigator);

    label = new JLabel("Record");
    currentPage = BasicComponentFactory
            .createIntegerField(presentationModel.getModel(IRecordNavigator.PROPERTY_RECORD));
    currentPage.setToolTipText("Current record");
    allPages = BasicComponentFactory//from   w w w  .  j av  a2s  .  c om
            .createIntegerField(presentationModel.getModel(IRecordNavigator.PROPERTY_MAXRECORDS));
    allPages.setToolTipText("All pages");
    allPages.setEditable(false);
    prevPage = new JButton(new AbstractAmbitAction("<", "images/resultset_previous.png", "Previous record") {
        public void actionPerformed(ActionEvent e) {
            navigator.prev();
        }
    });
    nextPage = new JButton(new AbstractAmbitAction(">", "images/resultset_next.png", "Next record") {
        public void actionPerformed(ActionEvent e) {
            navigator.next();
        }
    });
    PanelBuilder panel = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();
    panel.add(label, cc.xy(1, 1));
    panel.add(prevPage, cc.xy(3, 1));
    panel.add(currentPage, cc.xy(5, 1));
    panel.add(new JLabel("/"), cc.xy(7, 1));
    panel.add(allPages, cc.xy(9, 1));
    panel.add(nextPage, cc.xy(11, 1));

    return panel.getPanel();
}

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 .j a  va  2 s  . c  o  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: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.j a v  a 2s.c  om*/
            // TODO: Throw an exception?
            return new JTextField("TODO", 10);
        }
    } else {
        // Compuond question
        return new JTextField("TODO", 10);
    }
}

From source file:salomon.engine.util.validation.ComponentFactory.java

License:Open Source License

/**
 * @see salomon.engine.util.validation.IComponentFactoryEx#createIntegerField(java.lang.String)
 *//*from   www . j a  v  a 2s.  c  o  m*/
public JFormattedTextField createIntegerField(String propertyName) {
    return BasicComponentFactory.createIntegerField(_validationModel.getModel(propertyName));
}