Package javax.swing

Examples of javax.swing.JMenuItem$MenuItemFocusListener


        _layerHandler = new LayerHandler(_layers);
        _layerHandler.addLayerListener(_mapBean);
        _layersMenu = new LayersMenu(_layerHandler);
        _fileMenu = new JMenu("File");

        _httpExample = new JMenuItem("HTTP Example");
        _httpExample.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    String url = stripExtension(getRemoteFile(), "shp");
                    URL dbf = null, shp = null, shx = null;
                    dbf = new URL(url + ".dbf");
                    shp = new URL(url + ".shp");
                    shx = new URL(url + ".shx");
                    EsriLayer layer = new EsriLayer(url, dbf, shp, shx);
                    _layerHandler.addLayer(layer);
                } catch (Exception exception) {
                    System.out.println(exception);
                }
            }
        });

        _showTable = new JMenuItem("Show Table");
        _showTable.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                EsriLayer layer = pickEsriLayer();
                showTable(layer);
            }
        });

        _setModel = new JMenuItem("Set Model");
        _setModel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                try {
                    _drawableLayer = new EsriLayer("Drawable Layer", 3, 1); //Create
                                                                            // a
                                                                            // polyline
                                                                            // layer
                    _drawableLayer.setName("Drawable Layer");
                    _layerHandler.addLayer(_drawableLayer);
                    DbfTableModel model = new DbfTableModel(1);

                    model.setDecimalCount(0, (byte) 0);
                    model.setLength(0, (byte) 10);
                    model.setColumnName(0, "Column1");
                    model.setType(0, (byte) DbfTableModel.TYPE_CHARACTER);

                    _drawableLayer.setModel(model);
                    _addShape.setEnabled(true);
                    _setModel.setEnabled(false);
                } catch (Exception exception) {
                    System.out.println(exception);
                }

            }
        });

        _addShape = new JMenuItem("Add Shape");
        _addShape.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                EsriPolylineList shapeData = new EsriPolylineList();
                ArrayList tabularData = new ArrayList();
                float[] part0 = new float[] { 35.0f, -120.0f, -25.0f, -95.0f,
                        56.0f, -30.0f };
                float[] part1 = new float[] { -15.0f, -110.0f, 13.0f, -80.0f,
                        -25.0f, 10.0f };
                EsriPolyline poly0 = new EsriPolyline(part0, OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_RHUMB);
                EsriPolyline poly1 = new EsriPolyline(part1, OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_RHUMB);
                shapeData.add(poly0); //part 1
                shapeData.add(poly1); //part 2
                shapeData.generate(_mapBean.getProjection());
                tabularData.add(0, "a value");
                _drawableLayer.addRecord(shapeData, tabularData);
                _drawableLayer.repaint();
            }
        });

        _openFileChooser = new JMenuItem("Add Shape File");
        _openFileChooser.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JFileChooser fileChooser = new JFileChooser();
                fileChooser.setFileFilter(new EsriFilter());
                int returnVal = fileChooser.showOpenDialog(null);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    try {
                        File shp = fileChooser.getSelectedFile();
                        String s = shp.getCanonicalPath();
                        int pos1 = s.lastIndexOf('.');
                        String name = s.substring(0, pos1);
                        File shx = new File(s.substring(0, pos1) + ".shx");
                        File dbf = new File(s.substring(0, pos1) + ".dbf");
                        EsriLayer layer = new EsriLayer(name, dbf.toURL(), shp.toURL(), shx.toURL());
                        _layerHandler.addLayer(layer);
                    } catch (Exception exception) {
                        System.out.println(exception);
                    }
                }
            }
        });

        _exit = new JMenuItem("Exit");
        _exit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });

        _saveFileChooser = new JMenuItem("Save File");
        _saveFileChooser.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                EsriLayer layer = pickEsriLayer();
                if (layer != null) {
                    JFileChooser fileChooser = new JFileChooser();
View Full Code Here


  public TestMenuBar(ActionListener parent)
  {
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
   
    printer = new JMenuItem("Print");
    printer.setMnemonic(KeyEvent.VK_R);
    printer.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
              ActionEvent.CTRL_MASK));
    printer.addActionListener(parent);
    //printer.setEnabled(false);
    file.add(printer);
   
    close = new JMenuItem("Close");
    close.setMnemonic(KeyEvent.VK_Q);
    close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
            ActionEvent.CTRL_MASK));
    close.addActionListener(parent);
    file.add(close);   
   
    view = new JMenu("View");
    view.setMnemonic(KeyEvent.VK_V);

    // This isn't very extensible
    viewFirstPage = new JMenuItem("First Page");
    viewFirstPage.addActionListener(parent);
    view.add(viewFirstPage);
    viewSecondPage = new JMenuItem("Second Page");
    viewSecondPage.addActionListener(parent);
    view.add(viewSecondPage);
   
   
   
    help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    helpTopics = new JMenuItem("Help Topics");
    helpTopics.addActionListener(parent);
    help.add(helpTopics);
   
    about = new JMenu("About");
    about.setMnemonic(KeyEvent.VK_A);
    aboutApp = new JMenuItem("About");
    aboutApp.addActionListener(parent);
    about.add(aboutApp);
   
    add(file);
    add(view);  
