Example usage for javax.swing JComboBox JComboBox

List of usage examples for javax.swing JComboBox JComboBox

Introduction

In this page you can find the example usage for javax.swing JComboBox JComboBox.

Prototype

public JComboBox() 

Source Link

Document

Creates a JComboBox with a default data model.

Usage

From source file:org.jfree.demo.DrawStringDemo.java

/**
 * Creates the content for tab 1./*from  w ww. java2  s.  c o  m*/
 *
 * @return The content panel.
 */
private JPanel createTab1Content() {
    final JPanel content = new JPanel(new BorderLayout());
    this.combo1 = new JComboBox();
    this.combo1.setActionCommand("combo1.changed");
    populateTextAnchorCombo(this.combo1);
    this.combo1.addActionListener(this);

    final JPanel controls = new JPanel();
    controls.add(this.combo1);

    final JButton fontButton = new JButton("Select Font...");
    fontButton.setActionCommand("fontButton.clicked");
    fontButton.addActionListener(this);
    controls.add(fontButton);
    content.add(controls, BorderLayout.NORTH);
    this.drawStringPanel1 = new DrawStringPanel("0123456789", false);
    content.add(this.drawStringPanel1);
    return content;
}

From source file:edu.harvard.mcz.imagecapture.SpecimenPartAttribEditDialog.java

private void init() {
    setTitle("Edit Part Attribute");
    setBounds(100, 100, 420, 200);//from   w w  w.j  a  va2s.  co  m
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            okButton = new JButton("OK");
            okButton.setActionCommand("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    okButton.grabFocus();
                    if (comboBoxType.getSelectedIndex() > -1) {
                        targetAttribute.setAttributeType(comboBoxType.getSelectedItem().toString());
                    }
                    targetAttribute.setAttributeValue(comboBoxValue.getSelectedItem().toString());

                    targetAttribute.setAttributeUnits(textFieldUnits.getText());
                    targetAttribute.setAttributeRemark(textFieldRemarks.getText());

                    thisDialog.setVisible(false);
                }
            });
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.setActionCommand("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    thisDialog.setVisible(false);
                }
            });
            buttonPane.add(cancelButton);
        }
    }
    {
        JPanel panel = new JPanel();
        getContentPane().add(panel, BorderLayout.CENTER);
        panel.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));
        {
            JLabel lblAttributeType = new JLabel("Attribute Type");
            panel.add(lblAttributeType, "2, 2, right, default");
        }
        {
            comboBoxType = new JComboBox();
            comboBoxType.setModel(
                    new DefaultComboBoxModel(new String[] { "caste", "scientific name", "sex", "life stage" }));
            comboBoxType.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String item = comboBoxType.getSelectedItem().toString();
                    if (item != null) {
                        configureComboBoxValue(item);
                    }
                }

            });
            panel.add(comboBoxType, "4, 2, fill, default");
        }
        {
            JLabel lblValue = new JLabel("Value");
            panel.add(lblValue, "2, 4, right, default");
        }
        {
            comboBoxValue = new JComboBox();
            comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues()));

            panel.add(comboBoxValue, "4, 4, fill, default");
        }
        {
            JLabel lblUnits = new JLabel("Units");
            panel.add(lblUnits, "2, 6, right, default");
        }
        {
            textFieldUnits = new JTextField();
            panel.add(textFieldUnits, "4, 6, fill, default");
            textFieldUnits.setColumns(10);
        }
        {
            JLabel lblRemarks = new JLabel("Remarks");
            panel.add(lblRemarks, "2, 8, right, default");
        }
        {
            textFieldRemarks = new JTextField();
            panel.add(textFieldRemarks, "4, 8, fill, default");
            textFieldRemarks.setColumns(10);
        }
    }
}

From source file:com.floreantpos.bo.ui.explorer.MenuItemExplorer.java

