Search in sources :

Example 96 with ComponentEvent

use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.

the class NetworkMainPanel method getRootNetworkScroll.

JScrollPane getRootNetworkScroll() {
    if (rootNetworkScroll == null) {
        rootNetworkScroll = new JScrollPane(getRootNetworkListPanel());
        rootNetworkScroll.addComponentListener(new ComponentAdapter() {

            @Override
            public void componentResized(ComponentEvent e) {
                getRootNetworkListPanel().updateScrollableTracksViewportHeight();
            }
        });
        rootNetworkScroll.setMinimumSize(new Dimension(280, 160));
        rootNetworkScroll.setPreferredSize(new Dimension(380, 420));
    }
    return rootNetworkScroll;
}
Also used : JScrollPane(javax.swing.JScrollPane) ComponentEvent(java.awt.event.ComponentEvent) Dimension(java.awt.Dimension) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 97 with ComponentEvent

use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.

the class RootNetworkPanel method getSubNetListPanel.

private JPanel getSubNetListPanel() {
    if (subNetListPanel == null) {
        subNetListPanel = new JPanel();
        subNetListPanel.setBackground(UIManager.getColor("Table.background"));
        subNetListPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager.getColor("TableHeader.background")));
        subNetListPanel.setVisible(false);
        subNetListPanel.setLayout(new BoxLayout(subNetListPanel, BoxLayout.Y_AXIS));
        subNetListPanel.addComponentListener(new ComponentAdapter() {

            @Override
            public void componentShown(final ComponentEvent ce) {
                if (!getExpandCollapseBtn().isSelected())
                    getExpandCollapseBtn().setSelected(true);
            }

            @Override
            public void componentHidden(final ComponentEvent ce) {
                if (getExpandCollapseBtn().isSelected())
                    getExpandCollapseBtn().setSelected(false);
            }
        });
    }
    return subNetListPanel;
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 98 with ComponentEvent

use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.

the class NetworkViewGrid method init.

