Example usage for java.awt Frame getGraphicsConfiguration

List of usage examples for java.awt Frame getGraphicsConfiguration

Introduction

In this page you can find the example usage for java.awt Frame getGraphicsConfiguration.

Prototype

public GraphicsConfiguration getGraphicsConfiguration() 

Source Link

Document

Gets the GraphicsConfiguration associated with this Component .

Usage

From source file:org.opensc.test.pkcs11.PINEntry.java

/**
 * Contructs a PINEntry instance. //from ww  w . j a  v  a2  s  .c  o m
 */
public PINEntry() {
    super();
    Frame frame = new Frame("PIN entry");

    frame.setLayout(new GridLayout(2, 2));

    frame.add(new Label("Event:"));

    this.label = new Label("NO_EVENT");
    frame.add(this.label);

    this.prompt = new Label();
    frame.add(this.prompt);

    this.listener = new PINListener(frame);

    this.textField = new TextField();
    this.textField.setEchoChar('*');
    this.textField.addKeyListener(this.listener);
    frame.add(this.textField);
    frame.addWindowListener(this.listener);

    frame.pack();
    frame.setVisible(true);

    GraphicsConfiguration gc = frame.getGraphicsConfiguration();
    Rectangle r = gc.getBounds();
    Point p = new Point((r.width - frame.getWidth()) / 2, (r.height - frame.getHeight()) / 2);

    frame.setLocation(p);
}