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:J3dSwingFrame.java

/**
 * Construct the test frame with a menubar and 3D canvas
 *//*from   www  .  j a  v a 2 s .c o m*/
public J3dSwingFrame() {
    super("Java3D Tester");

    // Disable lightweight menus
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    JMenuBar menubar = new JMenuBar();

    // File menu
    JMenu file_menu = new JMenu("File");
    menubar.add(file_menu);

    close_menu = new JMenuItem("Exit");
    close_menu.addActionListener(this);
    file_menu.add(close_menu);

    setJMenuBar(menubar);

    GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = env.getDefaultScreenDevice();
    GraphicsConfiguration config = device.getBestConfiguration(template);

    canvas = new Canvas3D(config);

    // add the canvas to this frame. Since this is the only thing added to
    // the main frame we don't care about layout managers etc.

    getContentPane().add(canvas, "Center");

    constructWorld();

    setSize(600, 600);
}

From source file:com.dfki.av.sudplan.ui.MainFrame.java

/**
 * Creates new form MainFrame/*from ww w.  j a  v  a2  s .c o  m*/
 */
public MainFrame() {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    this.canvasSize = new Dimension(1500, 800);
    this.wwPanel = new VisualizationPanel(canvasSize);
    this.wwPanel.setPreferredSize(canvasSize);

    initComponents();

    // Add LayerTreeComponent to the left split panel.
    JPanel layerTreeComponent = wwPanel.getLayerPanel();
    if (layerTreeComponent != null) {
        pLeftPanel.add(layerTreeComponent);
    } else {
        log.debug("layerTreeComponent == null");
    }
}

From source file:edu.umich.robot.ViewerApplication.java

public ViewerApplication(String[] args) {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);

    Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig();
    if (config == null)
        System.exit(1);/*  w  w  w . j a  v a  2s. c  om*/

    setupViewerConfig(config);
    viewer = new Viewer(config);
    viewer.getVisCanvas().getViewManager().setInterfaceMode(3);

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            frame.dispose();

            try {
                Thread.sleep(500);
            } catch (InterruptedException ignored) {
            }
            System.exit(0); // No way to shut down april threads
        }
    });
    frame.setLayout(new BorderLayout());

    viewerView = new ViewerView(viewer.getVisCanvas());

    // TODO SoarApril
    // viewer.getVisCanvas().setDrawGround(true);

    frame.add(viewerView, BorderLayout.CENTER);

    Preferences windowPrefs = getWindowPreferences();
    if (windowPrefs.get("x", null) != null) {
        frame.setBounds(windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0),
                windowPrefs.getInt("width", 800), windowPrefs.getInt("height", 800));
    } else {
        frame.setBounds(windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0),
                windowPrefs.getInt("width", 600), windowPrefs.getInt("height", 600));
        frame.setLocationRelativeTo(null); // center
    }

    frame.getRootPane().registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);

    frame.pack();

    frame.setVisible(true);

    String[] splinters = config.getStrings("splinters", new String[0]);
    for (String s : splinters) {
        addViewRobot(s);
        addViewLidars(s);
        addViewWaypoints(s);

        // TODO SoarApril
        addViewTrajectory(s);
    }
}

From source file:jgraph.JShow.java

/**
 * a driver for this demo//from   w  w w  . j  ava  2 s.  c  om
 */
