SORU
17 EKİM 2008, Cuma


Nasıl ekran üzerine bir JDialog merkezi muyum?

Nasıl ekranın ortasında bir JDialog konumlandırma için ne yapmam lazım?

CEVAP
17 EKİM 2008, Cuma


Java 1.4 yapabilirsiniz:

final JDialog d = new JDialog();
d.setSize(200,200);
d.setLocationRelativeTo(null);
d.setVisible(true);

Veya (pre 1.4) belki de:

final JDialog d = new JDialog();
d.setSize(200, 200);
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension screenSize = toolkit.getScreenSize();
final int x = (screenSize.width - d.getWidth()) / 2;
final int y = (screenSize.height - d.getHeight()) / 2;
d.setLocation(x, y);
d.setVisible(true);

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Awesomesauce Network

    Awesomesauce

    4 EKİM 2012
  • PlayStation

    PlayStation

    16 Aralık 2005
  • Rayone GB

    Rayone GB

    14 Temmuz 2007