JSeparator
- JSeparator 가로 또는 세로 줄 또는 빈 공간 구성 요소를 분리합니다.
- JSeparator 클래스 구성요소를 구분하기 위해 선을 긋는 데 사용됩니다. 레이아웃에서.
- 메뉴나 도구 모음에 구분 기호를 추가하는 가장 쉬운 방법은 addSeparator( ) 메서드 JMenu 클래스에서 제공 , J팝업 메뉴 및 JToolBar .
- JSeperator 클래스의 중요한 메소드는 setOrientation() 및 getOrientation().
예
import java.awt.*;
import javax.swing.*;
public class JSeparatorTest extends JFrame {
private JLabel label1, label2;
public JSeparatorTest() {
setTitle("JSeparator Test");
setLayout(new GridLayout(0, 1));
label1 = new JLabel("Above Separator");
add(label1);
JSeparator sep = new JSeparator();
add(sep); // add a separator between two labels.
label2 = new JLabel("Below Separator");
add(label2);
setSize(375, 250);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String args[]) {
new JSeparatorTest();
}
} 출력