@SuppressWarnings("serial")
public static void showtest(DirectedOrderedSparseMultigraph<Object, Object> graph) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JShow demo = new JShow(graph);

    JMenu menu = new JMenu("Snapshot");
    menu.add(new AbstractAction("To JPEG") {
        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:SwingTest.java

/**
 * main entry point for the application. Creates the parent JFrame, the
 * JMenuBar and creates the JPanel which is the application itself.
 *//*from w  ww . j  a  v a2 s .c  om*/
public static void main(String[] args) {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setLightWeightPopupEnabled(false);

    JFrame frame = new JFrame();

    SwingTest swingTest = new SwingTest();
    frame.setJMenuBar(swingTest.createMenuBar());

    frame.getContentPane().add(swingTest);
    frame.setSize(550, 550);
    registerWindowListener(frame);

    frame.setVisible(true);
}

From source file:edu.umich.robot.GuiApplication.java

/**
 * Entry point.//ww  w  . j av a  2 s.c o  m
 * 
 * @param args Args from command line.
 */
public GuiApplication(Config config) {
    // Heavyweight is not desirable but it is the only thing that will
    // render in front of the Viewer on all platforms. Blame OpenGL
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);

    // must have config
    //Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig(frame);
    if (config == null)
        System.exit(1);

    // Add more stuff to the config file that doesn't change between runs.
    Application.setupSimulatorConfig(config);
    setupViewerConfig(config);

    Configs.toLog(logger, config);

    controller = new Controller(config, new Gamepad());
    controller.initializeGamepad();

    viewer = new Viewer(config, frame);
    // This puts us in full 3d mode by default. The Viewer GUI doesn't
    // reflect this in its right click drop-down, a bug.
    viewer.getVisCanvas().getViewManager().setInterfaceMode(3);

    controller.addListener(RobotAddedEvent.class, listener);
    controller.addListener(RobotRemovedEvent.class, listener);
    controller.addListener(AfterResetEvent.class, listener);
    controller.addListener(ControllerActivatedEvent.class, listener);
    controller.addListener(ControllerDeactivatedEvent.class, listener);

    actionManager = new ActionManager(this);
    initActions();

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            controller.shutdown();
            System.exit(0);
        }
    });
    frame.setLayout(new BorderLayout());

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    fileMenu.add(actionManager.getAction(CreateSplinterRobotAction.class));
    fileMenu.add(actionManager.getAction(CreateSuperdroidRobotAction.class));
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(ConnectSuperdroidAction.class));
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(ResetPreferencesAction.class));

    /*
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(TextMessageAction.class));
    */

    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(SaveMapAction.class));
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(ExitAction.class));
    menuBar.add(fileMenu);

    JMenu cameraMenu = new JMenu("Camera");
    cameraMenu.add(actionManager.getAction(DisableFollowAction.class));
    cameraMenu.add(actionManager.getAction(FollowPositionAction.class));
    cameraMenu.add(actionManager.getAction(FollowPositionAndThetaAction.class));
    cameraMenu.add(new JSeparator());
    cameraMenu.add(actionManager.getAction(MoveCameraBehindAction.class));
    cameraMenu.add(actionManager.getAction(MoveCameraAboveAction.class));
    menuBar.add(cameraMenu);

    JMenu objectMenu = new JMenu("Objects");
    boolean added = false;
    for (String objectName : controller.getObjectNames()) {
        added = true;
        objectMenu.add(new AddObjectAction(this, objectName));
    }
    if (!added)
        objectMenu.add(new JLabel("No objects available"));
    menuBar.add(objectMenu);

    menuBar.revalidate();
    frame.setJMenuBar(menuBar);

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    toolBar.add(actionManager.getAction(SoarParametersAction.class));
    toolBar.add(actionManager.getAction(SoarDataAction.class));
    toolBar.add(actionManager.getAction(ResetAction.class));
    toolBar.add(actionManager.getAction(SoarToggleAction.class));
    toolBar.add(actionManager.getAction(SoarStepAction.class));
    toolBar.add(actionManager.getAction(SimSpeedAction.class));
    frame.add(toolBar, BorderLayout.PAGE_START);

    viewerView = new ViewerView(viewer.getVisCanvas());
    robotsView = new RobotsView(this, actionManager);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, viewerView, robotsView);
    splitPane.setDividerLocation(0.75);

    // TODO SoarApril
    /*
    viewer.addRobotSelectionChangedListener(robotsView);
    viewer.getVisCanvas().setDrawGround(true);
    */

    viewer.getVisCanvas().addEventHandler(new VisCanvasEventAdapter() {

        public String getName() {
            return "Place Object";
        }

        @Override
        public boolean mouseClicked(VisCanvas vc, GRay3D ray, MouseEvent e) {
            boolean ret = false;
            synchronized (GuiApplication.this) {
                if (objectToAdd != null && controller != null) {
                    controller.addObject(objectToAdd, ray.intersectPlaneXY());
                    objectToAdd = null;
                    ret = true;
                } else {
                    double[] click = ray.intersectPlaneXY();
                    chatView.setClick(new Point2D.Double(click[0], click[1]));
                }
            }
            status.setMessage(
                    String.format("%3.1f,%3.1f", ray.intersectPlaneXY()[0], ray.intersectPlaneXY()[1]));
            return ret;
        }
    });

    consoleView = new ConsoleView();
    chatView = new ChatView(this);
    controller.getRadio().addRadioHandler(chatView);

    final JSplitPane bottomPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, consoleView, chatView);
    bottomPane.setDividerLocation(200);

    final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane, bottomPane);
    splitPane2.setDividerLocation(0.75);

    frame.add(splitPane2, BorderLayout.CENTER);

    status = new StatusBar();
    frame.add(status, BorderLayout.SOUTH);

    /*
    frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent e)
    {
        final Preferences windowPrefs = getWindowPreferences();
        final Rectangle r = frame.getBounds();
        if(frame.getExtendedState() == JFrame.NORMAL)
        {
            windowPrefs.putInt("x", r.x);
            windowPrefs.putInt("y", r.y);
            windowPrefs.putInt("width", r.width);
            windowPrefs.putInt("height", r.height);
            windowPrefs.putInt("divider", splitPane.getDividerLocation());
        }
                
        exit();
    }});
            
    Preferences windowPrefs = getWindowPreferences();
    if (windowPrefs.get("x", null) != null)
    {
    frame.setBounds(
            windowPrefs.getInt("x", 0), 
            windowPrefs.getInt("y", 0), 
            windowPrefs.getInt("width", 1200), 
            windowPrefs.getInt("height", 900));
    splitPane.setDividerLocation(windowPrefs.getInt("divider", 500));
    }
    else
    {
    frame.setBounds(
            windowPrefs.getInt("x", 0), 
            windowPrefs.getInt("y", 0), 
            windowPrefs.getInt("width", 1200), 
            windowPrefs.getInt("height", 900));
    splitPane.setDividerLocation(0.75);
    frame.setLocationRelativeTo(null); // center
    }
    */

    frame.getRootPane().setBounds(0, 0, 1600, 1200);

    frame.getRootPane().registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);

    frame.pack();

    frame.setVisible(true);

    for (String s : config.getStrings("splinters", new String[0])) {
        double[] pos = config.getDoubles(s + ".position");
        if (pos == null) {
            logger.error("Splinter indexed in config file but no position defined: " + s);
            continue;
        }

        Pose pose = new Pose(pos);
        String prods = config.getString(s + ".productions");
        boolean collisions = config.getBoolean(s + ".wallCollisions", true);

        controller.createSplinterRobot(s, pose, collisions);
        boolean simulated = config.getBoolean(s + ".simulated", true);
        if (simulated)
            controller.createSimSplinter(s);
        else
            controller.createRealSplinter(s);
        controller.createSimLaser(s);
        if (prods != null) {
            controller.createSoarController(s, s, prods, config.getChild(s + ".properties"));
            PREFERENCES.put("lastProductions", prods);
        }
    }

    for (String s : config.getStrings("superdroids", new String[0])) {
        double[] pos = config.getDoubles(s + ".position");
        if (pos == null) {
            logger.error("Superdroid indexed in config file but no position defined: " + s);
            continue;
        }

        Pose pose = new Pose(pos);
        String prods = config.getString(s + ".productions");
        boolean collisions = config.getBoolean(s + ".wallCollisions", true);

        controller.createSuperdroidRobot(s, pose, collisions);
        boolean simulated = config.getBoolean(s + ".simulated", true);
        if (simulated)
            controller.createSimSuperdroid(s);
        else {
            try {
                controller.createRealSuperdroid(s, "192.168.1.165", 3192);
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            } catch (SocketException e1) {
                e1.printStackTrace();
            }
        }
        controller.createSimLaser(s);
        if (prods != null) {
            // wait a sec
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }
            controller.createSoarController(s, s, prods, config.getChild(s + ".properties"));
            PREFERENCES.put("lastProductions", prods);
        }
    }

}

