com.alee.laf.menu.WebMenuItem Java Examples

The following examples show how to use com.alee.laf.menu.WebMenuItem. 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: MenuBar.java    From lnk2pwn with MIT License 6 votes vote down vote up
@PostConstruct	
private void initComponents() {
    WebMenu menu = new WebMenu("File");
    menu.setIcon(IconFactory.getIcon("file.png"));
    
    WebMenuItem about = new WebMenuItem("About");
    about.setIcon(IconFactory.getIcon("about.png"));
    about.addActionListener(showAboutDialogAction);
    
    WebMenuItem exit = new WebMenuItem("Exit");
    exit.setIcon(IconFactory.getIcon("exit.png"));
    exit.addActionListener(exitAction);
    
    menu.add(about);
    menu.add(new WebSeparator());
    menu.add(exit);		
    
    this.add(menu);
}
 
Example #2
Source File: ComponentUtils.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public JPopupMenu getComponentPopupMenu() {
    WebPopupMenu menu = new WebPopupMenu();

    if (mFile == null)
        return null; // should never happen

    WebMenuItem saveMenuItem = new WebMenuItem(Tr.tr("Save File As…"));
    saveMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (mFile == null)
                return; // should never happen

            File suggestedFile = new File(
                    mFileChooser.getCurrentDirectory(), mFile.getName());

            mFileChooser.setSelectedFile(suggestedFile);
            // fix WebLaf bug
            mFileChooser.getFileChooserPanel().setSelectedFiles(new File[]{suggestedFile});

            int option = mFileChooser.showSaveDialog(AttachmentPanel.this);
            if (option == JFileChooser.APPROVE_OPTION) {
                try {
                    Files.copy(mFile.toPath(), mFileChooser.getSelectedFile().toPath(),
                            StandardCopyOption.REPLACE_EXISTING);
                } catch (IOException ex) {
                    LOGGER.log(Level.WARNING, "can't copy file", ex);
                }
            }
        }
    });
    if (!mFile.exists()) {
        saveMenuItem.setEnabled(false);
        saveMenuItem.setToolTipText(Tr.tr("File does not exist"));
    }
    menu.add(saveMenuItem);

    return menu;
}
 
Example #3
Source File: ComponentUtils.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
private void showPopupMenu(MouseEvent e) {
    WebPopupMenu menu = new WebPopupMenu();
    WebMenuItem removeItem = new WebMenuItem(Tr.tr("Remove"));
    removeItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent event) {
                EditableAvatarImage.this.changeImage(null);
            }
        });
    removeItem.setEnabled(EditableAvatarImage.this.canRemove());
    menu.add(removeItem);
    menu.show(this, e.getX(), e.getY());
}
 
Example #4
Source File: Tool.java    From Spade with GNU General Public License v3.0 5 votes vote down vote up
public Tool(String name)
{
	this.name = name;
	
	WebPopup menu = new WebPopup();
	
	menu.add(new WebMenuItem(name + " Settings"));
	menu.add(new WebSeparator());
	menu.setLayout(new BoxLayout(menu, BoxLayout.Y_AXIS));
	menu.setPopupStyle(PopupStyle.bordered);
	menu.setFocusable(false);
	this.menu = menu;
}
 
Example #5
Source File: WeblafWrapper.java    From Spade with GNU General Public License v3.0 4 votes vote down vote up
public static JMenuItem createMenuItem(String text)
{
	WebMenuItem c = new WebMenuItem(text);
	return c;
}
 
Example #6
Source File: WeblafWrapper.java    From Spade with GNU General Public License v3.0 4 votes vote down vote up
public static JMenuItem asMenuItem(JComponent comp)
{
	WebMenuItem c = new WebMenuItem();
	c.add(comp);
	return c;
}