1 Replies - 343 Views - Last Post: 31 May 2010 - 05:27 AM Rate Topic: -----

#1 saSBH2  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 02-March 10

GUI problem

Posted 31 May 2010 - 05:03 AM

Hi,
My code is here:
import javax.swing.*;
import java.awt.*;
public class newGui{
	JFrame f;
	JPanel p1=new JPanel();
	JPanel p2=new JPanel();
	JPanel p3=new JPanel();
	public static void main(String[]args){
		newGui myB=new newGui();
		myB.draw();
	}
	public void draw()
	{
		f=new JFrame();
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.getContentPane().add(BorderLayout.NORTH,p1);
		p2.setBackground(Color.lightGray);
		f.getContentPane().add(BorderLayout.CENTER,p2);
		f.getContentPane().add(BorderLayout.SOUTH,p3);
		p3.setLayout(new GridLayout(9,9));
		for(int j=0;j<9;j++)
			for(int i=0;i<9;i++)
			{
				JButton b=new JButton();
				p3.add(B)/>;
			}
		f.setSize(150,300);
		f.setVisible(true);
	}
}

But the result is not what I want. I want to make the Center location smaller.(for Minesweeper Game)
What should I do?
(the code is not complete!!!)

Is This A Good Question/Topic? 0
  • +

Replies To: GUI problem

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2650
  • View blog
  • Posts: 11,179
  • Joined: 20-September 08

Re: GUI problem

Posted 31 May 2010 - 05:27 AM

Try using an additional panel:

	p2.setPreferredSize(new Dimension(100, 100));
	p2.setMaximumSize(new Dimension(100, 100));
	JPanel base = new JPanel();
	base.add(p2);
        f.getContentPane().add(BorderLayout.CENTER, base);


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1