private JPanel buildSearchForm() {
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout("", "[][]15[][]15[][]15[]", "[]5[]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JLabel lblOrderType = new JLabel(Messages.getString("MenuItemExplorer.4")); //$NON-NLS-1$
    cbOrderTypes = new JComboBox();

    cbOrderTypes.addItem(Messages.getString("MenuItemExplorer.5")); //$NON-NLS-1$
    cbOrderTypes.addItem("<None>");

    List<OrderType> orderTypes = Application.getInstance().getOrderTypes();
    for (OrderType orderType : orderTypes) {
        cbOrderTypes.addItem(orderType);
    }/*  ww  w.  j  a  v a  2 s .c  om*/

    JLabel lblName = new JLabel(Messages.getString("MenuItemExplorer.0")); //$NON-NLS-1$
    JLabel lblGroup = new JLabel(Messages.getString("MenuItemExplorer.1")); //$NON-NLS-1$
    tfName = new JTextField(15);

    try {

        List<MenuGroup> menuGroupList = MenuGroupDAO.getInstance().findAll();

        cbGroup = new JComboBox();

        cbGroup.addItem(Messages.getString("MenuItemExplorer.2")); //$NON-NLS-1$
        cbGroup.addItem("<None>");
        for (MenuGroup s : menuGroupList) {
            cbGroup.addItem(s);
        }

        JButton searchBttn = new JButton(Messages.getString("MenuItemExplorer.3")); //$NON-NLS-1$

        panel.add(lblName, "align label"); //$NON-NLS-1$
        panel.add(tfName);
        panel.add(lblGroup);
        panel.add(cbGroup);
        panel.add(lblOrderType);
        panel.add(cbOrderTypes);
        panel.add(searchBttn);

        Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(loweredetched, "Search"); //$NON-NLS-1$
        title.setTitleJustification(TitledBorder.LEFT);
        panel.setBorder(title);

        searchBttn.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                searchItem();
            }
        });

        tfName.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                searchItem();
            }
        });

    } catch (Throwable x) {
        BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x);
    }

    return panel;
}

From source file:dbmods.InsertTemplateName.java

private void addTechnology() {
    //START >>  jUserNameLabel
    jUserNameLabel = new JLabel();
    getContentPane().add(jUserNameLabel);
    jUserNameLabel.setText("User");
    jUserNameLabel.setBounds(28, 113, 146, 16);
    //END <<  jUserNameLabel

    //START >>  jTechnologyList
    ComboBoxModel<String> jTechnologyListModel = new DefaultComboBoxModel<String>(TECHNOLOGY);
    jTechnologyList = new JComboBox<String>();
    getContentPane().add(jTechnologyList);
    jTechnologyList.setModel(jTechnologyListModel);
    jTechnologyList.setBounds(192, 75, 118, 23);
    //END <<  jTechnologyList
}

From source file:gtu.zcognos.DimensionUI.java

