본문 바로가기

[JAVA][SWING]setBorder TitledBorder LineBorder


소스 투척


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
32
33
34
35
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
 
@SuppressWarnings("serial")
public class ExBorder extends JFrame {
 
    public ExBorder() {
        Container container = getContentPane();
 
        container.add(new JPanel(), BorderLayout.NORTH);
        container.add(new JPanel(), BorderLayout.EAST);
        container.add(new JPanel(), BorderLayout.WEST);
        container.add(new JPanel(), BorderLayout.SOUTH);
        
        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(new LineBorder(Color.black),"panel"));
        container.add(panel, BorderLayout.CENTER);
        
        setSize(300300);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
    }
 
    public static void main(String[] args) {
        new ExBorder();
    }
 
}
cs


출처 : Java setBorder() 사용하기




상좌하우 10씩 띄기


setBorder(BorderFactory.createEmptyBorder(0 , 10 , 0 , 10)); //상좌하우



반응형