Example usage for java.awt Frame getWidth

List of usage examples for java.awt Frame getWidth

Introduction

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

Prototype

public int getWidth() 

Source Link

Document

Returns the current width of this component.

Usage

From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java

protected Point getDialogLocation(JDialog dialog, Component c) {
    Frame frame = JOptionPane.getFrameForComponent(c);
    int x = frame.getX() + (frame.getWidth() - dialog.getWidth()) / 2;
    int y = frame.getY() + (frame.getHeight() - dialog.getHeight()) / 2;
    return new Point(x, y);
}

From source file:net.ontopia.topicmaps.viz.AboutFrame.java

public AboutFrame(Frame parent) {
    super(parent, Messages.getString("Viz.About", "Ontopia Vizigator"), true);

    JPanel mainPanel = new JPanel();
    mainPanel.setBackground(Color.white);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(createImagePanel());/*from   w  w w  .  j  av  a  2s .co  m*/
    mainPanel.add(createAboutTextPanel());

    this.getContentPane().add(mainPanel);
    this.pack();
    this.setResizable(false);
    //    Center the dialog box above its parent
    this.setLocation((parent.getX() + (parent.getWidth() - this.getWidth()) / 2),
            parent.getY() + (parent.getHeight() - this.getHeight()) / 2);
}

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

/**
 * Contructs a PINEntry instance. /* w  w  w  . j ava  2s .  com*/
 */
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);
}