Java Code Examples for javax.swing.JPopupMenu#Separator

The following examples show how to use javax.swing.JPopupMenu#Separator . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TitledMenuSeparator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public TitledMenuSeparator(String text) {
    setLayout(new BorderLayout());
    setOpaque(false);

    JLabel l = new JLabel(text);
    l.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    if (UIUtils.isWindowsLookAndFeel()) l.setOpaque(true);
    l.setFont(l.getFont().deriveFont(Font.BOLD, l.getFont().getSize2D() - 1));
    if (UIUtils.isWindowsLookAndFeel()) l.setForeground(UIUtils.getDisabledLineColor());
    
    add(l, BorderLayout.WEST);
    
    if (UIUtils.isGTKLookAndFeel()) {
        add(UIUtils.createHorizontalSeparator(), BorderLayout.CENTER);
    } else {
        JComponent sep = new JPopupMenu.Separator();
        add(sep, BorderLayout.CENTER);
        
        if (UIUtils.isOracleLookAndFeel()) {
            setOpaque(true);
            setBackground(sep.getBackground());
            l.setForeground(sep.getForeground());
        }
    }
}
 
Example 2
Source File: MenuChecker.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Get MenuBar and tranfer it to ArrayList.
    * @param menu menu to be tranfered
    * @return tranfered menubar  - !separator is ignored
    */
   public static ArrayList<NbMenuItem> getMenuBarArrayList(JMenuBar menu) {
//       System.out.println("getMenuBarArrayList " + menu.getName());
       visitMenuBar(menu);

       MenuElement[] elements = menu.getSubElements();

       ArrayList<NbMenuItem> list = new ArrayList<NbMenuItem>();
       for (int k = 0; k < elements.length; k++) {
           if (elements[k] instanceof JPopupMenu.Separator) {
               NbMenuItem separator = new NbMenuItem();
               separator.setSeparator(true);
               list.add(separator);
           } else {
               if (elements[k] instanceof JMenuItem) {

                   NbMenuItem item = new NbMenuItem((JMenuItem) elements[k]);
                   JMenuBarOperator menuOp = new JMenuBarOperator(menu);
                   item.setSubmenu(getMenuArrayList(menuOp.getMenu(k)));
                   list.add(item);
               }
           }
       }
       return list;
   }
 
Example 3
Source File: MenuChecker.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Get MenuBar and tranfer it to ArrayList.
    * @param menu menu to be tranfered
    * @return tranfered menubar  - !separator is ignored
    */
   public static ArrayList<NbMenuItem> getMenuBarArrayList(JMenuBar menu) {
//       System.out.println("getMenuBarArrayList " + menu.getName());
       visitMenuBar(menu);

       MenuElement[] elements = menu.getSubElements();

       ArrayList<NbMenuItem> list = new ArrayList<NbMenuItem>();
       for (int k = 0; k < elements.length; k++) {
           if (elements[k] instanceof JPopupMenu.Separator) {
               NbMenuItem separator = new NbMenuItem();
               separator.setSeparator(true);
               list.add(separator);
           } else {
               if (elements[k] instanceof JMenuItem) {

                   NbMenuItem item = new NbMenuItem((JMenuItem) elements[k]);
                   JMenuBarOperator menuOp = new JMenuBarOperator(menu);
                   item.setSubmenu(getMenuArrayList(menuOp.getMenu(k)));
                   list.add(item);
               }
           }
       }
       return list;
   }
 
Example 4
Source File: OQLQueries.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public PopupSeparator(String text) {
    setLayout(new BorderLayout());
    setOpaque(false);

    JLabel l = new JLabel(text);
    l.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 3));
    if (UIUtils.isWindowsLookAndFeel()) l.setOpaque(true);
    l.setFont(l.getFont().deriveFont(Font.BOLD, l.getFont().getSize2D() - 1));
    if (UIUtils.isWindowsLookAndFeel()) l.setForeground(UIUtils.getDisabledLineColor());

    add(l, BorderLayout.WEST);

    if (UIUtils.isGTKLookAndFeel()) {
        add(UIUtils.createHorizontalSeparator(), BorderLayout.CENTER);
    } else {
        JComponent sep = new JPopupMenu.Separator();
        add(sep, BorderLayout.CENTER);

        if (UIUtils.isOracleLookAndFeel()) {
            setOpaque(true);
            setBackground(sep.getBackground());
            l.setForeground(sep.getForeground());
        }
    }
}
 
