Example usage for javax.swing JFrame setLocationRelativeTo

List of usage examples for javax.swing JFrame setLocationRelativeTo

Introduction

In this page you can find the example usage for javax.swing JFrame setLocationRelativeTo.

Prototype

public void setLocationRelativeTo(Component c) 

Source Link

Document

Sets the location of the window relative to the specified component according to the following scenarios.

Usage

From source file:GradientsMiddle.java

public static void main(String[] args) {

    JFrame frame = new JFrame("GradientsMiddle");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new GradientsMiddle());
    frame.setSize(350, 350);// w  ww. j av  a 2  s. co  m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new Main());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();//from w w  w  .  j a  v  a  2  s.c o  m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:TextAttributesSize.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Text attributes");
    frame.add(new TextAttributesSize());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(620, 190);//from www. j  a v  a  2s . co m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:GradientsVertical.java

public static void main(String[] args) {

    JFrame frame = new JFrame("GradientsVertical");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new GradientsVertical());
    frame.setSize(350, 350);/*w w  w . ja va  2  s.co m*/
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Colors.java

public static void main(String[] args) {

    JFrame frame = new JFrame("Colors");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new Colors());
    frame.setSize(360, 300);/*from  w w w  .  ja va  2s  .  c o m*/
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:TreeRowHeightCalculation.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.setRowHeight(0);//ww  w .  j  ava2 s .co m

    JFrame frame = new JFrame("tree row height calculation");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:TextAttributesColor.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Text attributes");
    frame.add(new TextAttributesColor());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(620, 190);//from ww  w.j av a 2 s  . co m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:TextAttributesFont.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Text attributes");
    frame.add(new TextAttributesFont());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(620, 190);//from w  w  w.j ava2  s .co  m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:GradientsDirection.java

public static void main(String[] args) {

    JFrame frame = new JFrame("GradientsDirection");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new GradientsDirection());
    frame.setSize(350, 350);/*from   w w w .  j av a  2  s . com*/
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:TreeDISCONTIGUOUSSelection.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

    JFrame frame = new JFrame("tree DISCONTIGUOUS selection");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);//from w w  w  . j a v a 2  s  .  co m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}