当前位置: 首页>>代码示例>>Java>>正文


Java ComponentEvent.getComponent方法代码示例

本文整理汇总了Java中java.awt.event.ComponentEvent.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentEvent.getComponent方法的具体用法?Java ComponentEvent.getComponent怎么用?Java ComponentEvent.getComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.event.ComponentEvent的用法示例。


在下文中一共展示了ComponentEvent.getComponent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: componentShown

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
 * May be called for either component or horizontal scrollbar.
 */
public @Override void componentShown(ComponentEvent e) {
    // Called when horizontal scrollbar gets visible
    // (but the same listener added to component as well so must check first)
    // Check whether present caret position will not get hidden
    // under horizontal scrollbar and if so scroll the view
    Component hScrollBar = e.getComponent();
    if (hScrollBar != component) { // really called for horizontal scrollbar
        Component scrollPane = hScrollBar.getParent();
        if (caretBounds != null && scrollPane instanceof JScrollPane) {
            Rectangle viewRect = ((JScrollPane)scrollPane).getViewport().getViewRect();
            Rectangle hScrollBarRect = new Rectangle(
                    viewRect.x,
                    viewRect.y + viewRect.height,
                    hScrollBar.getWidth(),
                    hScrollBar.getHeight()
                    );
            if (hScrollBarRect.intersects(caretBounds)) {
                // Update caret's position
                dispatchUpdate(true); // should be visible so scroll the view
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BaseCaret.java

示例2: componentResized

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
 * May be called for either component or horizontal scrollbar.
 */
public @Override void componentResized(ComponentEvent e) {
    Component c = e.getComponent();
    if (c == component) { // called for component
        // In case the caretBounds are still null
        // (component not connected to hierarchy yet or it has zero size
        // so the modelToView() returned null) re-attempt to compute the bounds.
        CaretItem caret = getLastCaretItem();
        if (caret.getCaretBounds() == null) {
            dispatchUpdate(false);
            resetBlink();
            if (caret.getCaretBounds() != null) { // detach the listener - no longer necessary
                c.removeComponentListener(this);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:EditorCaret.java

示例3: eventDispatched

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
     * Called when event is dispatched. WindowEvent.WINDOW_OPENED events for
     * JFrames are processed here to loadSettings.
     *
     * @param evt the AWTEvent. Only WINDOW_OPENED events are processed to
     * loadSettings
     * @see #loadSettings
     */
    @Override
    public void eventDispatched(AWTEvent evt) {
        try {
            if (evt.getID() == WindowEvent.WINDOW_OPENED) {
                ComponentEvent cev = (ComponentEvent) evt;
                if (cev.getComponent() instanceof JFrame) {
//                    log.info("event: " + evt);
                    JFrame frame = (JFrame) cev.getComponent();
                    loadSettings(frame);
                }
            }
        } catch (Exception ex) {
            log.warning(ex.toString());
        }
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:24,代码来源:WindowSaver.java

示例4: componentResized

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
 * May be called for either component or horizontal scrollbar.
 */
public @Override void componentResized(ComponentEvent e) {
    Component c = e.getComponent();
    if (c == component) { // called for component
        // In case the caretBounds are still null
        // (component not connected to hierarchy yet or it has zero size
        // so the modelToView() returned null) re-attempt to compute the bounds.
        if (caretBounds == null) {
            dispatchUpdate(true);
            if (caretBounds != null) { // detach the listener - no longer necessary
                c.removeComponentListener(this);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:BaseCaret.java

示例5: componentShown

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
         * May be called for either component or horizontal scrollbar.
         */
        public @Override void componentShown(ComponentEvent e) {
            // Called when horizontal scrollbar gets visible
            // (but the same listener added to component as well so must check first)
            // Check whether present caret position will not get hidden
            // under horizontal scrollbar and if so scroll the view
            Component hScrollBar = e.getComponent();
/* The following should already be handled in update()            
            if (hScrollBar != component) { // really called for horizontal scrollbar
                Component scrollPane = hScrollBar.getParent();
                boolean needsScroll = false;
                List<CaretInfo> sortedCarets = getSortedCarets();
                for (CaretInfo caret : sortedCarets) { // TODO This is wrong, but a quick prototype
                    CaretItem caretItem = caret.getCaretItem();
                    if (caretItem.getCaretBounds() != null && scrollPane instanceof JScrollPane) {
                        Rectangle viewRect = ((JScrollPane)scrollPane).getViewport().getViewRect();
                        Rectangle hScrollBarRect = new Rectangle(
                                viewRect.x,
                                viewRect.y + viewRect.height,
                                hScrollBar.getWidth(),
                                hScrollBar.getHeight()
                                );
                        if (hScrollBarRect.intersects(caretItem.getCaretBounds())) {
                            // Update caret's position
                            needsScroll = true;
                        }
                    }
                }
                if (needsScroll) {
                    resetBlink();
                    dispatchUpdate(false);
                }
            }
*/
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:EditorCaret.java

示例6: componentShown

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentShown(ComponentEvent e) {
    JMenu menu = (JMenu) e.getComponent();
    String containerCtx = getContainerContext(menu);
    System.err.println("ComponentShown: Menu" + containerCtx + " - " + menu);
    populateMenu(containerCtx, menu);
    getEngine().notifyMenuShown (containerCtx, menu);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:AbstractMenuFactory.java

示例7: componentShown

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
@Override
public void componentShown(ComponentEvent e) {
    JFrame frame = (JFrame) e.getComponent();

    runActualTest(device, latch, frame, result);

    frame.setVisible(false);
    frame.dispose();
    latch.countDown();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:bug8071705.java

示例8: getImageCanvas

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public ImageCanvas getImageCanvas(ComponentEvent e) {
	Component component = e.getComponent();
	return component instanceof ImageCanvas ? (ImageCanvas)component :
		(component instanceof ImageWindow ? ((ImageWindow)component).getCanvas() : null);
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:6,代码来源:Interactive_HWatershed.java

示例9: componentHidden

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentHidden(ComponentEvent e) {
    JToolBar jtb = (JToolBar) e.getComponent();
    String ctx = (String) jtb.getClientProperty(KEY_CONTAINERCTX);
    depopulateToolbar (ctx, jtb);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:AbstractToolbarFactory.java

示例10: componentShown

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentShown(ComponentEvent e) {
    JToolBar jtb = (JToolBar) e.getComponent();
    String ctx = (String) jtb.getClientProperty(KEY_CONTAINERCTX);
    populateToolbar (ctx, jtb);
    getEngine().notifyToolbarShown(ctx, jtb);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:AbstractToolbarFactory.java

示例11: componentHidden

import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentHidden(ComponentEvent e) {
    JMenu menu = (JMenu) e.getComponent();
    String containerContext = getContainerContext(menu);
    getEngine().notifyMenuHidden (containerContext, menu);
    depopulateMenu (containerContext, menu);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:AbstractMenuFactory.java


注:本文中的java.awt.event.ComponentEvent.getComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。