View Full Code Here

           
            if (!buttonBrowse.isEnabled()) return;
           
            DcPopupMenu popup = new DcPopupMenu();
           
            JMenuItem miClear = ComponentFactory.getMenuItem(IconLibrary._icoDelete, DcResources.getText("lblClearField"));
            miClear.addActionListener(this);
            miClear.setActionCommand("clear");
            miClear.setEnabled(file != null);

            JMenuItem miDelete = ComponentFactory.getMenuItem(IconLibrary._icoDelete, DcResources.getText("lblDeleteFile"));
            miDelete.addActionListener(this);
            miDelete.setActionCommand("deleteFile");
            miDelete.setEnabled(file != null && file.exists());

            JMenuItem miMove = ComponentFactory.getMenuItem(DcResources.getText("lblMoveFile"));
            miMove.addActionListener(this);
            miMove.setActionCommand("moveFile");
            miMove.setEnabled(file != null && file.exists());

            JMenuItem miLocateHP = ComponentFactory.getMenuItem(IconLibrary._icoDriveScanner, DcResources.getText("lblLocateFile", DcResources.getText("lblMatchOnHashAndSize")));
            miLocateHP.addActionListener(this);
            miLocateHP.setActionCommand("locateFileHP");
            miLocateHP.setEnabled(file != null && !file.exists() && parent != null);
           
            JMenuItem miLocateMP = ComponentFactory.getMenuItem(IconLibrary._icoDriveScanner, DcResources.getText("lblLocateFile", DcResources.getText("lblMatchOnFilenameAndSize")));
            miLocateMP.addActionListener(this);
            miLocateMP.setActionCommand("locateFileMP");
            miLocateMP.setEnabled(file != null && !file.exists() && parent != null);           

            JMenuItem miLocateLP = ComponentFactory.getMenuItem(IconLibrary._icoDriveScanner, DcResources.getText("lblLocateFile", DcResources.getText("lblMatchOnFilename")));
            miLocateLP.addActionListener(this);
            miLocateLP.setActionCommand("locateFileLP");
            miLocateLP.setEnabled(file != null && !file.exists() && parent != null);           
           
            popup.add(miClear);
            popup.addSeparator();
            popup.add(miDelete);
           