private void initGUI() {
    try {/*from  w  w  w .  ja  v  a2  s  .  co  m*/

        final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this);
        {
            GroupLayout thisLayout = new GroupLayout((JComponent) getContentPane());
            getContentPane().setLayout(thisLayout);
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            {
                projectId = new JTextField();
            }
            {
                jLabel1 = new JLabel();
                jLabel1.setText("PROJECT_ID");
            }
            {
                create = new JButton();
                create.setText("create");
                create.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("create.actionPerformed", evt);
                    }
                });
            }
            {
                reportId = new JTextField();
            }
            {
                jLabel8 = new JLabel();
                jLabel8.setText("report id");
            }
            {
                addDimensionFromDb = new JButton();
                addDimensionFromDb.setText("add from db");
                addDimensionFromDb.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("addFromDb.actionPerformed", evt);
                    }
                });
            }
            {
                dataSourceTable = new JTextField();
                dataSourceTable.setText("rscdpg0901");
            }
            {
                jLabel7 = new JLabel();
                jLabel7.setText("data source table");
            }
            {
                addDimension = new JButton();
                addDimension.setText("add");
                addDimension.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("add.actionPerformed", evt);
                    }
                });
            }
            {
                dimensionName = new JTextField();
            }
            {
                jLabel6 = new JLabel();
                jLabel6.setText("dimension chinese name");
            }
            {
                jLabel5 = new JLabel();
                jLabel5.setText("rscdzzzz id index");
            }
            {
                String[] idx = new String[20];
                for (int ii = 0; ii < idx.length; ii++) {
                    idx[ii] = "id" + (ii + 1);
                }
                ComboBoxModel rscdzzzzIdIndexModel = new DefaultComboBoxModel(idx);
                rscdzzzzIdIndex = new JComboBox();
                rscdzzzzIdIndex.setModel(rscdzzzzIdIndexModel);
            }
            {
                jLabel3 = new JLabel();
                jLabel3.setText("Dimension");
            }
            {
                jScrollPane1 = new JScrollPane();
                {
                    DefaultListModel dimensionListModel = new DefaultListModel();
                    dimensionList = new JList();
                    jScrollPane1.setViewportView(dimensionList);
                    dimensionList.setModel(dimensionListModel);
                    dimensionList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(dimensionList).defaultJListKeyPressed(evt);
                        }
                    });
                }
            }
            {
                exportDir = new JButton();
                exportDir.setText("export dir");
                exportDir.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("exportDir.actionPerformed", evt);
                    }
                });
            }
            {
                category = new JTextField();
            }
            {
                jLabel4 = new JLabel();
                jLabel4.setText("category");
            }
            {
                tableName = new JTextField();
            }
            {
                jLabel2 = new JLabel();
                jLabel2.setText("merge table name");
            }
            thisLayout
                    .setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12)
                            .addGroup(thisLayout.createParallelGroup()
                                    .addComponent(jLabel3, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE)
                                    .addGroup(thisLayout.createSequentialGroup().addGap(19).addGroup(thisLayout
                                            .createParallelGroup().addGroup(thisLayout.createSequentialGroup()
                                                    .addComponent(exportDir, GroupLayout.PREFERRED_SIZE, 119,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(
                                                            addDimension, GroupLayout.PREFERRED_SIZE, 119,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addGroup(thisLayout.createParallelGroup().addComponent(
                                                            addDimensionFromDb, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 191,
                                                            GroupLayout.PREFERRED_SIZE)
                                                            .addGroup(thisLayout.createSequentialGroup().addGap(
                                                                    88)
                                                                    .addComponent(create,
                                                                            GroupLayout.PREFERRED_SIZE, 119,
                                                                            GroupLayout.PREFERRED_SIZE))))
                                            .addGroup(thisLayout.createSequentialGroup().addGroup(thisLayout
                                                    .createParallelGroup()
                                                    .addComponent(jLabel6, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel5, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel4, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel8, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel2, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel7, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel1, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE))
                                                    .addGap(39)
                                                    .addGroup(thisLayout.createParallelGroup()
                                                            .addComponent(dimensionName,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(rscdzzzzIdIndex,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(category,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(reportId,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(tableName,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(dataSourceTable,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(projectId,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)))
                                            .addComponent(jScrollPane1, GroupLayout.Alignment.LEADING,
                                                    GroupLayout.PREFERRED_SIZE, 436,
                                                    GroupLayout.PREFERRED_SIZE))))
                            .addContainerGap(11, 11));
            thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(projectId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(dataSourceTable, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(tableName, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(reportId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(category, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup()
                            .addComponent(jLabel5, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(rscdzzzzIdIndex, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(dimensionName, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(addDimension, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(exportDir, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(addDimensionFromDb, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(11)
                    .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 269, GroupLayout.PREFERRED_SIZE)
                    .addGap(12).addComponent(create, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(9, 9));
        }
        this.setSize(513, 632);

        swingUtil.addAction("exportDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (file != null) {
                    baseDir = file;
                }
            }
        });

        swingUtil.addAction("addFromDb.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                String project = projectId.getText();
                Validate.notEmpty(project, "projectId is null");
                Validate.notEmpty(dataSourceTable.getText(), "dataSourceTable is null");

                DefaultListModel model = (DefaultListModel) dimensionList.getModel();
                for (Dimension_ ddd : InformixDbConn.queryGetDaminsion(dataSourceTable.getText(), project)) {
                    model.addElement(ddd);
                }
            }
        });

        swingUtil.addAction("add.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                // Validate.notEmpty(tableName.getText(),
                // "tableName is null");
                Validate.notEmpty(category.getText(), "category is null");
                Validate.notEmpty(dimensionName.getText(), "dimensionName is null");
                Validate.notEmpty(dataSourceTable.getText(), "dataSourceTable is null");
                // Validate.notEmpty(reportId.getText(),
                // "reportId is null");

                String report_id = StringUtils.defaultString(reportId.getText(), projectId.getText());

                String tName = tableName.getText();
                if (StringUtils.isEmpty(tName)) {
                    tName = randomTableName();
                }

                DefaultListModel model = (DefaultListModel) dimensionList.getModel();
                model.addElement(new Dimension_(dataSourceTable.getText(), tName, category.getText(),
                        (String) rscdzzzzIdIndex.getSelectedItem(), dimensionName.getText(), report_id));
            }
        });

        swingUtil.addAction("create.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {

                String project = projectId.getText();
                Validate.notEmpty(project, "projectId is null");
                Validate.notNull(baseDir, "exportDir is null");

                File destDir = new File(baseDir, project);

                Map<String, Object> map = new HashMap<String, Object>();

                List<Map<String, String>> llist = new ArrayList<Map<String, String>>();

                int idx = 2;
                int categoryId = 1;
                DefaultListModel model = (DefaultListModel) dimensionList.getModel();
                for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) {
                    Dimension_ di = (Dimension_) enu.nextElement();

                    Map mmm = new HashMap();
                    mmm.put("rscdpg0901", di.dataSourceTable);//
                    mmm.put("rscdpg0901a", di.tableName);//
                    mmm.put("rscdpg0901a_category", di.category);//
                    mmm.put("rscdpg0901a_report_id", di.reportId);//
                    mmm.put("rscdzzzz_id", di.idIndex);//
                    mmm.put("rscdpg0901a_dname", di.dimensionName);//
                    llist.add(mmm);
                }

                map.put("PROJECT_ID", project);
                map.put("RSCDPG0901", llist);
                map.put("rscdpg0901", dataSourceTable.getText());

                ConfigCopy.getInstance().applyBaseDir(baseDir).applyProjectId(project).execute();

                Dimension.getInstance()//
                        .applyDestDir(destDir.getAbsolutePath())//
                        .applyParameter(map)//
                        .execute();

                JOptionPaneUtil.newInstance().iconInformationMessage()
                        .showMessageDialog(project + " create completed!!\r\n dir : " //
                                + destDir.getAbsolutePath(), project);

                Desktop.getDesktop().open(destDir);
            }
        });

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

From source file:EditorPaneExample18.java

public EditorPaneExample18() {
    super("JEditorPane Example 18");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);/*from   w w  w.j a  va  2  s  . com*/

    // Populate it
    createMenuBar();

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Register a custom EditorKit for HTML
    ClassLoader loader = getClass().getClassLoader();
    if (loader != null) {
        // Java 2
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit");
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:gdt.jgui.entity.query.JQueryPanel.java

/**
 * The default constructor.// w w w.  j  av  a  2  s  . c o  m
 */
public JQueryPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 100, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0 };
    setLayout(gridBagLayout);
    JLabel lblElement = new JLabel("Element");

    GridBagConstraints gbc_lblElement = new GridBagConstraints();
    gbc_lblElement.insets = new Insets(5, 5, 5, 5);
    gbc_lblElement.gridx = 0;
    gbc_lblElement.gridy = 0;
    gbc_lblElement.anchor = GridBagConstraints.FIRST_LINE_START;
    add(lblElement, gbc_lblElement);

    elementComboBox = new JComboBox<String>();
    GridBagConstraints gbc_elementComboBox = new GridBagConstraints();
    gbc_elementComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_elementComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_elementComboBox.gridx = 1;
    gbc_elementComboBox.gridy = 0;
    gbc_elementComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(elementComboBox, gbc_elementComboBox);
    elementComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            try {
                initItemNameSelector();
            } catch (Exception ee) {
                LOGGER.severe(ee.toString());
            }
        }
    });
    JLabel lblItemNameField = new JLabel("Item field");
    GridBagConstraints gbc_lblItemField = new GridBagConstraints();
    gbc_lblItemField.insets = new Insets(5, 5, 5, 5);
    gbc_lblItemField.gridx = 0;
    gbc_lblItemField.gridy = 1;
    gbc_lblItemField.anchor = GridBagConstraints.FIRST_LINE_START;

    add(lblItemNameField, gbc_lblItemField);

    itemNameFieldComboBox = new JComboBox<String>();
    GridBagConstraints gbc_itemNameFieldComboBox = new GridBagConstraints();
    gbc_itemNameFieldComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_itemNameFieldComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_itemNameFieldComboBox.gridx = 1;
    gbc_itemNameFieldComboBox.gridy = 1;
    gbc_itemNameFieldComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemNameFieldComboBox, gbc_itemNameFieldComboBox);
    itemNameFieldComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            try {
                initItemNameSelector();
                initItemValueSelector();
            } catch (Exception ee) {
                LOGGER.severe(ee.toString());
            }
        }
    });
    JLabel itemTitle = new JLabel("Item title");
    GridBagConstraints gbc_lblItemtitle = new GridBagConstraints();
    gbc_lblItemtitle.insets = new Insets(5, 5, 5, 5);
    gbc_lblItemtitle.gridx = 0;
    gbc_lblItemtitle.gridy = 2;
    gbc_lblItemtitle.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemTitle, gbc_lblItemtitle);

    itemNameComboBox = new JComboBox<String>();
    GridBagConstraints gbc_itemComboBox = new GridBagConstraints();
    gbc_itemComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_itemComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_itemComboBox.gridx = 1;
    gbc_itemComboBox.gridy = 2;
    gbc_itemComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemNameComboBox, gbc_itemComboBox);
    itemNameComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            try {
                initItemValueSelector();
            } catch (Exception ee) {
                LOGGER.severe(ee.toString());
            }
        }
    });

    JLabel itemValue = new JLabel("Item value");
    GridBagConstraints gbc_lblItemValue = new GridBagConstraints();
    gbc_lblItemValue.insets = new Insets(5, 5, 5, 5);
    gbc_lblItemValue.weighty = 0.0;
    gbc_lblItemValue.gridx = 0;
    gbc_lblItemValue.gridy = 3;
    gbc_lblItemValue.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemValue, gbc_lblItemValue);

    itemValueComboBox = new JComboBox<String>();
    GridBagConstraints gbc_itemValueComboBox = new GridBagConstraints();
    gbc_itemValueComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_itemValueComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_itemValueComboBox.gridx = 1;
    gbc_itemValueComboBox.gridy = 3;
    gbc_itemValueComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemValueComboBox, gbc_itemValueComboBox);
    table = new JTable();
    JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            int row = table.rowAtPoint(evt.getPoint());
            int col = table.columnAtPoint(evt.getPoint());
            System.out.println("JQueryPanel:cell click:row=" + row + " column=" + col);
            if (col == 1) {
                String label$ = (String) table.getValueAt(row, 1);
                System.out.println("JQueryPanel:cell click:label=" + label$);
                Entigrator entigrator = console.getEntigrator(entihome$);
                String entity$ = entigrator.indx_keyAtLabel(label$);
                JEntityFacetPanel efp = new JEntityFacetPanel();
                String efpLocator$ = efp.getLocator();
                efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$);
                efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entity$);
                JConsoleHandler.execute(console, efpLocator$);
            }
        }
    });
    GridBagConstraints gbc_scroll_panel = new GridBagConstraints();
    gbc_scroll_panel.anchor = GridBagConstraints.NORTH;
    gbc_scroll_panel.gridwidth = 2;
    gbc_scroll_panel.weighty = 1.0;
    gbc_scroll_panel.fill = GridBagConstraints.HORIZONTAL;
    gbc_scroll_panel.gridx = 0;
    gbc_scroll_panel.gridy = 4;
    add(scrollPane, gbc_scroll_panel);
    scrollPane.setMinimumSize(scrollPane.getPreferredSize());
}

