Search in sources :

Example 71 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project libgdx by libgdx.

the class FlameMain method initializeComponents.

private void initializeComponents() {
    splitPane = new JSplitPane();
    splitPane.setUI(new BasicSplitPaneUI() {

        public void paint(Graphics g, JComponent jc) {
        }
    });
    splitPane.setDividerSize(4);
    getContentPane().add(splitPane, BorderLayout.CENTER);
    {
        JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        rightSplit.setUI(new BasicSplitPaneUI() {

            public void paint(Graphics g, JComponent jc) {
            }
        });
        rightSplit.setDividerSize(4);
        splitPane.add(rightSplit, JSplitPane.RIGHT);
        {
            JPanel propertiesPanel = new JPanel(new GridBagLayout());
            rightSplit.add(propertiesPanel, JSplitPane.TOP);
            propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory.createTitledBorder("Editor Properties")));
            {
                JScrollPane scroll = new JScrollPane();
                propertiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                scroll.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
                {
                    editorPropertiesPanel = new JPanel(new GridBagLayout());
                    scroll.setViewportView(editorPropertiesPanel);
                    scroll.getVerticalScrollBar().setUnitIncrement(70);
                }
            }
        }
        {
            JSplitPane rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
            rightSplitPane.setUI(new BasicSplitPaneUI() {

                public void paint(Graphics g, JComponent jc) {
                }
            });
            rightSplitPane.setDividerSize(4);
            rightSplitPane.setDividerLocation(100);
            rightSplit.add(rightSplitPane, JSplitPane.BOTTOM);
            JPanel propertiesPanel = new JPanel(new GridBagLayout());
            rightSplitPane.add(propertiesPanel, JSplitPane.TOP);
            propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory.createTitledBorder("Influencers")));
            {
                JScrollPane scroll = new JScrollPane();
                propertiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                scroll.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
                {
                    JPanel influencersPanel = new JPanel(new GridBagLayout());
                    influencerBox = new JComboBox(new DefaultComboBoxModel());
                    JButton addInfluencerButton = new JButton("Add");
                    addInfluencerButton.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            InfluencerWrapper wrapper = (InfluencerWrapper) influencerBox.getSelectedItem();
                            ParticleController controller = getEmitter();
                            if (controller != null)
                                addInfluencer(wrapper.type, controller);
                        }
                    });
                    influencersPanel.add(influencerBox, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                    influencersPanel.add(addInfluencerButton, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                    scroll.setViewportView(influencersPanel);
                    scroll.getVerticalScrollBar().setUnitIncrement(70);
                }
            }
            propertiesPanel = new JPanel(new GridBagLayout());
            rightSplitPane.add(propertiesPanel, JSplitPane.BOTTOM);
            propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory.createTitledBorder("Particle Controller Components")));
            {
                JScrollPane scroll = new JScrollPane();
                propertiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                scroll.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
                {
                    controllerPropertiesPanel = new JPanel(new GridBagLayout());
                    scroll.setViewportView(controllerPropertiesPanel);
                    scroll.getVerticalScrollBar().setUnitIncrement(70);
                }
            }
        }
        rightSplit.setDividerLocation(250);
    }
    {
        JSplitPane leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        leftSplit.setUI(new BasicSplitPaneUI() {

            public void paint(Graphics g, JComponent jc) {
            }
        });
        leftSplit.setDividerSize(4);
        splitPane.add(leftSplit, JSplitPane.LEFT);
        {
            JPanel spacer = new JPanel(new BorderLayout());
            leftSplit.add(spacer, JSplitPane.TOP);
            spacer.add(lwjglCanvas.getCanvas());
            spacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));
        }
        {
            JPanel emittersPanel = new JPanel(new BorderLayout());
            leftSplit.add(emittersPanel, JSplitPane.BOTTOM);
            emittersPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(0, 6, 6, 0), BorderFactory.createTitledBorder("Particle Controllers")));
            {
                effectPanel = new EffectPanel(this);
                emittersPanel.add(effectPanel);
            }
        }
        leftSplit.setDividerLocation(625);
    }
    splitPane.setDividerLocation(500);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Graphics(java.awt.Graphics) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) CompoundBorder(javax.swing.border.CompoundBorder) BasicSplitPaneUI(javax.swing.plaf.basic.BasicSplitPaneUI) JSplitPane(javax.swing.JSplitPane)

Example 72 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project libgdx by libgdx.

the class EffectPanel method initializeComponents.

