Welcome, Guest. Please login or register.
Did you miss your activation email?
Pages: [1]   Go Down
  Print  
Author Topic: Center a JFrame  (Read 1739 times)
0 Members and 1 Guest are viewing this topic.
deAppel
Favorite member
Member
*

Reputation: 0
HappyFace plants one on you
Offline Offline
Posts: 45
Referrals: 0

Awards
« on: October 28, 2007, 03:18:45 PM »

Code
GeSHi (java):
  1. import java.awt.Container;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.JLabel;
  5.  
  6.  
  7. /*--------------------------------------------------------------------------
  8. // File and Version Information:
  9. // Test.java
  10. //
  11. // Description:
  12. // A JFrame that is centered on the screen
  13. //
  14. // Environment:
  15. //      This software was developed with Eclipse and Java 1.6
  16. //
  17. // Author List:
  18. //      deAppel <Creator>
  19. //
  20. //
  21. // Copyright Information:
  22. //      Copyright (C) 2007      <Institution><None>
  23. //
  24. //----------------------------------------------------------------------*/
  25. public class CenterFrame extends JFrame{
  26. JLabel defaultText;
  27.  
  28. public CenterFrame(){
  29. Container c = getContentPane();
  30. setTitle("A centered JFrame");
  31. defaultText = new JLabel("Some text here..");
  32. c.add(defaultText);
  33. setSize(200,50);
  34. setLocationRelativeTo(null);
  35. setVisible(true);
  36. }
  37.  
  38. public static void main(String[] args) {
  39. new CenterFrame();
  40. }
  41.  
  42. }
  43.  
Created by GeSHI 1.0.7.20
Logged

Earn $0.04 or more for each search you make! http://www.myhpf.co.uk/apply001.asp?Friend=77889

If you need homework help, just post your assignment and i'll code it before your deadline =) i'll provide you "t3h c0d3z" but only if you show me that you have done something and not just ask for me to write everything for you. Just tell us what the problem is and i'm sure we can fix it for you!

I was born into the Hakka lineage, A bloodline that
traces it's roots back to the original Han emperors of
China. During the rise of the 3 Kingdoms (China's
famous warring period), the Hans were overthrown
and exiled. Forced to flee, they headed south finding
refuge within the mountains of Guilin Province where
they lived under their new title, the Hakka and patiently
wait for their chance to return to the throne as the
Sons Of Heaven...
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here