Search in sources :

Example 66 with ComponentEvent

use of java.awt.event.ComponentEvent in project omegat by omegat-org.

the class StaticUIUtils method persistGeometry.

public static void persistGeometry(Window window, String key, Runnable extraProcessing) {
    getStoredRectangle(key).ifPresent(window::setBounds);
    String xKey = key + "_x";
    String yKey = key + "_y";
    String widthKey = key + "_width";
    String heightKey = key + "_height";
    Timer timer = new Timer(500, e -> {
        Rectangle bounds = window.getBounds();
        Preferences.setPreference(xKey, bounds.x);
        Preferences.setPreference(yKey, bounds.y);
        Preferences.setPreference(widthKey, bounds.width);
        Preferences.setPreference(heightKey, bounds.height);
        if (extraProcessing != null) {
            extraProcessing.run();
        }
    });
    timer.setRepeats(false);
    window.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentMoved(ComponentEvent e) {
            timer.restart();
        }

        @Override
        public void componentResized(ComponentEvent e) {
            timer.restart();
        }
    });
}
Also used : Timer(javax.swing.Timer) Rectangle(java.awt.Rectangle) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 67 with ComponentEvent

use of java.awt.event.ComponentEvent in project omegat by omegat-org.

the class EditorController method createUI.

private void createUI() {
    pane = new DockablePanel("EDITOR", " ", false);
    pane.setComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
    pane.setMinimumSize(new Dimension(100, 100));
    pane.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            updateTitle();
        }
    });
    scrollPane = new JScrollPane(editor);
    Border panelBorder = UIManager.getBorder("OmegaTDockablePanel.border");
    if (panelBorder != null) {
        scrollPane.setBorder(panelBorder);
    }
    Border viewportBorder = UIManager.getBorder("OmegaTDockablePanelViewport.border");
    if (viewportBorder != null) {
        scrollPane.setViewportBorder(viewportBorder);
    }
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.getVerticalScrollBar().addAdjustmentListener(scrollListener);
    pane.setLayout(new BorderLayout());
    pane.add(scrollPane, BorderLayout.CENTER);
    mw.addDockable(pane);
    DockingDesktop desktop = UIDesignManager.getDesktop(pane);
    if (desktop != null) {
        desktop.addDockableSelectionListener(e -> dockableSelected = pane == e.getSelectedDockable());
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) BorderLayout(java.awt.BorderLayout) DockingDesktop(com.vlsolutions.swing.docking.DockingDesktop) Dimension(java.awt.Dimension) ComponentEvent(java.awt.event.ComponentEvent) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder) ComponentAdapter(java.awt.event.ComponentAdapter) DockablePanel(org.omegat.gui.main.DockablePanel)

Example 68 with ComponentEvent

use of java.awt.event.ComponentEvent in project omegat by omegat-org.

the class PreferencesWindowController method show.

