Search in sources :

Example 26 with ActionListener

use of java.awt.event.ActionListener in project gradle by gradle.

the class SearchPanel method setupUI.

private void setupUI() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    isCaseSensitiveCheckBox = new JCheckBox("Case Sensitive");
    isCaseSensitiveCheckBox.setMnemonic('c');
    isCaseSensitiveCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            requestSearch();
        }
    });
    useRegularExpressionsCheckBox = new JCheckBox("Regular Expression");
    useRegularExpressionsCheckBox.setMnemonic('r');
    useRegularExpressionsCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            requestSearch();
        }
    });
    findNextButton = Utility.createButton(getClass(), "/org/gradle/gradleplugin/userinterface/swing/generic/tabs/move-down.png", "Find Next Match", new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            goToNextMatch();
        }
    });
    findPreviousButton = Utility.createButton(getClass(), "/org/gradle/gradleplugin/userinterface/swing/generic/tabs/move-up.png", "Find Previous Match", new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            goToPreviousMatch();
        }
    });
    JButton closeButton = Utility.createButton(getClass(), "/org/gradle/gradleplugin/userinterface/swing/generic/close.png", "Close Search Panel", new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    mainPanel.add(createTextToMatchField());
    mainPanel.add(Box.createHorizontalStrut(5));
    mainPanel.add(findPreviousButton);
    mainPanel.add(Box.createHorizontalStrut(5));
    mainPanel.add(findNextButton);
    mainPanel.add(Box.createHorizontalStrut(5));
    mainPanel.add(isCaseSensitiveCheckBox);
    mainPanel.add(Box.createHorizontalStrut(5));
    mainPanel.add(useRegularExpressionsCheckBox);
    addAdditionalFields(mainPanel);
    mainPanel.add(Box.createHorizontalGlue());
    mainPanel.add(closeButton);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 27 with ActionListener

use of java.awt.event.ActionListener in project libgdx by libgdx.

the class EditorPanel method initializeComponents.

protected void initializeComponents() {
    setLayout(new GridBagLayout());
    {
        titlePanel = new JPanel(new GridBagLayout());
        add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 0, 3, 0), 0, 0));
        titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        {
            nameLabel = new JLabel(name);
            titlePanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
            nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
        }
        {
            descriptionLabel = new JLabel(description);
            titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
        }
        {
            advancedButton = new JToggleButton("Advanced");
            titlePanel.add(advancedButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
            advancedButton.setVisible(false);
        }
        {
            activeButton = new JToggleButton("Active");
            titlePanel.add(activeButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
        }
        {
            removeButton = new JButton("X");
            titlePanel.add(removeButton, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
        }
    }
    {
        contentPanel = new JPanel(new GridBagLayout());
        add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0));
        contentPanel.setVisible(false);
    }
    {
        advancedPanel = new JPanel(new GridBagLayout());
        add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0));
        advancedPanel.setVisible(false);
    }
    titlePanel.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent event) {
            if (!isAlwaysShown)
                showContent(!contentPanel.isVisible());
        }
    });
    activeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            activate();
        }
    });
    advancedButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            advancedPanel.setVisible(advancedButton.isSelected());
        }
    });
    removeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            removePanel();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel)

Example 28 with ActionListener

use of java.awt.event.ActionListener in project libgdx by libgdx.

the class EditorPanel method setValue.

protected static void setValue(JCheckBox checkBox, boolean isSelected) {
    ActionListener[] listeners = checkBox.getActionListeners();
    ActionListener listener = null;
    if (listeners != null && listeners.length > 0) {
        listener = listeners[0];
        checkBox.removeActionListener(listener);
    }
    checkBox.setSelected(isSelected);
    if (listener != null)
        checkBox.addActionListener(listener);
}
Also used : ActionListener(java.awt.event.ActionListener)

Example 29 with ActionListener

use of java.awt.event.ActionListener in project libgdx by libgdx.

the class DynamicsInfluencerPanel method initializeComponents.

