Java by API/javax.swing/JSeparator

Материал из Java эксперт
Перейти к: навигация, поиск

new JSeparator()

   <source lang="java">

import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JSeparator; public class MainClass {

 public static void main(String args[]) {
   JFrame f = new JFrame("JSeparator Sample");
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.setLayout(new GridLayout(0, 1));
   JLabel above = new JLabel("Above Separator");
   f.add(above);
   JSeparator separator = new JSeparator();
   f.add(separator);
   JLabel below = new JLabel("Below Separator");
   f.add(below);
   f.setSize(300, 100);
   f.setVisible(true);
 }

}


 </source>
   
  
 
  



new JSeparator(int orientation)

   <source lang="java">

import javax.swing.JFrame; import javax.swing.JSeparator; public class Main {

 public static void main(String[] a){
   JFrame frame = new JFrame();
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.add(new JSeparator(JSeparator.VERTICAL));
   frame.setSize(300, 200);
   frame.setVisible(true);
 }

}

 </source>