Example 5
Source File: TitledMenuSeparator.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public TitledMenuSeparator(String text) {
    setLayout(new BorderLayout());
    setOpaque(false);

    JLabel l = new JLabel(text);
    l.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    if (UIUtils.isWindowsLookAndFeel()) l.setOpaque(true);
    l.setFont(l.getFont().deriveFont(Font.BOLD, l.getFont().getSize2D() - 1));
    if (UIUtils.isWindowsLookAndFeel()) l.setForeground(UIUtils.getDisabledLineColor());
    
    add(l, BorderLayout.WEST);
    
    if (UIUtils.isGTKLookAndFeel()) {
        add(UIUtils.createHorizontalSeparator(), BorderLayout.CENTER);
    } else {
        JComponent sep = new JPopupMenu.Separator();
        add(sep, BorderLayout.CENTER);
        
        if (UIUtils.isOracleLookAndFeel()) {
            setOpaque(true);
            setBackground(sep.getBackground());
            l.setForeground(sep.getForeground());
        }
    }
}
 
Example 6
Source File: RQueries.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public PopupSeparator(String text) {
    setLayout(new BorderLayout());
    setOpaque(false);

    JLabel l = new JLabel(text);
    l.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 3));
    if (UIUtils.isWindowsLookAndFeel()) l.setOpaque(true);
    l.setFont(l.getFont().deriveFont(Font.BOLD, l.getFont().getSize2D() - 1));
    if (UIUtils.isWindowsLookAndFeel()) l.setForeground(UIUtils.getDisabledLineColor());

    add(l, BorderLayout.WEST);

    if (UIUtils.isGTKLookAndFeel()) {
        add(UIUtils.createHorizontalSeparator(), BorderLayout.CENTER);
    } else {
        JComponent sep = new JPopupMenu.Separator();
        add(sep, BorderLayout.CENTER);

        if (UIUtils.isOracleLookAndFeel()) {
            setOpaque(true);
            setBackground(sep.getBackground());
            l.setForeground(sep.getForeground());
        }
    }
}
 
Example 7
Source File: MainFrame.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Removes duplicated separators from a JMenu
 *
 * @param menu the menu
 */
private static void removeDuplicatedSeparators(JMenu menu) {
	int separatorCount = 0;
	for (Component component : menu.getMenuComponents()) {
		if (component instanceof JPopupMenu.Separator) {
			separatorCount++;
		} else {
			separatorCount = 0;
		}
		if (separatorCount > 1) {
			menu.remove(component);
		}
	}
}
 
Example 8
Source File: SyntaxMenu.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public SyntaxMenu() {
    super(MENU_LABEL);

    syntaxStylesButtonGroup = new ButtonGroup();
    syntaxOptions = new HashMap<>();

    // Create plain syntax as all SyntaxHighlightTextArea will have this style
    addSyntaxOption(
            SyntaxHighlightTextArea.PLAIN_SYNTAX_LABEL, SyntaxConstants.SYNTAX_STYLE_NONE);
    syntaxOptions.get(SyntaxConstants.SYNTAX_STYLE_NONE).setSelected(true);

    plainSyntaxSeparator = new JPopupMenu.Separator();
    add(plainSyntaxSeparator);
}
 
Example 9
Source File: JComponentBuilders.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected JSeparator createInstanceImpl() {
    return new JPopupMenu.Separator();
}
 
Example 10
Source File: JComponentBuilders.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
protected JSeparator createInstanceImpl() {
    return new JPopupMenu.Separator();
}