當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。