I am learning java programming and I want to know about 'JSeparator class'. I want to know use of JSeparator class of advanced java. Any help would be appreciated.
I am learning java programming and I want to know about 'JSeparator class'. I want to know use of JSeparator class of advanced java. Any help would be appreciated.
This class gives general purpose part for implementing divider lines generally utilized as divider among menu items that breaks them up into logical groupings. Rather than using JSeparator, use JMenu or JPopupMenu addSeparator method to make and include separator. JSeparators also utilized somewhere else in GUI where visual divider is helpful.
See the code given below which may be useful for you:
Code:import javax.swing.JSeparator; import javax.swing.JFrame; import javax.swing.JLabel; public class JSeparatorDemo { public static void main(String argsb[]) { JFrame fn = new JFrame("JSeparator Sample"); fn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fn.setLayout(new GridLayout(0, 1)); JLabel abovec = new JLabel("Above Separator"); fn.add(abovec); JSeparator separator = new JSeparator(); fn.add(separator); JLabel belown = new JLabel("Below Separator"); fn.add(belown); fn.setSize(300, 100); fn.setVisible(true); } }
Bookmarks