Search in sources :

Example 71 with ComponentEvent

use of java.awt.event.ComponentEvent in project android by JetBrains.

the class DataReducerVisualTest method createLayeredSelection.

private JLayeredPane createLayeredSelection(JComponent host) {
    JBLayeredPane layeredPane = new JBLayeredPane();
    layeredPane.add(host);
    layeredPane.add(mySelection);
    layeredPane.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            JLayeredPane host = (JLayeredPane) e.getComponent();
            if (host != null) {
                Dimension dim = host.getSize();
                for (Component c : host.getComponents()) {
                    c.setBounds(0, 0, dim.width, dim.height);
                }
            }
        }
    });
    return layeredPane;
}
Also used : JBLayeredPane(com.intellij.ui.components.JBLayeredPane) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 72 with ComponentEvent

use of java.awt.event.ComponentEvent in project intellij-community by JetBrains.

the class WelcomeBalloonLayoutImpl method addToPopup.

private void addToPopup(@NotNull BalloonImpl balloon, @NotNull BalloonLayoutData layoutData) {
    layoutData.doLayout = this::layoutPopup;
    layoutData.configuration = layoutData.configuration.replace(JBUI.scale(myPopupBalloon == null ? 7 : 5), JBUI.scale(12));
    if (myPopupBalloon == null) {
        final JScrollPane pane = NotificationsManagerImpl.createBalloonScrollPane(myBalloonPanel, true);
        pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        pane.getVerticalScrollBar().addComponentListener(new ComponentAdapter() {

            @Override
            public void componentShown(ComponentEvent e) {
                pane.setBorder(IdeBorderFactory.createEmptyBorder(SystemInfo.isMac ? 2 : 1, 0, 1, 1));
            }

            @Override
            public void componentHidden(ComponentEvent e) {
                pane.setBorder(IdeBorderFactory.createEmptyBorder());
            }
        });
        myPopupBalloon = new BalloonImpl(pane, BORDER_COLOR, new Insets(0, 0, 0, 0), FILL_COLOR, true, false, false, true, false, true, 0, false, false, null, false, 0, 0, 0, 0, false, null, null, false, false, false, null, false, null, -1);
        myPopupBalloon.setAnimationEnabled(false);
        myPopupBalloon.setShadowBorderProvider(new NotificationBalloonShadowBorderProvider(FILL_COLOR, BORDER_COLOR));
        myPopupBalloon.setHideListener(() -> myPopupBalloon.getComponent().setVisible(false));
        myPopupBalloon.setActionProvider(new BalloonImpl.ActionProvider() {

            private BalloonImpl.ActionButton myAction;

            @NotNull
            @Override
            public List<BalloonImpl.ActionButton> createActions() {
                myAction = myPopupBalloon.new ActionButton(AllIcons.Ide.Notification.Close, null, null, com.intellij.util.Consumer.EMPTY_CONSUMER);
                return Collections.singletonList(myAction);
            }

            @Override
            public void layout(@NotNull Rectangle bounds) {
                myAction.setBounds(0, 0, 0, 0);
            }
        });
    }
    myBalloonPanel.add(balloon.getContent());
    balloon.getContent().putClientProperty(TYPE_KEY, layoutData.type);
    Disposer.register(balloon, new Disposable() {

        @Override
        public void dispose() {
            myBalloons.remove(balloon);
            myBalloonPanel.remove(balloon.getContent());
            updatePopup();
        }
    });
    myBalloons.add(balloon);
    updatePopup();
}
Also used : Disposable(com.intellij.openapi.Disposable) NotNull(org.jetbrains.annotations.NotNull) ArrayList(java.util.ArrayList) List(java.util.List) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 73 with ComponentEvent

use of java.awt.event.ComponentEvent in project intellij-community by JetBrains.

the class ProgressStripeIcon method generateIcon.