@SuppressWarnings("unchecked")
private void init() {
    setName(NAME);
    setFocusable(true);
    setRequestFocusEnabled(true);
    setLayout(new BorderLayout());
    add(getGridScrollPane(), BorderLayout.CENTER);
    add(getToolBar(), BorderLayout.SOUTH);
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentShown(ComponentEvent e) {
            update(thumbnailSize);
            updateToolBar();
        }

        @Override
        public void componentResized(ComponentEvent e) {
            update(thumbnailSize);
        }
    });
    setSelectionKeyBindings(this);
    setSelectionKeyBindings(getGridScrollPane().getViewport());
    update(thumbnailSize);
    addPropertyChangeListener("selectedItems", (PropertyChangeEvent e) -> {
        if (!ignoreSelectedItemsEvent)
            setSelectedNetworkViews(getNetworkViews((Collection<ThumbnailPanel>) e.getNewValue()));
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) BorderLayout(java.awt.BorderLayout) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 99 with ComponentEvent

use of java.awt.event.ComponentEvent in project CCDD by nasa.

the class CcddInputFieldPanelHandler method createDescAndDataFieldPanel.

/**
 ********************************************************************************************
 * Create the table input field panel
 *
 * @param fieldPnlHndlrOwner
 *            reference to the owner of this description and data field handler
 *
 * @param tableScrollPane
 *            scroll pane containing the table; null if this field panel handler does not
 *            contain a table
 *
 * @param ownerName
 *            name of the owner of this field panel handler; null if no owner name is
 *            associated with it
 *
 * @param description
 *            description field text; null if the description is initially blank and disabled
 *
 * @param fieldHandler
 *            field handler reference
 ********************************************************************************************
 */
protected void createDescAndDataFieldPanel(final Component fieldPnlHndlrOwner, final JScrollPane tableScrollPane, String ownerName, String description, CcddFieldHandler fieldHandler) {
    this.fieldPnlHndlrOwner = fieldPnlHndlrOwner;
    this.ownerName = ownerName;
    this.dataFieldHandler = fieldHandler;
    // Set the flag to indicate if this input field panel handler is a data table
    isDataTable = this instanceof CcddTableEditorHandler;
    // Create the handler for undoing/redoing data field changes
    undoFieldPnl = undoHandler.new UndoableDataFieldPanel();
    // Set the initial layout manager characteristics
    gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
    // Create an outer panel to put the editor panel in (the border doesn't appear without
    // this) and add the table description text field
    inputPnl = new JPanel(new GridBagLayout());
    // Check if this editor contains a table
    if (tableScrollPane != null) {
        // Define the editor panel to contain the table
        JPanel innerPanel = new JPanel();
        innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
        innerPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
        innerPanel.add(tableScrollPane);
        inputPnl.add(innerPanel, gbc);
    }
    // Create borders for the input fields
    border = BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.GRAY), BorderFactory.createEmptyBorder(ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing()));
    Border emptyBorder = BorderFactory.createEmptyBorder();
    // Create a panel to hold the table's system name, description and, if applicable, message
    // ID information
    JPanel descriptionPnl = new JPanel(new GridBagLayout());
    // Create the description label
    JLabel descriptionLbl = new JLabel("Description");
    descriptionLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
    descriptionLbl.setForeground(ModifiableColorInfo.SPECIAL_LABEL_TEXT.getColor());
    // Check if this editor doesn't contain a table
    if (tableScrollPane == null) {
        gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
        gbc.insets.bottom = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
    }
    // Add the table description label
    gbc.insets.left = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() / 2;
    gbc.insets.right = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() / 2;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridy++;
    descriptionPnl.add(descriptionLbl, gbc);
    // Create the description input field
    descriptionFld = undoHandler.new UndoableTextArea(3, 1);
    descriptionFld.setFont(ModifiableFontInfo.INPUT_TEXT.getFont());
    descriptionFld.setBorder(emptyBorder);
    descriptionFld.setEditable(true);
    descriptionFld.setLineWrap(true);
    descriptionFld.setWrapStyleWord(true);
    descriptionFld.setForeground(ModifiableColorInfo.INPUT_TEXT.getColor());
    descriptionFld.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
    descriptionFld.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
    descScrollPane = new JScrollPane(descriptionFld);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    // Check if the description field is initially disabled
    if (description == null) {
        // Set the description field and description field scroll pane background color to
        // indicate these are disabled
        descriptionFld.setBackground(ModifiableColorInfo.INPUT_DISABLE_BACK.getColor());
        descScrollPane.setBackground(ModifiableColorInfo.INPUT_DISABLE_BACK.getColor());
    } else {
        // Set the description field and description field scroll pane background color to
        // indicate these are enabled, and set the description field text
        descriptionFld.setBackground(ModifiableColorInfo.INPUT_BACK.getColor());
        descScrollPane.setBackground(ModifiableColorInfo.INPUT_BACK.getColor());
        descriptionFld.setText(description);
    }
    // Check if this editor doesn't contain a table
    if (tableScrollPane == null) {
        // Place the description field within a scroll pane and add the field to the editor
        inputPnl.setBorder(BorderFactory.createEtchedBorder());
        descScrollPane.setBorder(border);
        descScrollPane.setMinimumSize(descScrollPane.getPreferredSize());
        gbc.gridy++;
        descriptionPnl.add(descScrollPane, gbc);
    } else // The editor contains a table
    {
        // Place the description field within a scroll pane and add the field to the editor
        inputPnl.setBorder(emptyBorder);
        descriptionFld.setToolTipText(CcddUtilities.wrapText("Table description", ModifiableSizeInfo.MAX_TOOL_TIP_LENGTH.getSize()));
        descScrollPane.setBorder(emptyBorder);
        descScrollPane.setViewportBorder(border);
        descScrollPane.setMinimumSize(descScrollPane.getPreferredSize());
        gbc.gridx++;
        descriptionPnl.add(descScrollPane, gbc);
        gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing();
        gbc.insets.bottom = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing();
    }
    // Add the description panel to the editor
    gbc.gridx = 0;
    gbc.gridy++;
    inputPnl.add(descriptionPnl, gbc);
    // Add the data field panel to the editor
    gbc.gridy++;
    gbc.insets.top = 0;
    gbc.insets.bottom = 0;
    createDataFieldPanel(false);
    // Check if this editor doesn't contain a table
    if (tableScrollPane == null) {
        // Add an invisible component in order to force the description panel and data fields
        // to the top of the panel
        JLabel invisibleLbl = new JLabel("");
        gbc.weighty = 1.0;
        gbc.gridy++;
        inputPnl.add(invisibleLbl, gbc);
        gbc.weighty = 0.0;
        gbc.gridy--;
    }
    // Add a listener for changes in the editor panel's size
    inputPnl.addComponentListener(new ComponentAdapter() {

        /**
         ************************************************************************************
         * Handle resizing of the editor panel
         ************************************************************************************
         */
        @Override
        public void componentResized(ComponentEvent ce) {
            // Create a runnable object to be executed
            SwingUtilities.invokeLater(new Runnable() {

                /**
                 ****************************************************************************
                 * Since the size returned by get___Size() can lag the actual size, use
                 * invokeLater to let the sizes "catch up"
                 ****************************************************************************
                 */
                @Override
                public void run() {
                    // Revalidate to force the editor panel to redraw to the new sizes, which
                    // causes the data fields to be correctly sized so that all of the fields
                    // are visible
                    inputPnl.revalidate();
                }
            });
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) UndoableTextArea(CCDD.CcddUndoHandler.UndoableTextArea) ComponentEvent(java.awt.event.ComponentEvent) UndoableDataFieldPanel(CCDD.CcddUndoHandler.UndoableDataFieldPanel) Border(javax.swing.border.Border) BevelBorder(javax.swing.border.BevelBorder) EtchedBorder(javax.swing.border.EtchedBorder) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 100 with ComponentEvent

use of java.awt.event.ComponentEvent in project Universal-G-Code-Sender by winder.

the class MainWindow method visualizeButtonActionPerformed.

// GEN-LAST:event_browseButtonActionPerformed
private void visualizeButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // Create new object if it is null.
    if (this.vw == null) {
        this.vw = new VisualizerWindow(settings.getVisualizerWindowSettings());
        final MainWindow mw = this;
        vw.addComponentListener(new ComponentListener() {

            @Override
            public void componentResized(ComponentEvent ce) {
                mw.settings.getVisualizerWindowSettings().height = ce.getComponent().getSize().height;
                mw.settings.getVisualizerWindowSettings().width = ce.getComponent().getSize().width;
            }

            @Override
            public void componentMoved(ComponentEvent ce) {
                mw.settings.getVisualizerWindowSettings().xLocation = ce.getComponent().getLocation().x;
                mw.settings.getVisualizerWindowSettings().yLocation = ce.getComponent().getLocation().y;
            }

            @Override
            public void componentShown(ComponentEvent ce) {
            }

            @Override
            public void componentHidden(ComponentEvent ce) {
            }
        });
        setVisualizerFile();
        // Add listener
        this.backend.addControllerListener(vw);
    }
    // Display the form
    java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            vw.setVisible(true);
        }
    });
}
Also used : ComponentListener(java.awt.event.ComponentListener) VisualizerWindow(com.willwinder.universalgcodesender.visualizer.VisualizerWindow) ComponentEvent(java.awt.event.ComponentEvent)

Aggregations

ComponentEvent (java.awt.event.ComponentEvent)120 ComponentAdapter (java.awt.event.ComponentAdapter)97 Dimension (java.awt.Dimension)22 Component (java.awt.Component)18 ActionEvent (java.awt.event.ActionEvent)18 JPanel (javax.swing.JPanel)18 JScrollPane (javax.swing.JScrollPane)16 ComponentListener (java.awt.event.ComponentListener)15 MouseEvent (java.awt.event.MouseEvent)15 JButton (javax.swing.JButton)15 JLabel (javax.swing.JLabel)15 BorderLayout (java.awt.BorderLayout)12 Point (java.awt.Point)12 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 MouseAdapter (java.awt.event.MouseAdapter)11 ActionListener (java.awt.event.ActionListener)10 JTable (javax.swing.JTable)9 AbstractAction (javax.swing.AbstractAction)8 BoxLayout (javax.swing.BoxLayout)8