@SuppressWarnings("serial")
public void show(Window parent, Class<? extends IPreferencesController> initialSelection) {
    dialog = new JDialog();
    dialog.setTitle(OStrings.getString("PREFERENCES_TITLE_NO_SELECTION"));
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setModal(true);
    StaticUIUtils.setWindowIcon(dialog);
    outerPanel = new PreferencePanel();
    innerPanel = new PreferenceViewSelectorPanel();
    outerPanel.prefsViewPanel.add(innerPanel, BorderLayout.CENTER);
    dialog.getContentPane().add(outerPanel);
    overlay = new HighlightablePanel(dialog.getRootPane(), innerPanel.selectedPrefsScrollPane);
    // Prevent ugly white viewport background with GTK LAF
    innerPanel.selectedPrefsScrollPane.getViewport().setOpaque(false);
    innerPanel.selectedPrefsScrollPane.setBackground(innerPanel.getBackground());
    innerPanel.searchTextField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            SwingUtilities.invokeLater(PreferencesWindowController.this::searchAndFilterTree);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            SwingUtilities.invokeLater(PreferencesWindowController.this::searchAndFilterTree);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            SwingUtilities.invokeLater(PreferencesWindowController.this::searchAndFilterTree);
        }
    });
    innerPanel.searchTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
                innerPanel.availablePrefsTree.getActionForKeyStroke(KeyStroke.getKeyStrokeForEvent(e)).actionPerformed(new ActionEvent(innerPanel.availablePrefsTree, 0, null));
                innerPanel.availablePrefsTree.requestFocusInWindow();
                e.consume();
            }
        }
    });
    innerPanel.searchTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            innerPanel.searchTextField.selectAll();
            searchCurrentView();
            preloadGuis();
        }
    });
    innerPanel.clearButton.addActionListener(e -> {
        innerPanel.searchTextField.clear();
    });
    innerPanel.availablePrefsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultMutableTreeNode root = createNodeTree();
    walkTree(root, node -> {
        IPreferencesController view = (IPreferencesController) node.getUserObject();
        if (view != null) {
            view.addFurtherActionListener(this);
        }
    });
    innerPanel.availablePrefsTree.setModel(new DefaultTreeModel(root));
    innerPanel.availablePrefsTree.addTreeSelectionListener(e -> {
        handleViewSelection(e);
        updateTitle();
    });
    innerPanel.availablePrefsTree.addTreeExpansionListener(new TreeExpansionListener() {

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            SwingUtilities.invokeLater(PreferencesWindowController.this::adjustTreeSize);
        }

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        }
    });
    innerPanel.selectedPrefsScrollPane.getViewport().setBackground(innerPanel.getBackground());
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) innerPanel.availablePrefsTree.getCellRenderer();
    renderer.setIcon(null);
    renderer.setLeafIcon(null);
    renderer.setOpenIcon(null);
    renderer.setClosedIcon(null);
    renderer.setDisabledIcon(null);
    outerPanel.okButton.addActionListener(e -> {
        if (currentView == null || currentView.validate()) {
            new SwingWorker<Void, Void>() {

                @Override
                protected Void doInBackground() throws Exception {
                    doSave();
                    return null;
                }

                @Override
                protected void done() {
                    if (getIsReloadRequired()) {
                        SwingUtilities.invokeLater(ProjectUICommands::promptReload);
                    }
                }
            }.execute();
            StaticUIUtils.closeWindowByEvent(dialog);
        }
    });
    outerPanel.cancelButton.addActionListener(e -> StaticUIUtils.closeWindowByEvent(dialog));
    // Hide undo, reset buttons on outer panel
    outerPanel.undoButton.setVisible(false);
    outerPanel.resetButton.setVisible(false);
    // Use ones on inner panel to indicate that actions are view-specific
    innerPanel.undoButton.addActionListener(e -> currentView.undoChanges());
    innerPanel.resetButton.addActionListener(e -> currentView.restoreDefaults());
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowOpened(WindowEvent e) {
            walkTree(root, node -> {
                // Start with tree fully expanded
                if (node.getChildCount() > 0) {
                    innerPanel.availablePrefsTree.expandPath(new TreePath(node.getPath()));
                }
            });
            SwingUtilities.invokeLater(() -> {
                if (initialSelection != null) {
                    selectView(initialSelection);
                }
            });
        }
    });
    innerPanel.availablePrefsScrollPane.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            SwingUtilities.invokeLater(PreferencesWindowController.this::adjustTreeSize);
        }
    });
    ActionMap actionMap = innerPanel.getActionMap();
    InputMap inputMap = innerPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    actionMap.put(ACTION_KEY_NEW_SEARCH, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            innerPanel.searchTextField.requestFocusInWindow();
            innerPanel.searchTextField.selectAll();
        }
    });
    KeyStroke searchKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, Java8Compat.getMenuShortcutKeyMaskEx());
    inputMap.put(searchKeyStroke, ACTION_KEY_NEW_SEARCH);
    actionMap.put(ACTION_KEY_CLEAR_OR_CLOSE, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!innerPanel.searchTextField.isEmpty()) {
                // Move focus away from search field
                innerPanel.availablePrefsTree.requestFocusInWindow();
                innerPanel.clearButton.doClick();
            } else {
                StaticUIUtils.closeWindowByEvent(dialog);
            }
        }
    });
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_KEY_CLEAR_OR_CLOSE);
    // Don't let Enter close the dialog
    innerPanel.searchTextField.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ACTION_KEY_DO_SEARCH);
    innerPanel.searchTextField.getActionMap().put(ACTION_KEY_DO_SEARCH, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            searchCurrentView();
        }
    });
    String searchKeyText = StaticUIUtils.getKeyStrokeText(searchKeyStroke);
    innerPanel.searchTextField.setHintText(OStrings.getString("PREFERENCES_SEARCH_HINT", searchKeyText));
    // Set initial state
    searchAndFilterTree();
    adjustTreeSize();
    dialog.getRootPane().setDefaultButton(outerPanel.okButton);
    dialog.setPreferredSize(new Dimension(800, 500));
    dialog.pack();
    // Prevent search field from getting initial focus
    innerPanel.availablePrefsTree.requestFocusInWindow();
    dialog.setLocationRelativeTo(parent);
    dialog.setVisible(true);
}
Also used : Color(java.awt.Color) UIManager(javax.swing.UIManager) ExternalFinderPreferencesController(org.omegat.externalfinder.gui.ExternalFinderPreferencesController) Enumeration(java.util.Enumeration) StaticUIUtils(org.omegat.util.gui.StaticUIUtils) RepositoriesCredentialsController(org.omegat.core.team2.gui.RepositoriesCredentialsController) CustomColorSelectionController(org.omegat.gui.preferences.view.CustomColorSelectionController) StringUtil(org.omegat.util.StringUtil) MouseWheelEvent(java.awt.event.MouseWheelEvent) Map(java.util.Map) SwingWorker(javax.swing.SwingWorker) CharTableAutoCompleterOptionsController(org.omegat.gui.preferences.view.CharTableAutoCompleterOptionsController) KeyStroke(javax.swing.KeyStroke) TreePath(javax.swing.tree.TreePath) FiltersCustomizerController(org.omegat.gui.filters2.FiltersCustomizerController) UserPassController(org.omegat.gui.preferences.view.UserPassController) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) Component(java.awt.Component) InvocationTargetException(java.lang.reflect.InvocationTargetException) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractAction(javax.swing.AbstractAction) FontSelectionController(org.omegat.gui.preferences.view.FontSelectionController) LanguageToolConfigurationController(org.omegat.gui.preferences.view.LanguageToolConfigurationController) AutotextAutoCompleterOptionsController(org.omegat.gui.preferences.view.AutotextAutoCompleterOptionsController) BasicStroke(java.awt.BasicStroke) SpellcheckerConfigurationController(org.omegat.gui.preferences.view.SpellcheckerConfigurationController) GlossaryPreferencesController(org.omegat.gui.preferences.view.GlossaryPreferencesController) TeamOptionsController(org.omegat.gui.preferences.view.TeamOptionsController) TreeExpansionListener(javax.swing.event.TreeExpansionListener) Preferences(org.omegat.util.Preferences) JPanel(javax.swing.JPanel) WindowConstants(javax.swing.WindowConstants) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) ProjectUICommands(org.omegat.gui.main.ProjectUICommands) KeyAdapter(java.awt.event.KeyAdapter) ArrayList(java.util.ArrayList) MachineTranslationPreferencesController(org.omegat.gui.preferences.view.MachineTranslationPreferencesController) BiConsumer(java.util.function.BiConsumer) Container(java.awt.Container) DocumentEvent(javax.swing.event.DocumentEvent) TMMatchesPreferencesController(org.omegat.gui.preferences.view.TMMatchesPreferencesController) ActionMap(javax.swing.ActionMap) GeneralOptionsController(org.omegat.gui.preferences.view.GeneralOptionsController) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) JRootPane(javax.swing.JRootPane) Window(java.awt.Window) TreeSelectionModel(javax.swing.tree.TreeSelectionModel) MouseEvent(java.awt.event.MouseEvent) SaveOptionsController(org.omegat.gui.preferences.view.SaveOptionsController) Java8Compat(org.omegat.util.Java8Compat) JScrollBar(javax.swing.JScrollBar) JLayeredPane(javax.swing.JLayeredPane) AutoCompleterController(org.omegat.gui.preferences.view.AutoCompleterController) DocumentListener(javax.swing.event.DocumentListener) JDialog(javax.swing.JDialog) Area(java.awt.geom.Area) HistoryAutoCompleterOptionsController(org.omegat.gui.preferences.view.HistoryAutoCompleterOptionsController) Point(java.awt.Point) RenderingHints(java.awt.RenderingHints) SegmentationCustomizerController(org.omegat.gui.segmentation.SegmentationCustomizerController) ComponentListener(java.awt.event.ComponentListener) Core(org.omegat.core.Core) MouseAdapter(java.awt.event.MouseAdapter) BorderLayout(java.awt.BorderLayout) Method(java.lang.reflect.Method) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Shape(java.awt.Shape) Predicate(java.util.function.Predicate) ComponentEvent(java.awt.event.ComponentEvent) Logger(java.util.logging.Logger) WindowEvent(java.awt.event.WindowEvent) RoundRectangle2D(java.awt.geom.RoundRectangle2D) DictionaryPreferencesController(org.omegat.gui.preferences.view.DictionaryPreferencesController) Objects(java.util.Objects) Dimension(java.awt.Dimension) List(java.util.List) PluginsPreferencesController(org.omegat.gui.preferences.view.PluginsPreferencesController) Graphics(java.awt.Graphics) VersionCheckPreferencesController(org.omegat.gui.preferences.view.VersionCheckPreferencesController) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Rectangle(java.awt.Rectangle) TreeNode(javax.swing.tree.TreeNode) HashMap(java.util.HashMap) Function(java.util.function.Function) ViewOptionsController(org.omegat.gui.preferences.view.ViewOptionsController) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) SecureStoreController(org.omegat.gui.preferences.view.SecureStoreController) Level(java.util.logging.Level) FocusAdapter(java.awt.event.FocusAdapter) SwingUtilities(javax.swing.SwingUtilities) Graphics2D(java.awt.Graphics2D) FurtherActionListener(org.omegat.gui.preferences.IPreferencesController.FurtherActionListener) OStrings(org.omegat.util.OStrings) JComponent(javax.swing.JComponent) GlossaryAutoCompleterOptionsController(org.omegat.gui.preferences.view.GlossaryAutoCompleterOptionsController) ActionEvent(java.awt.event.ActionEvent) ComponentAdapter(java.awt.event.ComponentAdapter) Consumer(java.util.function.Consumer) FocusEvent(java.awt.event.FocusEvent) EditingBehaviorController(org.omegat.gui.preferences.view.EditingBehaviorController) TagProcessingOptionsController(org.omegat.gui.preferences.view.TagProcessingOptionsController) AppearanceController(org.omegat.gui.preferences.view.AppearanceController) InputMap(javax.swing.InputMap) DocumentListener(javax.swing.event.DocumentListener) FocusAdapter(java.awt.event.FocusAdapter) TreeExpansionListener(javax.swing.event.TreeExpansionListener) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) WindowAdapter(java.awt.event.WindowAdapter) FocusEvent(java.awt.event.FocusEvent) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) KeyEvent(java.awt.event.KeyEvent) AbstractAction(javax.swing.AbstractAction) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) ComponentAdapter(java.awt.event.ComponentAdapter) ActionMap(javax.swing.ActionMap) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Dimension(java.awt.Dimension) DocumentEvent(javax.swing.event.DocumentEvent) InvocationTargetException(java.lang.reflect.InvocationTargetException) TreePath(javax.swing.tree.TreePath) WindowEvent(java.awt.event.WindowEvent) KeyStroke(javax.swing.KeyStroke) InputMap(javax.swing.InputMap) ComponentEvent(java.awt.event.ComponentEvent) JDialog(javax.swing.JDialog)

