FileDocCategorySizeDatePackage
MenuElementExample.javaAPI DocExample3425Thu Oct 24 20:14:24 BST 2002None

MenuElementExample

public class MenuElementExample extends JPanel

Fields Summary
public JPopupMenu
popup
SliderMenuItem
slider
int
theValue
Constructors Summary
public MenuElementExample()


      

        popup = new JPopupMenu(); 
        slider = new SliderMenuItem();

        popup.add(slider);
        popup.add(new JSeparator());

        JMenuItem ticks = new JCheckBoxMenuItem("Slider Tick Marks");
        ticks.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                slider.setPaintTicks(!slider.getPaintTicks());
            }
        });
        JMenuItem labels = new JCheckBoxMenuItem("Slider Labels");
        labels.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                slider.setPaintLabels(!slider.getPaintLabels());
            }
        });
        popup.add(ticks);
        popup.add(labels);
        popup.addPopupMenuListener(new PopupPrintListener());

        addMouseListener(new MousePopupListener());
    
Methods Summary
public static voidmain(java.lang.String[] s)

        JFrame frame = new JFrame("Menu Element Example");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setContentPane(new MenuElementExample());
        frame.setSize(300, 300);
        frame.setVisible(true);