From source file:PrintCanvas3D.java

private PrintCanvas3D(String args[]) {
    this.setTitle("Canvas3D Print Test");

    // Create and initialize menu bar
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    this.setJMenuBar(createMenuBar());

    // Handle the close event
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent winEvent) {
            System.exit(0);//from  w w w  .  j  a  va 2  s . c  om
        }
    });

    // Add main panel to top-level frame and make it visible
    this.getContentPane().add(new AppPanel(args));
    this.pack();
    this.setVisible(true);
}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

void createPopupMenuUI() {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    this.scenePopupMenu = new JPopupMenu();

    JMenuItem trackName = new JMenuItem("Track Name");
    trackName.setEnabled(false);/* ww  w .ja va  2s  .  c om*/
    this.scenePopupMenu.add(trackName);

    JMenuItem sectionName = new JMenuItem("Section name");
    sectionName.setEnabled(false);
    this.scenePopupMenu.add(sectionName);

    this.scenePopupMenu.addSeparator();

    // Mode menu
    JMenu modeMenu = new JMenu("Mode");
    ButtonGroup modeGroup = new ButtonGroup();
    this.normalMode = new JRadioButtonMenuItem("Normal mode");
    this.normalMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/normal.gif")));
    this.normalMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(0);
        }
    });
    this.normalMode.setSelected(true);
    modeGroup.add(this.normalMode);
    modeMenu.add(this.normalMode);

    this.clastMode = new JRadioButtonMenuItem("Create annotation mode");
    this.clastMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/copyright.gif")));
    this.clastMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(3);
        }
    });
    modeGroup.add(this.clastMode);
    modeMenu.add(this.clastMode);

    this.markerMode = new JRadioButtonMenuItem("Modify annotation marker mode");
    this.markerMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/marker.gif")));
    this.markerMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(2);
        }
    });
    modeGroup.add(this.markerMode);
    modeMenu.add(this.markerMode);

    this.measureMode = new JRadioButtonMenuItem("Measure mode");
    this.measureMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/ruler.gif")));
    this.measureMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(1);
        }
    });
    modeGroup.add(this.measureMode);
    modeMenu.add(this.measureMode);

    this.cutMode = new JRadioButtonMenuItem("Cut mode");
    this.cutMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/cut.gif")));
    this.cutMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(4);
        }
    });
    modeGroup.add(this.cutMode);
    modeMenu.add(this.cutMode);

    this.scenePopupMenu.add(modeMenu);

    JMenuItem hideTrackMenuItem = new JMenuItem("Hide track");
    hideTrackMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            doHideTrack();
        }
    });
    this.scenePopupMenu.add(hideTrackMenuItem);

    JMenuItem exportTrackMenuItem = new JMenuItem("Export track");
    exportTrackMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent actionEvent) {
            doExportTrack();
        }
    });
    this.scenePopupMenu.add(exportTrackMenuItem);

    JMenuItem lockSectionMenuItem = new JCheckBoxMenuItem("Lock Section");
    lockSectionMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent actionEvent) {
            AbstractButton b = (AbstractButton) actionEvent.getSource();
            doLockSection(b.getModel().isSelected());
        }
    });

    JMenuItem lockSectionGraphMenuItem = new JCheckBoxMenuItem("Lock Section Graphs");
    lockSectionGraphMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent actionEvent) {
            AbstractButton b = (AbstractButton) actionEvent.getSource();
            doLockSectionGraph(b.getModel().isSelected());
        }
    });

    JMenuItem graphMenuItem = new JMenuItem("Graph...");
    graphMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            doGraphDialog();
        }
    });

    this.propertyMenuItem = new JMenuItem("Properties...");
    this.propertyMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            SectionImagePropertyDialog dialog = new SectionImagePropertyDialog(canvas);
            dialog.setProperties(selectedTrack, selectedTrackSection);
            dialog.pack();
            dialog.setLocationRelativeTo(canvas);
            dialog.setVisible(true);
            dialog.dispose();
        }
    });

    splitMenuItem = new JMenuItem("Split...");
    splitMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            CorelyzerApp app = CorelyzerApp.getApp();
            if (app != null) {
                app.getController().sectionSplit();
            }
        }
    });

    JMenuItem deleteItem = new JMenuItem("Delete...");
    deleteItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent actionEvent) {
            doDeleteSection();
        }
    });

    JMenuItem staggerSectionsItem = new JCheckBoxMenuItem("Stagger Sections", false);
    staggerSectionsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            AbstractButton b = (AbstractButton) e.getSource();
            doStaggerSections(b.getModel().isSelected());
        }
    });

    JMenuItem trimSectionsItem = new JMenuItem("Trim Sections...");
    trimSectionsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            doTrimSections();
        }
    });

    JMenuItem stackSectionsItem = new JMenuItem("Stack Sections");
    stackSectionsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            doStackSections();
        }
    });

    this.scenePopupMenu.addSeparator();
    this.scenePopupMenu.add(lockSectionMenuItem);
    this.scenePopupMenu.add(lockSectionGraphMenuItem);
    this.scenePopupMenu.addSeparator();
    this.scenePopupMenu.add(graphMenuItem);
    this.scenePopupMenu.add(splitMenuItem);
    this.scenePopupMenu.add(propertyMenuItem);
    this.scenePopupMenu.add(deleteItem);
    this.scenePopupMenu.add(staggerSectionsItem);
    this.scenePopupMenu.add(trimSectionsItem);
    this.scenePopupMenu.add(stackSectionsItem);

    CorelyzerApp.getApp().getPluginManager().addPluginPopupSubMenus(this.scenePopupMenu);
}

