Example usage for java.awt.event ComponentEvent getComponent

List of usage examples for java.awt.event ComponentEvent getComponent

Introduction

In this page you can find the example usage for java.awt.event ComponentEvent getComponent.

Prototype

public Component getComponent() 

Source Link

Document

Returns the originator of the event.

Usage

From source file:Main.java

@Override
public void componentMoved(ComponentEvent e) {
    System.out.println(e.getComponent().getClass().getName() + " --- Moved");
}

From source file:Main.java

@Override
public void componentResized(ComponentEvent e) {
    System.out.println(e.getComponent().getClass().getName() + " --- Resized ");
}

From source file:Main.java

@Override
public void componentShown(ComponentEvent e) {
    System.out.println(e.getComponent().getClass().getName() + " --- Shown");
}

From source file:events.ComponentEventDemo.java

public void componentHidden(ComponentEvent e) {
    displayMessage(e.getComponent().getClass().getName() + " --- Hidden");
}

From source file:events.ComponentEventDemo.java

public void componentMoved(ComponentEvent e) {
    displayMessage(e.getComponent().getClass().getName() + " --- Moved");
}

From source file:events.ComponentEventDemo.java

public void componentResized(ComponentEvent e) {
    displayMessage(e.getComponent().getClass().getName() + " --- Resized ");
}

From source file:events.ComponentEventDemo.java

public void componentShown(ComponentEvent e) {
    displayMessage(e.getComponent().getClass().getName() + " --- Shown");

}

From source file:ComponentEventDemo.java

public void componentMoved(ComponentEvent e) {
    Component c = e.getComponent();
    displayMessage("componentMoved event from " + c.getClass().getName() + "; new location: "
            + c.getLocation().x + ", " + c.getLocation().y);
}

From source file:ComponentEventDemo.java

public void componentResized(ComponentEvent e) {
    Component c = e.getComponent();
    displayMessage("componentResized event from " + c.getClass().getName() + "; new size: " + c.getSize().width
            + ", " + c.getSize().height);
}

From source file:Main.java

public void componentMoved(ComponentEvent evt) {
    if (locked)/*from   w ww.  j  av  a2s . c  o m*/
        return;
    Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
    int nx = evt.getComponent().getX();
    int ny = evt.getComponent().getY();
    // top
    if (ny < 0 + sd) {
        ny = 0;
    }
    // left
    if (nx < 0 + sd) {
        nx = 0;
    }
    // right
    if (nx > size.getWidth() - evt.getComponent().getWidth() - sd) {
        nx = (int) size.getWidth() - evt.getComponent().getWidth();
    }
    // bottom
    if (ny > size.getHeight() - evt.getComponent().getHeight() - sd) {
        ny = (int) size.getHeight() - evt.getComponent().getHeight();
    }
    locked = true;
    evt.getComponent().setLocation(nx, ny);
    locked = false;
}