Help on my code...

please help me out on this code... thanks!

Page 1 of 1

1 Replies - 941 Views - Last Post: 14 March 2008 - 11:35 AM Rate Topic: -----

#1 eklok  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-March 08

Help on my code...

Post icon  Posted 14 March 2008 - 11:27 AM

public TicTacToe()
	{
		final JPanel mainPanel = new JPanel(new GridLayout(3, 3));
		final ActionListener buttonListener = new ButtonListener();
		
		for (int i = 0; i < 9; i++)
			{
			this.buttons[i] = new JButton();
			mainPanel.add(this.buttons[i]);
			this.buttons[i].addActionListener(buttonListener);
			}
		
		this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
		this.frame.setBounds(200, 200, 250, 250);
		this.frame.setVisible(true);
	}



i got this code from a friend(google search)! I just want to ask how to set the location of this.frame."something" into a dead center of the screen disregarding what resolution the monitor uses!

the problem is that, my professor was so sensitive, he wanted that the layout should be centered in any screen resolution and i can't figure it out!

please help me out! it would be a great help... thanks in advance!


Is This A Good Question/Topic? 0
  • +

Replies To: Help on my code...

#2 letthecolorsrumble  Icon User is offline

  • Student of The Sun
  • member icon

Reputation: 27
  • View blog
  • Posts: 555
  • Joined: 07-November 07

Re: Help on my code...

Posted 14 March 2008 - 11:35 AM

You will find this link helpful for your task.

http://exampledepot....ScreenSize.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1