⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e570. determining when a component has been made visible, moved, or resized.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
A component fires a component event after it is made visible, hidden, moved, or resized. 
    // Create a listener for component events
    ComponentListener listener = new ComponentAdapter() {
        // This method is called only if the component was hidden and setVisible(true) was called
        public void componentShown(ComponentEvent evt) {
            // Component is now visible
            Component c = (Component)evt.getSource();
        }
    
        // This method is called only if the component was visible and setVisible(false) was called
        public void componentHidden(ComponentEvent evt) {
            // Component is now hidden
            Component c = (Component)evt.getSource();
        }
    
        // This method is called after the component's location within its container changes
        public void componentMoved(ComponentEvent evt) {
            Component c = (Component)evt.getSource();
    
            // Get new location
            Point newLoc = c.getLocation();
        }
    
        // This method is called after the component's size changes
        public void componentResized(ComponentEvent evt) {
            Component c = (Component)evt.getSource();
    
            // Get new size
            Dimension newSize = c.getSize();
        }
    };
    
    // Register the listener with the component
    component.addComponentListener(listener);

 Related Examples 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -