Gui 그래픽구성

import javax.swing.*;

public class ComplexLayoutDemo

{

 public static void main (String[ ] args)

 {
  JFrame  frame = new JFrame ("복잡한 화면 구성 관리자");
  frame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE);
 
  frame.getContentPane().add(new layoutPanel());
 
  frame.pack();
  frame.show();
 }
}



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

public class layoutPanel extends JPanel
{
 public layoutPanel ()
 {
 
  JPanel panel1 = new JPanel ();
  JPanel panel2 = new JPanel ();
  JPanel panel3 = new JPanel ();
 
  JTextArea textAreal = new JTextArea ();
  JLabel label1 = new JLabel ("Label one");
  JLabel label2 = new JLabel ("Label two");
  JLabel label3 = new JLabel ("Label three");
  JLabel label4 = new JLabel ("Label four");
  JButton button1 = new JButton("Button one");
  JButton button2 = new JButton("Button two");
  JButton button3 = new JButton("Button three");
 
 
  this.setLayout(new GridLayout(2,2));
 
  this.add(textAreal);
 
  this.add(panel1);
 
  panel1.setLayout(new GridLayout(2,1));
  panel1.add(label1);
  panel1.add(label2);
 
  this.add(new JPanel ());
 
  this.add(panel2);
 
  panel2.setLayout(new GridLayout(4,1));
  panel2.add(label3);
  panel2.add(button1);
  panel2.add(label4);
  panel2.add(panel3);
  panel3.setLayout(new GridLayout(1,2));
  panel3.add(button2);
  panel3.add(button3);
 }
}



티스토리 툴바