Example usage for javax.swing JComponent setLocation

List of usage examples for javax.swing JComponent setLocation

Introduction

In this page you can find the example usage for javax.swing JComponent setLocation.

Prototype

public void setLocation(int x, int y) 

Source Link

Document

Moves this component to a new location.

Usage

From source file:Main.java

/**
 * Centers JComponent on screen//ww  w.j a  v  a2  s  . c  o m
 *
 * @param target
 */
public static void centerComponent(final JComponent target) {
    final Rectangle screen = getScreenRect();
    final Rectangle frameSize = target.getBounds();
    final int x = (screen.width - frameSize.width) / 2;
    final int y = (screen.height - frameSize.height) / 2;
    target.setLocation(x, y);
}

From source file:DesktopManagerDemo.java

public void dragFrame(JComponent f, int newX, int newY) {
    f.setLocation(newX, newY);
    m_counts[6]++;
}

From source file:JavaXWin.java

public void dragFrame(JComponent f, int newX, int newY) {
    f.setLocation(newX, newY);
    ww.repaint();
}

From source file:com.t3.client.ui.T3Frame.java

private void showGlassPane(JComponent component, int x, int y, boolean modal) {
    component.setSize(component.getPreferredSize());
    component.setLocation(x, y);
    glassPane.setLayout(null);/* www.j a va 2 s .  c  o m*/
    glassPane.add(component);
    glassPane.setModel(modal);
    glassPane.setVisible(true);
}