protected void initializeComponents() {
    super.initializeComponents();
    JPanel velocitiesPanel = new JPanel();
    velocitiesPanel.setLayout(new GridBagLayout());
    {
        JPanel sideButtons = new JPanel(new GridBagLayout());
        velocitiesPanel.add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        {
            sideButtons.add(velocityBox = new JComboBox(new DefaultComboBoxModel()), 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) {
                    createVelocity(velocityBox.getSelectedItem());
                }
            });
        }
        {
            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) {
                    deleteVelocity();
                }
            });
        }
    }
    JScrollPane scroll = new JScrollPane();
    velocitiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
    velocityTable = 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;
        }
    };
    velocityTable.getTableHeader().setReorderingAllowed(false);
    velocityTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scroll.setViewportView(velocityTable);
    velocityTableModel = new DefaultTableModel(new String[0][0], new String[] { "Velocity", "Active" });
    velocityTable.setModel(velocityTableModel);
    velocityTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

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

        public void tableChanged(TableModelEvent event) {
            if (event.getColumn() != 1)
                return;
            velocityChecked(event.getFirstRow(), (Boolean) velocityTable.getValueAt(event.getFirstRow(), 1));
        }
    });
    //Velocity values
    emptyPanel = new ParticleValuePanel(editor, "", "", true, false);
    strengthVelocityPanel = new StrengthVelocityPanel(editor, null, "Life", "", "");
    angularVelocityPanel = new AngularVelocityPanel(editor, null, "Life", "", "");
    strengthVelocityPanel.setVisible(false);
    angularVelocityPanel.setVisible(false);
    emptyPanel.setVisible(false);
    strengthVelocityPanel.setIsAlwayShown(true);
    angularVelocityPanel.setIsAlwayShown(true);
    emptyPanel.setIsAlwayShown(true);
    emptyPanel.setValue(null);
    //Assemble
    int i = 0;
    addContent(i++, 0, velocitiesPanel);
    addContent(i++, 0, strengthVelocityPanel);
    addContent(i++, 0, angularVelocityPanel);
    addContent(i++, 0, emptyPanel);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) TableModelEvent(javax.swing.event.TableModelEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) TableModelListener(javax.swing.event.TableModelListener)

Example 30 with ActionListener

use of java.awt.event.ActionListener in project libgdx by libgdx.

the class AngularVelocityPanel method initializeComponents.

private void initializeComponents(DynamicsModifier.Angular aValue, String charTitle) {
    JPanel contentPanel = getContentPanel();
    {
        JPanel panel = new JPanel();
        panel.add(new JLabel("Global"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        panel.add(isGlobalCheckBox = new JCheckBox(), new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        contentPanel.add(panel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    }
    {
        contentPanel.add(magnitudePanel = new ScaledNumericPanel(editor, aValue == null ? null : aValue.strengthValue, charTitle, "Strength", "In world units per second.", true), new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
    }
    {
        contentPanel.add(phiPanel = new ScaledNumericPanel(editor, aValue == null ? null : aValue.phiValue, charTitle, "Azimuth", "Rotation starting on Y", true), new GridBagConstraints(0, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
    }
    {
        contentPanel.add(thetaPanel = new ScaledNumericPanel(editor, aValue == null ? null : aValue.thetaValue, charTitle, "Polar angle", "around Y axis on XZ plane", true), new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
    }
    {
        JPanel spacer = new JPanel();
        spacer.setPreferredSize(new Dimension());
        contentPanel.add(spacer, new GridBagConstraints(6, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    }
    magnitudePanel.setIsAlwayShown(true);
    phiPanel.setIsAlwayShown(true);
    thetaPanel.setIsAlwayShown(true);
    isGlobalCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            AngularVelocityPanel.this.value.isGlobal = isGlobalCheckBox.isSelected();
        }
    });
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Aggregations

ActionListener (java.awt.event.ActionListener)1347 ActionEvent (java.awt.event.ActionEvent)1303 JButton (javax.swing.JButton)363 JPanel (javax.swing.JPanel)345 JLabel (javax.swing.JLabel)234 JMenuItem (javax.swing.JMenuItem)191 BoxLayout (javax.swing.BoxLayout)150 GridBagConstraints (java.awt.GridBagConstraints)121 Insets (java.awt.Insets)121 GridBagLayout (java.awt.GridBagLayout)114 Dimension (java.awt.Dimension)113 FlowLayout (java.awt.FlowLayout)110 JCheckBox (javax.swing.JCheckBox)103 JScrollPane (javax.swing.JScrollPane)103 JMenu (javax.swing.JMenu)96 BorderLayout (java.awt.BorderLayout)88 JTextField (javax.swing.JTextField)79 JComboBox (javax.swing.JComboBox)73 ButtonGroup (javax.swing.ButtonGroup)64 ArrayList (java.util.ArrayList)60