View Full Code Here

   
    private void installMenu() {
        JMenuBar mb = ComponentFactory.getMenuBar();
        JMenu menu = ComponentFactory.getMenu(DcResources.getText("lblEdit"));
       
        JMenuItem miCreate = ComponentFactory.getMenuItem(IconLibrary._icoAdd, DcResources.getText("lblAddLanguage"));
        miCreate.setActionCommand("addLanguage");
        miCreate.addActionListener(this);
       
        menu.add(miCreate);
        mb.add(menu);
       
        setJMenuBar(mb);
View Full Code Here

import net.datacrow.core.resources.DcResources;

public class DcFileRenamerPopupMenu extends DcPopupMenu   {
   
    public DcFileRenamerPopupMenu(DcFilePatternField fpf, int modIdx) {
        JMenuItem menuInsertText = ComponentFactory.getMenuItem(DcResources.getText("lblInsertText"));
        JMenuItem menuInsertDir = ComponentFactory.getMenuItem(DcResources.getText("lblInsertDirectory"));
        JMenuItem menuRemove = ComponentFactory.getMenuItem(DcResources.getText("lblRemove"));

        JMenu menuInsertField = ComponentFactory.getMenu(DcResources.getText("lblInsertField"));
       
        DcModule module = DcModules.get(modIdx);
        for (DcField field : DcModules.get(modIdx).getFields()) {
           
          if (field.getIndex() == DcObject._SYS_CONTAINER)
            continue;
         
            if (field.getIndex() == module.getParentReferenceFieldIndex()) {
              JMenuItem menuField = ComponentFactory.getMenuItemmodule.getParent().getObjectName());
                menuField.setActionCommand(String.valueOf(field.getIndex()));
                menuField.addActionListener(fpf);
                menuInsertField.add(menuField);
            } else if (isValid(field)) {
                JMenuItem menuField = ComponentFactory.getMenuItem(field.getSystemName());
                menuField.setActionCommand(String.valueOf(field.getIndex()));
                menuField.addActionListener(fpf);
                menuInsertField.add(menuField);
            }
        }
       
        menuInsertText.setActionCommand("insertText");
View Full Code Here

    private JTextComponent c;
   
    public DcEditorPopupMenu(JTextComponent c) {
        this.c = c;
       
        JMenuItem menuCut = ComponentFactory.getMenuItem(IconLibrary._icoCut, DcResources.getText("lblCut"));
        JMenuItem menuCopy =ComponentFactory.getMenuItem(IconLibrary._icoCopy, DcResources.getText("lblCopy"));
        JMenuItem menuPaste = ComponentFactory.getMenuItem(IconLibrary._icoPaste, DcResources.getText("lblPaste"));
        JMenuItem menuSelectAll = ComponentFactory.getMenuItem(DcResources.getText("lblSelectAll"));
        
        boolean isEditable = c.isEditable();
        boolean isTextSelected = c.getSelectedText() != null;

        menuCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
        menuCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
        menuPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK));
        menuSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));

        menuSelectAll.setActionCommand("selectAll");
        menuPaste.setActionCommand("paste");
        menuCopy.setActionCommand("copy");       
        menuCut.setActionCommand("cut");       
       
        if (isEditable && isTextSelected)
            menuCut.addActionListener(this);
        else
            menuCut.setEnabled(false);
       
        if (isTextSelected)
            menuCopy.addActionListener(this);
        else
            menuCopy.setEnabled(false);
       
        Transferable content = tk.getSystemClipboard().getContents(null);
        if (isEditable && content.isDataFlavorSupported(DataFlavor.stringFlavor))
            menuPaste.addActionListener(this);
        else
            menuPaste.setEnabled(false);
       
        if (    c.getText().length() > 0 &&
               (c.getSelectedText() == null ||
                c.getSelectedText().length() < c.getText().length())) {
           
            menuSelectAll.addActionListener(this);
        } else {
            menuSelectAll.setEnabled(false);
        }

        this.add(menuCut);
        this.add(menuCopy);
        this.add(menuPaste);
View Full Code Here

      protected ModulePermissionMenu(FieldPermissionPanel panel) {
        this.panel = panel;
       
        JMenu mnuEdit = ComponentFactory.getMenu(DcResources.getText("lblEdit"));
       
        JMenuItem miAllowViewAll = ComponentFactory.getMenuItem(DcResources.getText("lblAllowViewAll"));
        JMenuItem miAllowEditAll = ComponentFactory.getMenuItem(DcResources.getText("lblAllowEditAll"));
        JMenuItem miDenyAccess = ComponentFactory.getMenuItem(DcResources.getText("lblDenyModuleAccess"));
       
        miAllowViewAll.setActionCommand("viewAll");
        miAllowEditAll.setActionCommand("editAll");
        miDenyAccess.setActionCommand("denyAll");
       
        miAllowViewAll.addActionListener(this);
        miAllowEditAll.addActionListener(this);
        miDenyAccess.addActionListener(this);
       
        mnuEdit.add(miAllowViewAll);
        mnuEdit.add(miAllowEditAll);
        mnuEdit.add(miDenyAccess);
       
View Full Code Here

     * displayed in a popup menu. You have to do the wiring for making the list
     * components do something, though.
     */
    public List getItemsForMapMenu(MapMouseEvent me) {
        List l = new ArrayList();
        JMenuItem when = new JMenuItem("When");
        when.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                fireRequestMessage("When was chosen.");
            }
        });
        JMenuItem where = new JMenuItem("Where");
        where.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                fireRequestMessage("Where was chosen.");
            }
        });
        JMenuItem how = new JMenuItem("How");
        how.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                fireRequestMessage("How was chosen.");
            }
        });

View Full Code Here

     * something, though.
     */
    public List getItemsForOMGraphicMenu(OMGraphic omg) {
        final OMGraphic chosen = omg;
        List l = new ArrayList();
        JMenuItem which = new JMenuItem("Which");
        which.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                String classname = chosen.getClass().getName();
                fireRequestMessage("Which was chosen over "
                        + classname.substring(classname.lastIndexOf('.') + 1));
            }
        });
        JMenuItem why = new JMenuItem("Why");
        why.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                String classname = chosen.getClass().getName();
                fireRequestMessage("Why was chosen over "
                        + classname.substring(classname.lastIndexOf('.') + 1));
            }
View Full Code Here

        }
    }

    public List getItemsForMapMenu(MapMouseEvent me) {
        List l = new ArrayList();
        l.add(new JMenuItem("When"));
        l.add(new JMenuItem("Where"));
        l.add(new JMenuItem("How"));
        return l;
    }
View Full Code Here

TOP

Related Classes of javax.swing.JMenuItem$MenuItemFocusListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.