@NotNull
public static AsyncProcessIcon generateIcon(@NotNull JComponent component) {
    List<Icon> result = ContainerUtil.newArrayList();
    if (UIUtil.isUnderAquaBasedLookAndFeel() && !UIUtil.isUnderDarcula()) {
        for (int i = 0; i < 2 * JBUI.scale(GradientIcon.GRADIENT); i += JBUI.scale(TRANSLATE)) {
            result.add(new GradientIcon(component, i));
        }
    } else {
        for (int i = 0; i < JBUI.scale(StripeIcon.WIDTH); i += JBUI.scale(TRANSLATE)) {
            result.add(new StripeIcon(component, i));
        }
        result = ContainerUtil.reverse(result);
    }
    Icon passive = result.get(0);
    AsyncProcessIcon icon = new AsyncProcessIcon("ProgressWithStripes", result.toArray(new Icon[result.size()]), passive) {

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(component.getWidth(), passive.getIconHeight());
        }
    };
    component.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            super.componentResized(e);
            icon.revalidate();
        }
    });
    return icon;
}
Also used : AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter) NotNull(org.jetbrains.annotations.NotNull)

Example 74 with ComponentEvent

use of java.awt.event.ComponentEvent in project intellij-community by JetBrains.

the class FacetStructureConfigurable method initTree.

@Override
protected void initTree() {
    super.initTree();
    if (!myTreeWasInitialized) {
        myTreeWasInitialized = true;
        final FacetsTreeCellRenderer separatorRenderer = new FacetsTreeCellRenderer();
        final TreeCellRenderer oldRenderer = myTree.getCellRenderer();
        myTree.setCellRenderer(new TreeCellRenderer() {

            @Override
            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
                if (value instanceof MyNode && ((MyNode) value).getConfigurable() instanceof FrameworkDetectionConfigurable) {
                    return separatorRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
                }
                return oldRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
            }
        });
        myTree.addComponentListener(new ComponentAdapter() {

            @Override
            public void componentResized(ComponentEvent e) {
                revalidateTree();
            }

            @Override
            public void componentMoved(ComponentEvent e) {
                revalidateTree();
            }

            @Override
            public void componentShown(ComponentEvent e) {
                revalidateTree();
            }
        });
    }
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) ComponentEvent(java.awt.event.ComponentEvent) DetailsComponent(com.intellij.openapi.ui.DetailsComponent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 75 with ComponentEvent

use of java.awt.event.ComponentEvent in project pcgen by PCGen.

the class PCGenFrame method initSettings.

private void initSettings() {
    final UIPropertyContext frameContext = UIPropertyContext.createContext("PCGenFrame");
    Rectangle screenBounds = getGraphicsConfiguration().getBounds();
    //this is the default frame dimensions
    setSize(1060, 725);
    //center the frame
    setLocationRelativeTo(null);
    if (!screenBounds.contains(getBounds())) {
        setSize((5 * screenBounds.width) / 6, (5 * screenBounds.height) / 6);
        //center the frame
        setLocationRelativeTo(null);
    }
    Rectangle frameBounds = getBounds();
    frameBounds.x = frameContext.initInt("bounds.x", frameBounds.x);
    frameBounds.y = frameContext.initInt("bounds.y", frameBounds.x);
    frameBounds.width = frameContext.initInt("bounds.width", frameBounds.width);
    frameBounds.height = frameContext.initInt("bounds.height", frameBounds.height);
    int extendedState = frameContext.initInt("extendedState", NORMAL);
    if (extendedState == ICONIFIED) {
        extendedState = NORMAL;
        frameContext.setInt("extendedState", NORMAL);
    }
    setExtendedState(extendedState);
    if (checkBounds(frameBounds)) {
        setBounds(frameBounds);
    }
    addPropertyChangeListener("extendedState", frameContext);
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            updateBounds();
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            updateBounds();
        }

        private void updateBounds() {
            Rectangle bounds = getBounds();
            frameContext.setInt("bounds.x", bounds.x);
            frameContext.setInt("bounds.y", bounds.y);
            frameContext.setInt("bounds.width", bounds.width);
            frameContext.setInt("bounds.height", bounds.height);
        }
    });
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            PCGenUIManager.closePCGen();
        }
    });
}
Also used : WindowEvent(java.awt.event.WindowEvent) Rectangle(java.awt.Rectangle) WindowAdapter(java.awt.event.WindowAdapter) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

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