From source file:com.alvermont.terraj.fracplanet.ui.AbstractTerrainViewerFrame.java

/**
 * Creates new form AbstractTerrainViewerFrame
 *//*from w w  w  . j  av a  2  s. co m*/
public AbstractTerrainViewerFrame() {
    // Globally use heavyweight components for all popup menus. Required
    // because GLCanvas is heavyweight
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    initComponents();

    // randomize the seeds

    Random initRandom = new Random();

    this.allParams.getTerrainParameters().setTerrainSeed(initRandom.nextInt());
    this.allParams.getTerrainParameters().setRiversSeed(initRandom.nextInt());
    this.allParams.getCloudParameters().setSeed(initRandom.nextInt());

    // set look and feel as early as is practicable

    LookAndFeelUtils.getInstance().setSystemLookAndFeel(true, this);

    controlsDialog = new ControlsDialog(this, false);
    cameraPosDialog = new CameraPosDialog(this, false);

    cameraPosDialog.addWindowListener(new MyWindowAdapter(showCameraDialogCheckbox));

    povChooser.addChoosableFileFilter(new POVFilter());
    pngChooser.addChoosableFileFilter(new PNGFileFilter());
    xmlChooser.addChoosableFileFilter(new XMLFileFilter());
    jsChooser.addChoosableFileFilter(new JSFilter());

    // TODO: consider writing a dummy mesh class instead of this. The dummy
    // mesh is used by Javascript when no cloud mesh exists

    TerrainParameters dummyTP = new TerrainParameters();
    dummyTP.setSubdivisions(1);

    dummyMesh = new TriangleMeshTerrainFlat(dummyTP, new DummyProgress(), new MathUtils());

    dummyMesh.getTriangles().clear();
    dummyMesh.getVertices().clear();
}

