Example usage for javax.swing JMenuItem setForeground

List of usage examples for javax.swing JMenuItem setForeground

Introduction

In this page you can find the example usage for javax.swing JMenuItem setForeground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.")
public void setForeground(Color fg) 

Source Link

Document

Sets the foreground color of this component.

Usage

From source file:blue.automation.AutomationManager.java

public JPopupMenu getAutomationMenu(SoundLayer soundLayer) {
    this.selectedSoundLayer = soundLayer;

    // if (menu == null || dirty) {
    JPopupMenu menu = new JPopupMenu();

    // Build Instrument Menu
    JMenu instrRoot = new JMenu("Instrument");

    Arrangement arrangement = data.getArrangement();

    ParameterIdList paramIdList = soundLayer.getAutomationParameters();

    for (int i = 0; i < arrangement.size(); i++) {
        InstrumentAssignment ia = arrangement.getInstrumentAssignment(i);

        if (ia.enabled && ia.instr instanceof Automatable) {

            ParameterList params = ((Automatable) ia.instr).getParameterList();

            if (params.size() <= 0) {
                continue;
            }//from  w ww .  j  av  a2 s  .  c o m

            JMenu instrMenu = new JMenu();
            instrMenu.setText(ia.arrangementId + ") " + ia.instr.getName());

            for (int j = 0; j < params.size(); j++) {
                Parameter param = params.getParameter(j);
                JMenuItem paramItem = new JMenuItem();
                paramItem.setText(param.getName());
                paramItem.addActionListener(parameterActionListener);

                if (param.isAutomationEnabled()) {
                    if (paramIdList.contains(param.getUniqueId())) {
                        paramItem.setForeground(Color.GREEN);
                    } else {
                        paramItem.setForeground(Color.ORANGE);
                    }

                }

                paramItem.putClientProperty("instr", ia.instr);
                paramItem.putClientProperty("param", param);

                instrMenu.add(paramItem);
            }
            instrRoot.add(instrMenu);
        }
    }

    menu.add(instrRoot);

    // Build Mixer Menu
    Mixer mixer = data.getMixer();

    if (mixer.isEnabled()) {
        JMenu mixerRoot = new JMenu("Mixer");

        // add channels
        ChannelList channels = mixer.getChannels();

        if (channels.size() > 0) {
            JMenu channelsMenu = new JMenu("Channels");

            for (int i = 0; i < channels.size(); i++) {
                channelsMenu.add(buildChannelMenu(channels.getChannel(i), soundLayer));
            }

            mixerRoot.add(channelsMenu);
        }

        // add subchannels
        ChannelList subChannels = mixer.getSubChannels();

        if (subChannels.size() > 0) {
            JMenu subChannelsMenu = new JMenu("Sub-Channels");
            for (int i = 0; i < subChannels.size(); i++) {
                subChannelsMenu.add(buildChannelMenu(subChannels.getChannel(i), soundLayer));
            }

            mixerRoot.add(subChannelsMenu);
        }

        // add master channel
        Channel master = mixer.getMaster();

        mixerRoot.add(buildChannelMenu(master, soundLayer));

        menu.add(mixerRoot);
    }

    menu.addSeparator();

    JMenuItem clearAll = new JMenuItem("Clear All");
    clearAll.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Object retVal = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(
                    "Please Confirm Clearing All Parameter Data for this SoundLayer"));

            if (retVal == NotifyDescriptor.YES_OPTION) {

                ParameterIdList idList = selectedSoundLayer.getAutomationParameters();

                Iterator iter = new ArrayList(idList.getParameters()).iterator();

                while (iter.hasNext()) {
                    String paramId = (String) iter.next();
                    Parameter param = getParameter(paramId);

                    param.setAutomationEnabled(false);
                    idList.removeParameterId(paramId);
                }
            }
        }
    });
    menu.add(clearAll);

    clearAll.setEnabled(soundLayer.getAutomationParameters().size() > 0);

    // }

    // System.err.println(parameterMap);

    return menu;
}

From source file:blue.automation.AutomationManager.java