private void initializeComponents() {
    setLayout(new GridBagLayout());
    {
        JScrollPane scroll = new JScrollPane();
        add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 6), 0, 0));
        {
            emitterTable = new JTable() {

                public Class getColumnClass(int column) {
                    return column == 1 ? Boolean.class : super.getColumnClass(column);
                }

                @Override
                public Dimension getPreferredScrollableViewportSize() {
                    Dimension dim = super.getPreferredScrollableViewportSize();
                    dim.height = getPreferredSize().height;
                    return dim;
                }
            };
            emitterTable.getTableHeader().setReorderingAllowed(false);
            emitterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            scroll.setViewportView(emitterTable);
            emitterTableModel = new DefaultTableModel(new String[0][0], new String[] { "Emitter", "" });
            emitterTable.setModel(emitterTableModel);
            emitterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

                public void valueChanged(ListSelectionEvent event) {
                    if (event.getValueIsAdjusting())
                        return;
                    emitterSelected();
                }
            });
            emitterTableModel.addTableModelListener(new TableModelListener() {

                public void tableChanged(TableModelEvent event) {
                    if (event.getColumn() != 1)
                        return;
                    emitterChecked(event.getFirstRow(), (Boolean) emitterTable.getValueAt(event.getFirstRow(), 1));
                }
            });
        }
    }
    {
        JPanel sideButtons = new JPanel(new GridBagLayout());
        add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        {
            controllerTypeCombo = new JComboBox();
            controllerTypeCombo.setModel(new DefaultComboBoxModel(ControllerType.values()));
            sideButtons.add(controllerTypeCombo, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
        }
        {
            JButton newButton = new JButton("New");
            sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            newButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    ControllerType item = (ControllerType) controllerTypeCombo.getSelectedItem();
                    createDefaultEmitter(item, true, true);
                }
            });
        }
        {
            JButton deleteButton = new JButton("Delete");
            sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            deleteButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    deleteEmitter();
                }
            });
        }
        {
            JButton cloneButton = new JButton("Clone");
            sideButtons.add(cloneButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            cloneButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    cloneEmitter();
                }
            });
        }
        {
            sideButtons.add(new JSeparator(JSeparator.HORIZONTAL), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
        }
        {
            JButton saveButton = new JButton("Save");
            sideButtons.add(saveButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            saveButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    saveEffect();
                }
            });
        }
        {
            JButton openButton = new JButton("Open");
            sideButtons.add(openButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            openButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    openEffect();
                }
            });
        }
        {
            JButton importButton = new JButton("Import");
            sideButtons.add(importButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            importButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    importEffect();
                }
            });
        }
    /*
			{
				JButton importButton = new JButton("Export");
				sideButtons.add(importButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER,
					GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
				importButton.addActionListener(new ActionListener() {
					public void actionPerformed (ActionEvent event) {
						exportEffect();
					}
				});
			}
			*/
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) TableModelEvent(javax.swing.event.TableModelEvent) ActionEvent(java.awt.event.ActionEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ControllerType(com.badlogic.gdx.tools.flame.FlameMain.ControllerType) JSeparator(javax.swing.JSeparator) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) TableModelListener(javax.swing.event.TableModelListener)

Example 73 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project libgdx by libgdx.

the class DynamicsInfluencerPanel method set.

private void set(DynamicsInfluencer influencer) {
    //Clear
    for (int i = velocityTableModel.getRowCount() - 1; i >= 0; i--) {
        velocityTableModel.removeRow(i);
    }
    velocities.clear();
    //Add
    for (int i = 0, c = influencer.velocities.size; i < c; ++i) {
        velocities.add(new VelocityWrapper((DynamicsModifier) influencer.velocities.items[i], true));
        velocityTableModel.addRow(new Object[] { "Velocity " + i, true });
    }
    DefaultComboBoxModel model = (DefaultComboBoxModel) velocityBox.getModel();
    model.removeAllElements();
    for (Object velocityObject : getAvailableVelocities(editor.getControllerType())) {
        model.addElement(velocityObject);
    }
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DynamicsModifier(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier)

Example 74 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project jBPM5-Developer-Guide by Salaboy.

the class TasksListUI method synchronizeUserComboBoxModel.

private void synchronizeUserComboBoxModel() {
    int cboAssignToIndex = this.cboAssignTo.getSelectedIndex();
    int selectedUserjComboBoxIndex = this.selectedUserjComboBox.getSelectedIndex();
    this.userComboBoxModel = new DefaultComboBoxModel();
    for (String user : this.users.keySet()) {
        this.userComboBoxModel.addElement(user);
    }
    this.cboAssignTo.setModel(userComboBoxModel);
    this.selectedUserjComboBox.setModel(userComboBoxModel);
    this.cboAssignTo.setSelectedIndex(cboAssignToIndex);
    this.selectedUserjComboBox.setSelectedIndex(selectedUserjComboBoxIndex);
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 75 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project zaproxy by zaproxy.

the class ContextSelectComboBox method reloadContexts.

/**
	 * Reloads/refreshes the list of {@link Context Contexts} from the {@link Session}.
	 * 
	 * @param keepSelected whether the previously selected context is tried to be restored. If
	 *            {@code false}, defaults to no selection.
	 */
public void reloadContexts(boolean keepSelected) {
    Context selected = null;
    if (keepSelected)
        selected = (Context) getSelectedItem();
    List<Context> contexts = Model.getSingleton().getSession().getContexts();
    Context[] contextsArray = contexts.toArray(new Context[contexts.size()]);
    ComboBoxModel<Context> model = new DefaultComboBoxModel<>(contextsArray);
    // No matter what, set selected item, so it either defaults to 'nothing selected' or
    // restores the previously selected item
    model.setSelectedItem(selected);
    this.setModel(model);
}
Also used : Context(org.zaproxy.zap.model.Context) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Aggregations

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