Example usage for javax.swing JPopupMenu setDefaultLightWeightPopupEnabled

List of usage examples for javax.swing JPopupMenu setDefaultLightWeightPopupEnabled

Introduction

In this page you can find the example usage for javax.swing JPopupMenu setDefaultLightWeightPopupEnabled.

Prototype

public static void setDefaultLightWeightPopupEnabled(boolean aFlag) 

Source Link

Document

Sets the default value of the lightWeightPopupEnabled property.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    boolean lwPopup = JPopupMenu.getDefaultLightWeightPopupEnabled(); // true

    // Globally use heavyweight components for all popup menus
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
}

From source file:MediumPopupMenuSample.java

public static void main(String args[]) {
    // Define ActionListener
    ActionListener aListener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.out.println("Selected: " + event.getActionCommand());
        }/*w  w  w .  j a  v  a2s.c  o m*/
    };

    // Define PopupMenuListener
    PopupMenuListener pListener = new PopupMenuListener() {
        public void popupMenuCanceled(PopupMenuEvent event) {
            System.out.println("Canceled");
        }

        public void popupMenuWillBecomeInvisible(PopupMenuEvent event) {
            System.out.println("Becoming Invisible");
        }

        public void popupMenuWillBecomeVisible(PopupMenuEvent event) {
            System.out.println("Becoming Visible");
        }
    };

    // Define
    JFrame frame = new JFrame("Popup Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    // Create popup menu, attach popup menu listener
    final JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.addPopupMenuListener(pListener);

    // Cut
    JMenuItem cutItem = new JMenuItem("Cut");
    cutItem.addActionListener(aListener);
    popupMenu.add(cutItem);

    // Copy
    JMenuItem copyItem = new JMenuItem("Copy");
    copyItem.addActionListener(aListener);
    popupMenu.add(copyItem);

    // Paste
    JMenuItem pasteItem = new JMenuItem("Paste");
    pasteItem.addActionListener(aListener);
    pasteItem.setEnabled(false);
    popupMenu.add(pasteItem);

    // Separator
    popupMenu.addSeparator();

    // Find
    JMenuItem findItem = new JMenuItem("Find");
    findItem.addActionListener(aListener);
    popupMenu.add(findItem);

    // Enable showing
    MouseListener mouseListener = new JPopupMenuShower(popupMenu);
    frame.addMouseListener(mouseListener);

    Button button = new Button("Label");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println(popupMenu.isLightWeightPopupEnabled());
        }
    });
    frame.getContentPane().add(button, BorderLayout.SOUTH);

    frame.setSize(350, 250);
    frame.setVisible(true);
}

From source file:ja.lingo.application.JaLingo.java

public static void main(String[] args) {
    System.getProperties().setProperty("swing.aatext", "true");

    // needed because of bug that was introduced by hack on Popup,
    // that is needed to show hand cursor for data tips on lists
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    LogInitializer.initialize();/* w  ww . j ava  2  s .c o m*/

    new JaLingo();
}

From source file:com.google.code.facebook.graph.sna.applet.GraphEditorDemo.java

/**
 * a driver for this demo/*from   w ww .  ja v a 2s.  co  m*/
 */
@SuppressWarnings("serial")
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final GraphEditorDemo demo = new GraphEditorDemo();

    JMenu menu = new JMenu("File");
    menu.add(new AbstractAction("Make Image") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                demo.writeJPEGImage(file);
            }
        }
    });
    menu.add(new AbstractAction("Print") {
        public void actionPerformed(ActionEvent e) {
            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setPrintable(demo);
            if (printJob.printDialog()) {
                try {
                    printJob.print();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setVisible(true);
}

From source file:external.jung.demo.GraphEditorDemo.java

/**
 * a driver for this demo/* w ww.j  av a 2 s . co m*/
 */
@SuppressWarnings("serial")
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final GraphEditorDemo demo = new GraphEditorDemo();

    JMenu menu = new JMenu("File");
    menu.add(new AbstractAction("Make Image") {

        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                demo.writeJPEGImage(file);
            }
        }
    });
    menu.add(new AbstractAction("Print") {

        public void actionPerformed(ActionEvent e) {
            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setPrintable(demo);
            if (printJob.printDialog()) {
                try {
                    printJob.print();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

/**
 * make lightweight components visible over canvas
 *///from   www. java2  s. c o m
public static void makeLightWeightComponentsVisible() {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
}

From source file:BeanContainer.java

  public BeanContainer() {
  super("Simple Bean Container");
  getContentPane().setLayout(new FlowLayout());
   /*w w w.j ava  2s  . c  o m*/
  setSize(300, 300);

  JPopupMenu.setDefaultLightWeightPopupEnabled(false);

  JMenuBar menuBar = createMenuBar();
  setJMenuBar(menuBar);

  WindowListener wndCloser = new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
      System.exit(0);
    }
  };
  addWindowListener(wndCloser);

  setVisible(true);
}

From source file:GraphEditorDemo.java

/**
 * a driver for this demo//from   w  ww  .j  a  va  2 s. c om
 */
@SuppressWarnings("serial")
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final GraphEditorDemo demo = new GraphEditorDemo();

    JMenu menu = new JMenu("File");
    menu.add(new AbstractAction("Make Image") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                demo.writeJPEGImage(file);
            }
        }
    });
    menu.add(new AbstractAction("Print") {
        public void actionPerformed(ActionEvent e) {
            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setPrintable(demo);
            if (printJob.printDialog()) {
                try {
                    printJob.print();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
    menu.add(new AbstractAction("Save") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                demo.writeTopologyFile(file);
            }
        }
    });
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setVisible(true);
}

From source file:ca.sfu.federation.Application.java

/**
 * Start the application./*from  w w w. ja v  a  2s .  c  o m*/
 */
@Override
public void run() {
    logger.log(Level.INFO, "Starting application");
    // set the look and feel options
    try {
        logger.log(Level.FINE, "Setting look and feel options");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
        LookAndFeelUtil.removeAllSplitPaneBorders();
    } catch (Exception e) {
        String stack = ExceptionUtils.getFullStackTrace(e);
        logger.log(Level.WARNING, "Could not set look and feel options\n\n{0}", stack);
    }
    // create the main application frame 
    logger.log(Level.FINE, "Creating main application frame");
    frame = new ApplicationFrame();
    // show the application
    frame.setVisible(true);
}

From source file:external.jung.demo.RoadEditorDemo.java

/**
 * a driver for this demo/*  ww w  . j a  v a 2  s  .  co m*/
 */
@SuppressWarnings("serial")
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final RoadEditorDemo demo = new RoadEditorDemo();

    JMenu menu = new JMenu("File");

    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setVisible(true);
}