private JMenu buildChannelMenu(Channel channel, SoundLayer soundLayer) {

    JMenu retVal = new JMenu();

    retVal.setText(channel.getName());//  w  w  w.j  a va 2  s.co  m

    ParameterIdList paramIdList = soundLayer.getAutomationParameters();

    // pre effects
    EffectsChain preEffects = channel.getPreEffects();

    if (preEffects.size() > 0) {
        JMenu preMenu = new JMenu("Pre-Effects");
        retVal.add(preMenu);

        for (int i = 0; i < preEffects.size(); i++) {
            Automatable automatable = (Automatable) preEffects.getElementAt(i);

            ParameterList params = automatable.getParameterList();

            if (params.size() > 0) {
                JMenu effectMenu = new JMenu();

                if (automatable instanceof Effect) {
                    effectMenu.setText(((Effect) automatable).getName());
                } else if (automatable instanceof Send) {
                    effectMenu.setText("Send: " + ((Send) automatable).getSendChannel());
                } else {
                    effectMenu.setText("ERROR");
                }

                preMenu.add(effectMenu);

                for (int j = 0; j < params.size(); j++) {
                    Parameter param = params.getParameter(j);
                    JMenuItem paramItem = new JMenuItem();
                    paramItem.setText(param.getName());
                    paramItem.addActionListener(parameterActionListener);

                    if (param.isAutomationEnabled()) {
                        if (paramIdList.contains(param.getUniqueId())) {
                            paramItem.setForeground(Color.GREEN);
                        } else {
                            paramItem.setForeground(Color.ORANGE);
                        }

                    }

                    paramItem.putClientProperty("param", param);

                    effectMenu.add(paramItem);
                }
            }
        }
    }

    // volume
    JMenuItem volItem = new JMenuItem("Volume");
    Parameter volParam = channel.getLevelParameter();
    volItem.putClientProperty("param", volParam);
    volItem.addActionListener(parameterActionListener);

    if (volParam.isAutomationEnabled()) {
        if (paramIdList.contains(volParam.getUniqueId())) {
            volItem.setForeground(Color.GREEN);
        } else {
            volItem.setForeground(Color.ORANGE);
        }

    }

    retVal.add(volItem);

    // post effects
    EffectsChain postEffects = channel.getPostEffects();

    if (postEffects.size() > 0) {
        JMenu postMenu = new JMenu("Post-Effects");
        retVal.add(postMenu);

        for (int i = 0; i < postEffects.size(); i++) {
            Automatable automatable = (Automatable) postEffects.getElementAt(i);

            ParameterList params = automatable.getParameterList();

            if (params.size() > 0) {
                JMenu effectMenu = new JMenu();

                if (automatable instanceof Effect) {
                    effectMenu.setText(((Effect) automatable).getName());
                } else if (automatable instanceof Send) {
                    effectMenu.setText("Send: " + ((Send) automatable).getSendChannel());
                } else {
                    effectMenu.setText("ERROR");
                }

                postMenu.add(effectMenu);

                for (int j = 0; j < params.size(); j++) {
                    Parameter param = params.getParameter(j);
                    JMenuItem paramItem = new JMenuItem();
                    paramItem.setText(param.getName());
                    paramItem.addActionListener(parameterActionListener);

                    if (param.isAutomationEnabled()) {
                        if (paramIdList.contains(param.getUniqueId())) {
                            paramItem.setForeground(Color.GREEN);
                        } else {
                            paramItem.setForeground(Color.ORANGE);
                        }

                    }

                    paramItem.putClientProperty("param", param);

                    effectMenu.add(paramItem);
                }
            }
        }
    }

    return retVal;
}

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Constructs DBMenuBar. Adds the menu and menuitems.
 *
 * @param graphicsRunner the JFrame that created this
 * @param desktop        the DBDesktopPane in the JFrame
 */// ww w .  ja v a  2s  . c  o m
public DBMenuBar(GraphicsRunner graphicsRunner, DBDesktopPane desktop) {
    super();

    gr = graphicsRunner;
    this.desktop = desktop;

    //Set up the menu
    JMenu menu = new JMenu("File");
    add(menu);

    //Set up the menu items.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open");
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("open");
    menuItem.addActionListener(this);
    menuItem.setLayout(new MigLayout());
    menu.add(menuItem);

    menuItem = new JMenuItem("Save");
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("save");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Save As");
    menuItem.setActionCommand("saveas");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print    Current Page");
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("printpage");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Show");
    menuItem.setActionCommand("printshow");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Dot Sheets");
    menuItem.setActionCommand("printdotsheets");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Edit");
    add(menu);

    menuItem = new JMenuItem("Undo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("undo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Redo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("redo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Settings");
    add(menu);

    menuItem = new JMenuItem("Toggle Gridlines");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglegrid");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowGrid() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Dot Names");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglenames");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowNames() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Text Box");
    menuItem.setActionCommand("toggletext");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowText() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Color Code Dots by Instrument");
    menuItem.setActionCommand("colordots");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldColorDots() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem();
    menuItem.setText(Main.getState().getSettings().useCollegeHashes() ? "Change to High School Hashes"
            : "Change to College Hashes");
    menuItem.setActionCommand("changehash");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Change Font Size");
    menuItem.setActionCommand("fontsize");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //add(Box.createHorizontalStrut(menu.getPreferredSize().width));

    //add these to the menubar itself
    menuItem = new JMenuItem("Play");
    menuItem.setMaximumSize(new Dimension(menuItem.getPreferredSize().width, Integer.MAX_VALUE));
    menuItem.setActionCommand("play");
    menuItem.addActionListener(this);
    add(menuItem);

    add(Box.createHorizontalGlue());

    menu = new JMenu("Help");
    add(menu);

    menuItem = new JMenuItem("Help");
    menuItem.setActionCommand("help");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("About");
    menuItem.setActionCommand("about");
    menuItem.addActionListener(this);
    menu.add(menuItem);
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Creates a button looking like an hyper-link.
 * //from w ww  . j  a  va2s .co m
 * @param text The text to display
 * @return See above.
 */
public static JMenuItem createHyperLinkMenuItem(String text) {
    if (text == null || text.trim().length() == 0)
        text = "hyperlink";
    JMenuItem b = new JMenuItem(text);
    //Font f = b.getFont();
    //b.setFont(f.deriveFont(f.getStyle(), f.getSize()-2));
    b.setOpaque(false);
    b.setForeground(UIUtilities.HYPERLINK_COLOR);
    unifiedButtonLookAndFeel(b);
    return b;
}