import javax.swing.*;

public class JFrameTest extends JFrame
{
	public JFrameTest()
	{
		super("스윙 JFrame 테스트");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(300,200);
		setVisible(true);
	}

	public static void main(String args[])
	{
		JFrameTest jf = new JFrameTest();
	}
}


import java.awt.*;
import javax.swing.*;

public class SixButtons extends JFrame
{
	protected JButton one, two, three, four, five, six;

	public SixButtons()
	{
		super("플로우 레이아웃");
		getContentPane().setLayout(new FlowLayout());
		one = new JButton("One");
		two = new JButton("Two");
		three = new JButton("Three");
		four = new JButton("Four");
		five = new JButton("Five");
		six = new JButton("Six");

		getContentPane().add(one);
		getContentPane().add(two);
		getContentPane().add(three);
		getContentPane().add(four);
		getContentPane().add(five);
		getContentPane().add(six);

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(300, 200);
		setVisible(true);
	}

	public static void main(String args[])
	{
		SixButtons sb = new SixButtons();
	}
}


import java.awt.*;
import javax.swing.*;

public class FiveButtons extends JFrame
{
	protected JButton b1, b2, b3, b4, b5;

	public FiveButtons()
	{
		super("보더 레이아웃");
		b1 = new JButton("Center");
		b2 = new JButton("South");
		b3 = new JButton("North");
		b4 = new JButton("West");
		b5 = new JButton("East");

		getContentPane().add(b1, BorderLayout.CENTER);
		getContentPane().add(b2, BorderLayout.SOUTH);
		getContentPane().add(b3, BorderLayout.NORTH);
		getContentPane().add(b4, BorderLayout.WEST);
		getContentPane().add(b5, BorderLayout.EAST);

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(300,200);
		setVisible(true);
	}

	public static void main(String args[])
	{
		FiveButtons fb = new FiveButtons();
	}
}


import java.awt.*;
import javax.swing.*;

public class FourButtons extends JFrame
{
	protected JButton b1, b2, b3, b4;

	public FourButtons()
	{
		super("그리드 레이아웃");
		getContentPane().setLayout(new GridLayout(2,2));

		b1 = new JButton("One");
		b2 = new JButton("Two");
		b3 = new JButton("Three");
		b4 = new JButton("Four");

		getContentPane().add(b1);
		getContentPane().add(b2);
		getContentPane().add(b3);
		getContentPane().add(b4);

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(300,200);
		setVisible(true);
	}

	public static void main(String args[])
	{
		FourButtons fb = new FourButtons();
	}
}


import java.awt.*;
import javax.swing.*;

public class SimpleGridBag extends JFrame {
	JButton b1,b2,b3,b4,b5,b6;

	public SimpleGridBag() {
		super("SimpleGridBag");
		GridBagLayout gridbag = new GridBagLayout();
		GridBagConstraints constraint = new GridBagConstraints();
		getContentPane().setLayout(gridbag);

		constraint.fill = GridBagConstraints.BOTH;
		constraint.weightx = 1.0;
		constraint.weighty = 1.0;
		b1 = new JButton("Button1");
		gridbag.setConstraints(b1, constraint);
		getContentPane().add(b1);

		b2 = new JButton("Button2");
		gridbag.setConstraints(b2, constraint);
		getContentPane().add(b2);

		constraint.gridwidth = GridBagConstraints.REMAINDER;
		b3 = new JButton("Button3");
		gridbag.setConstraints(b3, constraint);
		getContentPane().add(b3);

		constraint.gridwidth = 1;
		constraint.gridheight = 2;
		b4 = new JButton("Button4");
		gridbag.setConstraints(b3, constraint);
		getContentPane().add(b4);

		constraint.gridwidth = GridBagConstraints.REMAINDER;
		constraint.gridheight = 1;
		constraint.weighty = 1.0;
		b5 = new JButton("Button5");
		gridbag.setConstraints(b5, constraint);
		getContentPane().add(b5);

		b6 = new JButton("Button6");
		gridbag.setConstraints(b6, constraint);
		getContentPane().add(b6);

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(400,200);
		setVisible(true);
	}

	public static void main(String args[])
	{
		new SimpleGridBag();
	}
}

2007/09/12 10:12 2007/09/12 10:12

Trackback URL : http://mysilpir.net/trackback/237

Leave a comment

« Previous : 1 : ... 85 : 86 : 87 : 88 : 89 : 90 : 91 : 92 : 93 : ... 270 : Next »

블로그 이미지

일상의 이야기를 나누는 공간입니다.

- 실피

Calendar

    «   2009/01   »
            1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 31

Total 157576 hit (Today 21, Yesterday 185)

Admin Write Post