Example 69 with ComponentEvent

use of java.awt.event.ComponentEvent in project jna by java-native-access.

the class BalloonTipManager method getBalloonTip.

/**
   * Returns the popup window of the balloon tip.
   * @param owner the owner component for the balloon tip
   * @param content the text string to display in the balloon tip
   * @param x the x coordinate for the origin for the balloon tip in relation
   * to the owner component
   * @param y the y coordinate for the origin for the balloon tip in relation
   * to the owner component
   * @param position the position for the balloon; either above or below the
     * owner component
   * @param duration the duration in milliseconds to display balloon tip
   * @param bordercolor the background color for the balloon tip
   * @param backgroundcolor the border color for the balloon tip
   * @param textcolor the text color for the balloon tip
   * @return the popup window of the balloon tip
   */
public static Popup getBalloonTip(final Component owner, final String content, int x, int y, final Integer duration, final Color bordercolor, final Color backgroundcolor, final Color textcolor) {
    final Point origin = owner == null ? new Point(0, 0) : owner.getLocationOnScreen();
    final Window parent = owner != null ? SwingUtilities.getWindowAncestor(owner) : null;
    final String text = content != null ? content : "";
    final Integer timerDuration = duration != null ? duration : 10000;
    origin.translate(x, y);
    vpos = VPOS_BELOW;
    hpos = HPOS_LEFT;
    return new Popup() {

        private BalloonTip bt = null;

        final ComponentEar componentEar = new ComponentEar();

        final MouseEar mouseEar = new MouseEar();

        final FocusEar focusEar = new FocusEar();

        /*
       * (non-Javadoc)
       * @see javax.swing.Popup#show()
       */
        public void show() {
            hidePopupTimer = new Timer(timerDuration, new TimerAction());
            bt = new BalloonTip(parent, text, origin, bordercolor, backgroundcolor, textcolor);
            bt.pack();
            Point pt = new Point(origin);
            pt.translate(10, owner.getHeight());
            bt.setLocation(getAdjustedOrigin(pt));
            bt.setWindowMask();
            bt.setVisible(true);
            owner.addFocusListener(focusEar);
            owner.addMouseListener(mouseEar);
            parent.addMouseListener(mouseEar);
            parent.addComponentListener(componentEar);
            hidePopupTimer.start();
            isShowing = true;
        }

        /*
       * (non-Javadoc)
       * @see javax.swing.Popup#hide()
       */
        public void hide() {
            if (bt != null) {
                isShowing = false;
                hidePopupTimer.stop();
                parent.removeComponentListener(componentEar);
                parent.removeMouseListener(mouseEar);
                owner.removeMouseListener(mouseEar);
                owner.removeFocusListener(focusEar);
                bt.setVisible(false);
                bt.dispose();
            }
        }

        /*
       * Adjust the location of the balloon popup so that is drawn completely
       * on the screen and specify the orientation.
       */
        private Point getAdjustedOrigin(Point pt) {
            Point ret = new Point(pt.x, pt.y);
            GraphicsConfiguration gc = owner.getGraphicsConfiguration();
            Rectangle sBounds = gc.getBounds();
            Insets sInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
            sBounds.x += sInsets.left;
            sBounds.y += sInsets.top;
            sBounds.width -= (sInsets.left + sInsets.right);
            sBounds.height -= (sInsets.top + sInsets.bottom);
            if (ret.x < sBounds.x) {
                ret.x = sBounds.x;
            } else if (ret.x - sBounds.x + bt.getWidth() > sBounds.width) {
                ret.x = owner.getLocationOnScreen().x - bt.getWidth() + 43;
            }
            if (ret.x >= pt.x) {
                hpos = HPOS_LEFT;
            } else {
                hpos = HPOS_RIGHT;
            }
            if (ret.y < sBounds.y) {
                ret.y = sBounds.y;
            } else if (ret.y - sBounds.y + bt.getHeight() > sBounds.height) {
                ret.y = owner.getLocationOnScreen().y - bt.getHeight();
            }
            if (ret.y >= pt.y) {
                vpos = VPOS_BELOW;
            } else {
                vpos = VPOS_ABOVE;
            }
            return ret;
        }

        /*
       * This class handles actions from the balloon tip timer.
       */
        @SuppressWarnings("serial")
        final class TimerAction extends AbstractAction {

            /*
         * (non-Javadoc)
         * @see java.awt.event.ActionListener#actionPerformed(
         * java.awt.event.ActionEvent)
         */
            public void actionPerformed(ActionEvent e) {
                hide();
            }
        }

        /*
       * This class handles events spawned from moving the component.
       */
        final class ComponentEar extends ComponentAdapter {

            /*
         * (non-Javadoc)
         * @see java.awt.event.ComponentAdapter#componentMoved(
         * java.awt.event.ComponentEvent)
         */
            public void componentMoved(ComponentEvent e) {
                hide();
            }
        }

        /*
       * This class handles events spawned when a mouse button is pressed.
       */
        final class MouseEar extends MouseAdapter {

            /*
         * (non-Javadoc)
         * @see java.awt.event.MouseAdapter#mousePressed(
         * java.awt.event.MouseEvent)
         */
            public void mousePressed(MouseEvent e) {
                hide();
            }
        }

        /*
       * This class handles events spawned when the component loses focus.
       */
        final class FocusEar extends FocusAdapter {

            /*
         * (non-Javadoc)
         * @see java.awt.event.FocusAdapter#focusLost(
         * java.awt.event.FocusEvent)
         */
            public void focusLost(FocusEvent e) {
                hide();
            }
        }
    };
}
Also used : Window(java.awt.Window) JWindow(javax.swing.JWindow) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) Rectangle(java.awt.Rectangle) Point(java.awt.Point) FocusEvent(java.awt.event.FocusEvent) GraphicsConfiguration(java.awt.GraphicsConfiguration) Timer(javax.swing.Timer) Popup(javax.swing.Popup) ComponentEvent(java.awt.event.ComponentEvent)

Example 70 with ComponentEvent

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

the class ThreadsSegment method setCenterContent.

@Override
protected void setCenterContent(@NotNull JPanel panel) {
    JLayeredPane centerPane = new JBLayeredPane();
    JScrollPane scrollPane = new JBScrollPane(mThreadsList);
    centerPane.add(scrollPane);
    centerPane.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);
                }
            }
        }
    });
    panel.add(centerPane, BorderLayout.CENTER);
}
Also used : JBLayeredPane(com.intellij.ui.components.JBLayeredPane) ComponentEvent(java.awt.event.ComponentEvent) LegendComponent(com.android.tools.adtui.LegendComponent) AnimatedComponent(com.android.tools.adtui.AnimatedComponent) JBScrollPane(com.intellij.ui.components.JBScrollPane) 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