From source file:com.mgmtp.perfload.loadprofiles.ui.dialog.SettingsDialog.java

private void initComponents() {
    getContentPane().setLayout(new MigLayout("", "[grow]", "[][grow][grow][grow][]"));
    {//  w w w  .ja  v a 2 s .  com
        JPanel pnlConfigurations = new JPanel();
        pnlConfigurations.setBorder(new TitledBorder(null, "Saved Configurations", TitledBorder.LEADING,
                TitledBorder.TOP, null, null));
        pnlConfigurations.setName("pnlConfigurations");
        getContentPane().add(pnlConfigurations, "cell 0 0, growx");
        pnlConfigurations.setLayout(new MigLayout("", "[grow]", "[]"));
        {
            JLabel lblFileName = new JLabel("File Name");
            lblFileName.setName("lblFileName");
            pnlConfigurations.add(lblFileName, "flowx,cell 0 0");
        }
        {
            cboConfigurationFile = new JComboBox() {
                @Override
                public void setSelectedItem(final Object anObject) {
                    if (checkDirty()) {
                        super.setSelectedItem(anObject);
                    }
                }
            };
            cboConfigurationFile.addItemListener(new CboConfigurationFileItemListener());
            pnlConfigurations.add(cboConfigurationFile, "cell 0 0,growx");
            cboConfigurationFile.setName("cboConfigurationFile");
        }
        {
            JButton btnNewConfigurationFile = new JButtonExt("New...");
            btnNewConfigurationFile.addActionListener(new BtnNewConfigurationFileActionListener());
            pnlConfigurations.add(btnNewConfigurationFile, "cell 0 0, sg btns");
            btnNewConfigurationFile.setName("btnNewButton");
        }
        {
            JButton btnCopy = new JButtonExt("Copy...");
            btnCopy.addActionListener(new BtnCopyActionListener());
            btnCopy.setName("btnCopy");
            pnlConfigurations.add(btnCopy, "cell 0 0, sg btns");
        }
        {
            JButton btnDelete = new JButtonExt("Delete...");
            btnDelete.addActionListener(new BtnDeleteActionListener());
            btnDelete.setName("btnDelete");
            pnlConfigurations.add(btnDelete, "cell 0 0, sg btns");
        }
    }
    {
        JPanel pnlOperations = new JPanel();
        getContentPane().add(pnlOperations, "cell 0 1, grow");
        pnlOperations.setBorder(
                new TitledBorder(null, "Operations", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        pnlOperations.setName("pnlOperations");
        pnlOperations.setLayout(new MigLayout("insets 4", "[grow][110!]", "[][]"));
        {
            JScrollPane spOperations = new JScrollPane();
            spOperations.setName("spOperations");
            pnlOperations.add(spOperations, "cell 0 0 1 2, height 180::, grow");
            {
                tblOperations = new JTableExt();
                tblOperations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                tblOperations.setFillsViewportHeight(true);
                tblOperations.setName("tblOperations");
                spOperations.setViewportView(tblOperations);
            }
        }
        {
            JButton btnAddOperation = new JButtonExt("Add Operation");
            btnAddOperation.addActionListener(new BtnAddOperationActionListener());
            btnAddOperation.setMargin(new Insets(2, 2, 2, 2));
            btnAddOperation.setName("btnAddOperation");
            pnlOperations.add(btnAddOperation, "cell 1 0, grow");
        }
        {
            JButton btnRemoveOperation = new JButtonExt("Delete Operation");
            btnRemoveOperation.addActionListener(new BtnRemoveOperationActionListener());
            btnRemoveOperation.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveOperation.setName("btnRemoveOperation");
            pnlOperations.add(btnRemoveOperation, "cell 1 1, growx, top");
        }
    }

    {
        JPanel pnlTargets = new JPanel();
        getContentPane().add(pnlTargets, "cell 0 2, grow");
        pnlTargets.setBorder(
                new TitledBorder(null, "Targets", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        pnlTargets.setName("pnlTargets");
        pnlTargets.setLayout(new MigLayout("insets 4", "[grow][110!]", "[][]"));
        {
            JScrollPane spTargets = new JScrollPane();
            spTargets.setName("spTargets");
            pnlTargets.add(spTargets, "cell 0 0 1 2, height 50::, grow");
            {
                tblTargets = new JTableExt();
                tblTargets.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                tblTargets.setFillsViewportHeight(true);
                tblTargets.setName("tblTargets");
                spTargets.setViewportView(tblTargets);
            }
        }
        {
            JButton btnAddTarget = new JButtonExt("Add Target");
            btnAddTarget.addActionListener(new BtnAddTargetActionListener());
            btnAddTarget.setMargin(new Insets(2, 2, 2, 2));
            btnAddTarget.setName("btnAddClientConfig");
            pnlTargets.add(btnAddTarget, "cell 1 0, growx");
        }
        {
            JButton btnRemoveTarget = new JButtonExt("Delete Target");
            btnRemoveTarget.addActionListener(new BtnRemoveTargetActionListener());
            btnRemoveTarget.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveTarget.setName("btnRemoveClientConfig");
            pnlTargets.add(btnRemoveTarget, "cell 1 1, growx, top");
        }
    }

    {
        JPanel pnlClients = new JPanel();
        getContentPane().add(pnlClients, "cell 0 3, grow");
        pnlClients.setBorder(
                new TitledBorder(null, "Clients", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        pnlClients.setName("pnlClientConfigs");
        pnlClients.setLayout(new MigLayout("insets 4", "[grow][110!]", "[][]"));
        {
            JScrollPane spClients = new JScrollPane();
            spClients.setName("spClients");
            pnlClients.add(spClients, "cell 0 0 1 2, height 50::, grow");
            {
                tblClients = new JTableExt();
                tblClients.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                tblClients.setFillsViewportHeight(true);
                tblClients.setName("tblClients");
                spClients.setViewportView(tblClients);
            }
        }
        {
            JButton btnAddClient = new JButtonExt("Add Client");
            btnAddClient.addActionListener(new BtnAddClientActionListener());
            btnAddClient.setMargin(new Insets(2, 2, 2, 2));
            btnAddClient.setName("btnAddClient");
            pnlClients.add(btnAddClient, "cell 1 0, growx");
        }
        {
            JButton btnRemoveClient = new JButtonExt("Delete Client");
            btnRemoveClient.addActionListener(new BtnRemoveClientActionListener());
            btnRemoveClient.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveClient.setName("btnRemoveClient");
            pnlClients.add(btnRemoveClient, "cell 1 1, growx, top");
        }
    }

    {
        JButton btnOk = new JButtonExt("OK");
        getRootPane().setDefaultButton(btnOk);
        btnOk.addActionListener(new BtnOkActionListener());
        btnOk.setName("btnOk");
        getContentPane().add(btnOk, "cell 0 4,alignx right");
    }
    {
        JButton btnCancel = new JButtonExt("Cancel");
        btnCancel.addActionListener(new BtnCancelActionListener());
        btnCancel.setName("btnCancel");
        getContentPane().add(btnCancel, "cell 0 4,alignx right");
    }
}

From source file:sim.util.media.chart.ScatterPlotSeriesAttributes.java

public void buildAttributes() {
    // The following three variables aren't defined until AFTER construction if
    // you just define them above.  So we define them below here instead.
    opacity = 1.0;// ww  w  . j a v a  2 s .com

    // NOTE:
    // Paint paint = renderer.getSeriesPaint(getSeriesIndex());        
    // In JFreeChart 1.0.6 getSeriesPaint returns null!!!
    // You need lookupSeriesPaint(), but that's not backward compatible.
    // The only thing consistent in all versions is getItemPaint 
    // (which looks like a gross miss-use, but gets the job done)

    color = (Color) ((((XYPlot) getPlot()).getRenderer()).getItemPaint(getSeriesIndex(), -1));

    colorWell = new ColorWell(color) {
        public Color changeColor(Color c) {
            color = c;
            rebuildGraphicsDefinitions();
            return c;
        }
    };

    addLabelled("Color", colorWell);

    opacityField = new NumberTextField("Opacity ", opacity, 1.0, 0.125) {
        public double newValue(double newValue) {
            if (newValue < 0.0 || newValue > 1.0)
                newValue = currentValue;
            opacity = (float) newValue;
            rebuildGraphicsDefinitions();
            return newValue;
        }
    };
    addLabelled("", opacityField);

    shapeList = new JComboBox();
    shapeList.setEditable(false);
    shapeList.setModel(new DefaultComboBoxModel(new java.util.Vector(Arrays.asList(shapeNames))));
    shapeList.setSelectedIndex(shapeNum);
    shapeList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            shapeNum = shapeList.getSelectedIndex();
            shape = shapes[shapeNum];
            rebuildGraphicsDefinitions();
        }
    });
    addLabelled("Shape", shapeList);
}

From source file:edu.gmu.cs.sim.util.media.chart.BarChartGenerator.java

protected void buildGlobalAttributes(LabelledList list) {
    // create the chart
    CategoryPlot plot = (CategoryPlot) (chart.getPlot());
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinePaint(new Color(200, 200, 200));
    plot.setRangeGridlinePaint(new Color(200, 200, 200));

    // define the renderers
    barRenderer = new BarRenderer();
    reviseRenderer(barRenderer);//from   w w  w  .  j a  va2 s . c o  m

    stackedBarRenderer = new StackedBarRenderer(false);
    reviseRenderer(stackedBarRenderer);

    percentageRenderer = new StackedBarRenderer(true);
    reviseRenderer(percentageRenderer);

    plot.setRenderer(barRenderer);

    xLabel = new PropertyField() {
        public String newValue(String newValue) {
            setXAxisLabel(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    xLabel.setValue(getXAxisLabel());

    list.add(new JLabel("X Label"), xLabel);

    yLabel = new PropertyField() {
        public String newValue(String newValue) {
            setYAxisLabel(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    yLabel.setValue(getYAxisLabel());

    list.add(new JLabel("Y Label"), yLabel);

    final JCheckBox gridlines = new JCheckBox();
    gridlines.setSelected(false);
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hasgridlines = (e.getStateChange() == ItemEvent.SELECTED);
            updateGridLines();
        }
    };
    gridlines.addItemListener(il);

    list.add(new JLabel("Grid Lines"), gridlines);

    final JCheckBox labels = new JCheckBox();
    labels.setSelected(true);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                getBarRenderer().setBaseItemLabelsVisible(true);
                getStackedBarRenderer().setBaseItemLabelsVisible(true);
                getPercentageRenderer().setBaseItemLabelsVisible(true);
            } else {
                getBarRenderer().setBaseItemLabelsVisible(false);
                getStackedBarRenderer().setBaseItemLabelsVisible(false);
                getPercentageRenderer().setBaseItemLabelsVisible(false);
            }
        }
    };
    labels.addItemListener(il);
    list.add(new JLabel("Labels"), labels);

    final JComboBox barType = new JComboBox();
    barType.setEditable(false);
    barType.setModel(new DefaultComboBoxModel(
            new java.util.Vector(Arrays.asList(new String[] { "Separate", "Stacked", "Percentage" }))));
    barType.setSelectedIndex(0);
    barType.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CategoryPlot plot = (CategoryPlot) (chart.getPlot());
            int type = barType.getSelectedIndex();

            if (type == 0) // separate
            {
                plot.setRenderer(getBarRenderer());
            } else if (type == 1) // stacked
            {
                plot.setRenderer(getStackedBarRenderer());
            } else // percentage
            {
                plot.setRenderer(getPercentageRenderer());
            }
        }
    });
    list.add(new JLabel("Bars"), barType);

    final JCheckBox horizontal = new JCheckBox();
    horizontal.setSelected(false);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            CategoryPlot plot = (CategoryPlot) (chart.getPlot());
            if (e.getStateChange() == ItemEvent.SELECTED) {
                plot.setOrientation(PlotOrientation.HORIZONTAL);
                ishorizontal = true;
            } else {
                plot.setOrientation(PlotOrientation.VERTICAL);
                ishorizontal = false;
            }
            updateGridLines();
        }
    };
    horizontal.addItemListener(il);

    list.add(new JLabel("Horizontal"), horizontal);
}