From source file:com.imag.nespros.gui.plugin.GraphEditor.java

private static void initMenu() {
    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);
            }/*from   ww w.  jav  a2s  .c  o  m*/
        }
    });
    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 topology") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                try {
                    demo.save(file);
                    frame.setTitle(file.getName());
                } catch (IOException ex) {
                    Logger.getLogger(GraphEditor.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });
    menu.add(new AbstractAction("Load topology") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showOpenDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                try {
                    //EPGraph.getInstance().resetMapping();
                    simu.resetMapping();
                    demo.load(file);
                    frame.setTitle("Simulator - " + file.getName());
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(GraphEditor.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });
    JMenu menu2 = new JMenu("View");
    menu2.add(new AbstractAction("Layout") {
        @Override
        public void actionPerformed(ActionEvent e) {
            Layout l = new CircleLayout<Device, ComLink>(Topology.getInstance().getGraph());
            l.setInitializer(vv.getGraphLayout());
            l.setSize(vv.getSize());
            LayoutTransition<Device, ComLink> lt = new LayoutTransition<>(vv, vv.getGraphLayout(), l);
            Animator animator = new Animator(lt);
            animator.start();
            vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
            vv.repaint();
        }
    });
    menu2.add(new AbstractAction("Event Composition Networks") {
        @Override
        public void actionPerformed(ActionEvent e) {
            showEPGraph(EPGraph.getInstance().getGraph());
        }
    });
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    menuBar.add(menu2);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setVisible(true);
    buildEPGraphs();
    showEPGraph(EPGraph.getInstance().getGraph());
}