Example usage for java.awt.event KeyAdapter KeyAdapter

List of usage examples for java.awt.event KeyAdapter KeyAdapter

Introduction

In this page you can find the example usage for java.awt.event KeyAdapter KeyAdapter.

Prototype

KeyAdapter

Source Link

Usage

From source file:ec.util.chart.swing.JTimeSeriesChart.java

private void enableRevealObs() {
    chartPanel.addKeyListener(new KeyAdapter() {
        @Override/*  w  ww .j av  a  2 s . c  om*/
        public void keyPressed(KeyEvent e) {
            if (isInteractive() && e.getKeyChar() == 'r') {
                setRevealObs(true);
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (isInteractive() && e.getKeyChar() == 'r') {
                setRevealObs(false);
            }
        }
    });
}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_//from  ww w.  ja  v  a2s. c  o m
 *
 * @return _more_
 *
 * @throws RemoteException _more_
 * @throws VisADException _more_
 */
public JComponent doMakeViewpointPanel() throws VisADException, RemoteException {

    JSlider speedSlider = new JSlider(1, 200, 200 - animationSpeed);
    speedSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider slider = (JSlider) e.getSource();
            if (!slider.getValueIsAdjusting()) {
                animationSpeed = 200 - slider.getValue() + 1;
            }
        }
    });

    showTimesCbx = new JCheckBox("Set Animation Time", showTimes);
    showTimesCbx.setEnabled(hasTimes);
    animateCbx = new JCheckBox("Animated", animate);
    changeViewpointCbx = new JCheckBox("Change Viewpoint", changeViewpoint);

    orients = new Vector<TwoFacedObject>();
    orients.add(new TwoFacedObject("Towards Next Point", ORIENT_POINT));
    orients.add(new TwoFacedObject("Forward", ORIENT_FORWARD));
    orients.add(new TwoFacedObject("Up", ORIENT_UP));
    orients.add(new TwoFacedObject("Down", ORIENT_DOWN));
    orients.add(new TwoFacedObject("Left", ORIENT_LEFT));
    orients.add(new TwoFacedObject("Right", ORIENT_RIGHT));
    orientBox = new JComboBox(orients);
    orientBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            orientation = TwoFacedObject.getIdString(orientBox.getSelectedItem());
            goToCurrent();
        }
    });

    if (animationInfo == null) {
        animationInfo = new AnimationInfo();
        animationInfo.setShareIndex(true);
    }

    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            Misc.run(Flythrough.this, "goToCurrent");
        }
    };

    //xxxxx

    animationWidget = new AnimationWidget(null, null, animationInfo);

    if ((getShareGroup() == null) || getShareGroup().equals(SharableManager.GROUP_ALL)) {
        setShareGroup("flythrough");
    }
    animationWidget.setShareGroup(getShareGroup());
    animationWidget.setSharing(getSharing());

    animation = new Animation();
    animation.setAnimationInfo(animationInfo);
    animation.addPropertyChangeListener(this);
    animationWidget.setAnimation(animation);

    locationMarker = new SelectorPoint("flythrough.point",
            ShapeUtility.setSize(ShapeUtility.createShape(ShapeUtility.AIRPLANE3D)[0], .1f),
            new RealTuple(RealTupleType.SpatialCartesian3DTuple, new double[] { 0, 0, 0 }));

    locationMarker.setAutoSize(true);
    locationMarker.setManipulable(false);
    locationMarker.setColor(Color.green);
    locationMarker.setVisible(false);

    locationLine = new LineDrawing("flythroughpoint.line");
    locationLine.setVisible(false);
    locationLine.setLineWidth(2);
    locationLine.setColor(Color.green);

    //        locationLine2 = new LineDrawing("flythroughpoint.line2");
    //        locationLine2.setVisible(false);
    //        locationLine2.setLineWidth(2);
    //        locationLine2.setColor(Color.red);
    //        viewManager.getMaster().addDisplayable(locationLine2);

    Misc.runInABit(2000, this, "setScaleOnMarkers", null);

    viewManager.getMaster().addDisplayable(locationMarker);
    viewManager.getMaster().addDisplayable(locationLine);

    readout = new CursorReadoutWindow(viewManager, false);

    //zoomFld = new JTextField(zoom + "", 5);
    zoomFld = new JTextField(Misc.format(zoom), 5);

    for (int i = 0; i < tilt.length; i++) {
        final int theIndex = i;
        tiltSliders[i] = new JSlider(-90, 90, (int) tilt[i]);
        tiltSliders[i].setToolTipText("Control-R: reset");
        tiltSliders[i].addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) {
                    tilt[theIndex] = 0;
                    tiltLabels[theIndex].setText("" + (int) tilt[theIndex]);
                    tiltSliders[theIndex].setValue(0);
                    goToCurrent();
                }
            }
        });

        tiltLabels[i] = new JLabel("" + (int) tilt[i]);
        tiltSliders[i].addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                JSlider slider = (JSlider) e.getSource();
                tiltLabels[theIndex].setText("" + slider.getValue());
                if (!slider.getValueIsAdjusting()) {
                    tilt[theIndex] = slider.getValue();
                    goToCurrent();
                }
            }
        });
    }

    zoomFld.addActionListener(listener);

    fixedZCbx = GuiUtils.makeCheckbox("Use fixed Z", this, "useFixedZ");
    GuiUtils.tmpInsets = GuiUtils.INSETS_5;
    JComponent orientationComp = GuiUtils.formLayout(new Component[] { GuiUtils.filler(),
            GuiUtils.left(changeViewpointCbx), GuiUtils.rLabel("Tilt Down/Up:"),
            GuiUtils.centerRight(tiltSliders[0], tiltLabels[0]), GuiUtils.rLabel("Tilt Left/Right:"),
            GuiUtils.centerRight(tiltSliders[1], tiltLabels[1]), GuiUtils.rLabel("Zoom:"),
            GuiUtils.left(zoomFld), GuiUtils.rLabel("Orientation:"),
            GuiUtils.left(GuiUtils.hbox(orientBox, (doGlobe() ? GuiUtils.filler() : (JComponent) fixedZCbx))),
            //            GuiUtils.rLabel("Tilt Down/Up:"), GuiUtils.centerRight(tiltSliders[2],tiltLabels[2]),

            GuiUtils.rLabel("Transitions:"),
            GuiUtils.vbox(GuiUtils.left(animateCbx), GuiUtils.leftCenter(new JLabel("Speed"), speedSlider)),
            GuiUtils.filler(), GuiUtils.left(showTimesCbx), });

    return GuiUtils.top(orientationComp);

}

From source file:com.all.login.view.NewAccountFormPanel.java

private JPasswordField getPasswordTextField() {
    if (passwordTextField == null) {
        passwordTextField = new JPasswordField();
        passwordTextField.setBounds(PASSWORD_TEXTFIELD_BOUNDS);
        passwordTextField.setSelectionColor(COLOR_SELECTION_TEXTFIELDS);
        passwordTextField.setName(PASSWORD_TEXT_FIELD_NAME);
        passwordTextField.setEchoChar('\u25CF');
        passwordTextField.addKeyListener(new KeyAdapter() {
            @Override/*from www  .j  a va2s  .  c o m*/
            public void keyReleased(KeyEvent e) {
                validatePasswordStrength();
                String password = new String(passwordTextField.getPassword());
                getUser().setPassword(password);
                boolean validSize = passwordFieldValidator.isPasswordSizeAllowed(password);
                passwordFieldValidator.passwordRenameValidate(passwordTextField, PASSWORD_TEXT_FIELD_NAME,
                        validSize, messages);
                validateAllUserData();
            }
        });
        passwordTextField.addKeyListener(new DisableCopyPasteKey());
        passwordTextField.setDocument(new JTextFieldLimit(RegisterUserCommand.MAXIMUM_PASSWORD_SIZE));
    }
    return passwordTextField;
}

From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java

private void initKeyListener() {
    //key listener
    thumbnailList.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_UP)) {
                moveUpButton.doClick();/*from w  w  w .j  a  v  a  2 s  . c o m*/
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_DOWN)) {
                moveDownButton.doClick();
            } else if ((e.getKeyCode() == KeyEvent.VK_DELETE)) {
                removeButton.doClick();
            } else if (drawDeletedItems && (e.isControlDown()) && (e.getKeyCode() == KeyEvent.VK_Z)) {
                undeleteButton.doClick();
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_RIGHT)) {
                rotateButton.doClick();
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_LEFT)) {
                rotateAntiButton.doClick();
            }
        }
    });
}

From source file:SuitaDetails.java

public void setParent(Item parent) {
    //if(this.parent==parent)return;
    this.parent = parent;
    if (parent != null && parent.getType() == 2) {
        try {//from   www .  j ava  2s .c  om
            setComboTBs();
            tsuite.setText(parent.getName());
            KeyListener k[] = combo.getKeyListeners();
            for (KeyListener t : k) {
                tsuite.removeKeyListener(t);
            }
            tsuite.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent ev) {
                    String name = tsuite.getText();
                    FontMetrics metrics = getGraphics().getFontMetrics(new Font("TimesRoman", Font.BOLD, 14));
                    int width = metrics.stringWidth(name) + 40;
                    getItemParent().setName(name);
                    getItemParent().getRectangle().setSize(width,
                            (int) getItemParent().getRectangle().getHeight());
                    if (getItemParent().isVisible())
                        RunnerRepository.window.mainpanel.p1.sc.g.updateLocations(getItemParent());
                    RunnerRepository.window.mainpanel.p1.sc.g.repaint();
                }
            });
            panicdetect.setSelected(parent.isPanicdetect());
        } catch (Exception e) {
            System.out.println("There was a problem in getting ep list");
            e.printStackTrace();
        }
        for (int i = 0; i < definitions.size(); i++) {
            definitions.get(i).setParent(parent);
        }
    }
    if (parent != null && parent.getType() == 1) {
        if (parent.isRunnable())
            runnable.setSelected(true);
        else
            runnable.setSelected(false);
        if (parent.isOptional())
            optional.setSelected(true);
        else
            optional.setSelected(false);
        if (parent.isPrerequisite())
            prerequisites.setSelected(true);
        else
            prerequisites.setSelected(false);
        if (parent.isTeardown())
            teardown.setSelected(true);
        else
            teardown.setSelected(false);
        ttcname.setText(getItemParent().getName());
        if (parent.isClearcase()) {
            tview.setText(RunnerRepository.window.mainpanel.getP5().view);
        } else {
            tview.setText("");
        }
        KeyListener k[] = ttcname.getKeyListeners();
        for (KeyListener t : k) {
            ttcname.removeKeyListener(t);
        }
        ttcname.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent ev) {
                String name = ttcname.getText();
                FontMetrics metrics = getGraphics().getFontMetrics(new Font("TimesRoman", Font.BOLD, 14));
                int width = metrics.stringWidth(name) + 20;
                getItemParent().setName(name);
                getItemParent().getRectangle().setSize(width, (int) getItemParent().getRectangle().getHeight());
                if (getItemParent().isVisible())
                    RunnerRepository.window.mainpanel.p1.sc.g.updateLocations(getItemParent());
                RunnerRepository.window.mainpanel.p1.sc.g.repaint();
            }
        });
        ActionListener[] s = runnable.getActionListeners();
        for (ActionListener a : s) {
            runnable.removeActionListener(a);
        }
        runnable.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                if (runnable.isSelected())
                    getItemParent().setRunnable(true);
                else
                    getItemParent().setRunnable(false);
                RunnerRepository.window.mainpanel.p1.sc.g.repaint();
            }
        });
        s = optional.getActionListeners();
        for (ActionListener a : s) {
            optional.removeActionListener(a);
        }
        optional.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                if (optional.isSelected()) {
                    getItemParent().setOptional(true);
                    RunnerRepository.window.mainpanel.p1.sc.g.unsetPrerequisite(getItemParent());
                    prerequisites.setSelected(false);
                } else
                    getItemParent().setOptional(false);
                RunnerRepository.window.mainpanel.p1.sc.g.repaint();
            }
        });
        s = prerequisites.getActionListeners();
        for (ActionListener a : s) {
            prerequisites.removeActionListener(a);
        }
        prerequisites.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                if (prerequisites.isSelected()) {
                    RunnerRepository.window.mainpanel.p1.sc.g.setPreRequisites(getItemParent());
                } else {
                    RunnerRepository.window.mainpanel.p1.sc.g.unsetPrerequisite(getItemParent());
                }
            }
        });

        s = teardown.getActionListeners();
        for (ActionListener a : s) {
            teardown.removeActionListener(a);
        }
        teardown.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                if (teardown.isSelected()) {
                    //getItemParent().setPrerequisite(false);
                    RunnerRepository.window.mainpanel.p1.sc.g.setTeardown(getItemParent());
                } else {
                    RunnerRepository.window.mainpanel.p1.sc.g.unsetTeardown(getItemParent());
                }
            }
        });
        prop.setParent(getItemParent());
        param.setParent(getItemParent());
    }
}

From source file:com.all.login.view.NewAccountFormPanel.java

JTextField getEmailTextField() {
    if (emailTextField == null) {
        emailTextField = new JTextField();
        emailTextField.setBounds(EMAIL_TEXTFIELD_BOUNDS);
        emailTextField.setSelectionColor(COLOR_SELECTION_TEXTFIELDS);
        emailTextField.setName(EMAIL_TEXT_FIELD_NAME);
        final LowercaseFocusListener emailListener = new LowercaseFocusListener(emailTextField,
                EMAIL_FIELD_NAME);/*w w w .j  a  v  a2s  .  co m*/
        emailTextField.addFocusListener(emailListener);
        emailTextField.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                int caretPosition = emailTextField.getCaretPosition();
                if (emailTextField.getName().startsWith(INVALID_FIELD_NAME)) {
                    emailListener.focusLost(null);
                }
                validateAllUserData();
                emailTextField.setCaretPosition(caretPosition);
            }
        });
        InputMap map = emailTextField.getInputMap(JTextField.WHEN_FOCUSED);
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.VK_CONTROL), null);
        emailTextField.addKeyListener(new CopyPasteKeyAdapterForMac());
    }
    return emailTextField;
}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_// w w  w. j ava 2 s  . c o  m
 *
 * @return _more_
 */
public JComponent doMakePointsPanel() {

    pointTableModel = new FlythroughTableModel(this);
    pointTable = new JTable(pointTableModel);
    pointTable.setToolTipText("Double click: view; Control-P: Show point properties; Delete: delete point");

    pointTable.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if ((e.getKeyCode() == KeyEvent.VK_P) && e.isControlDown()) {
                List<FlythroughPoint> newPoints = new ArrayList<FlythroughPoint>();
                int[] rows = pointTable.getSelectedRows();
                List<FlythroughPoint> oldPoints = pointsToUse;
                for (int j = 0; j < rows.length; j++) {
                    FlythroughPoint pt = oldPoints.get(rows[j]);
                    if (!showProperties(pt)) {
                        break;
                    }
                    pointTable.repaint();
                }
            }

            if (GuiUtils.isDeleteEvent(e)) {
                List<FlythroughPoint> newPoints = new ArrayList<FlythroughPoint>();
                int[] rows = pointTable.getSelectedRows();
                List<FlythroughPoint> oldPoints = pointsToUse;
                for (int i = 0; i < oldPoints.size(); i++) {
                    boolean good = true;
                    for (int j = 0; j < rows.length; j++) {
                        if (i == rows[j]) {
                            good = false;
                            break;
                        }
                    }
                    if (good) {
                        newPoints.add(oldPoints.get(i));
                    }
                }
                flythrough(newPoints);
            }
        }
    });

    pointTable.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            final int row = pointTable.rowAtPoint(e.getPoint());
            if ((row < 0) || (row >= pointsToUse.size())) {
                return;
            }
            if (e.getClickCount() > 1) {
                animation.setCurrent(row);
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(pointTable);
    scrollPane.setPreferredSize(new Dimension(400, 300));
    return scrollPane;

}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_/*from w ww.  j a v a 2 s .co  m*/
 *
 * @return _more_
 */
public JComponent doMakeDashboardPanel() {
    dashboardImage = GuiUtils.getImage("/auxdata/ui/icons/cockpit.gif", getClass(), false);
    pipPanel = new PipPanel(viewManager);
    pipPanel.getNavigatedPanel().setBorder(null);
    pipPanel.setPreferredSize(new Dimension(100, 100));
    pipPanel.doLayout();
    pipPanel.validate();
    pipFrame = new JFrame("Show remain invisible");
    pipFrame.setContentPane(pipPanel);
    pipFrame.pack();

    dashboardLbl = new JLabel(new ImageIcon(dashboardImage)) {
        public void paint(Graphics g) {
            //                readPts();
            paintDashboardBackground(g, dashboardLbl);
            super.paint(g);
            paintDashboardAfter(g, dashboardLbl);
        }
    };
    dashboardLbl.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            pipPanel.keyPressedInMap(e);
            updateDashboard();
        }
    });

    dashboardLbl.setVerticalAlignment(SwingConstants.BOTTOM);
    MouseAdapter mouseAdapter = new MouseAdapter() {
        Point mouseStart = new Point(0, 0);
        Point originalOffset = new Point(0, 0);

        public void mouseClicked(MouseEvent me) {
            if (pipRect == null) {
                return;
            }
            if (goToClick && pipRect.contains(new Point(me.getX(), me.getY()))) {
                try {
                    int x = me.getX() - pipRect.x;
                    int y = me.getY() - pipRect.y;
                    //                        System.err.println ("x:" + x +" y:" + y);
                    LatLonPoint llp = pipPanel.screenToLatLon(x, y);
                    location = makePoint(llp.getLatitude(), llp.getLongitude(), 0);
                    doDrive(false, heading);
                } catch (Exception exc) {
                    logException("Driving", exc);
                }
            }
        }

        public void mousePressed(MouseEvent me) {
            dashboardLbl.requestFocus();
            originalOffset = new Point(dashboardImageOffset);
            mouseStart.x = me.getX();
            mouseStart.y = me.getY();
            Rectangle b = dashboardLbl.getBounds();
            int w = dashboardImage.getWidth(null);
            int h = dashboardImage.getHeight(null);
            Point ul = new Point(b.width / 2 - w / 2, b.height - h);
            //                System.out.println("{" + (me.getX()-ul.x) +",  " + (me.getY()-ul.y)+"}");
        }

        public void mouseDragged(MouseEvent me) {
            dashboardImageOffset.x = originalOffset.x + me.getX() - mouseStart.x;
            dashboardImageOffset.y = originalOffset.y + me.getY() - mouseStart.y;
            updateDashboard();
        }
    };

    dashboardLbl.addMouseListener(mouseAdapter);
    dashboardLbl.addMouseMotionListener(mouseAdapter);

    //Create ome charts to force classloading (which takes some time) in a thread
    //So the gui shows quicker
    Misc.run(new Runnable() {
        public void run() {
            try {
                MeterPlot plot = new MeterPlot(new DefaultValueDataset(new Double(1)));
                createChart(new XYSeriesCollection());
            } catch (Exception ignore) {
            }
        }
    });

    return dashboardLbl;
}

From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java

private JTable getTrackTable() {
    if (trackTable == null) {
        trackTable = new JTable();
        trackTable.setModel(new TrackTableModel(this));
        trackTable.addMouseListener(new MouseAdapter() {
            public void mouseReleased(MouseEvent evt) {
                TrackProfilerFrame.this.setSelectedPoint();
            }/*from   w  ww .  j  a v a 2  s  . c  o  m*/
            //                public void mouseClicked(MouseEvent evt) {
            //                    TrackProfilerFrame.this.setSelectedPoint();
            //                }
        });
        trackTable.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent evt) {
                TrackProfilerFrame.this.setSelectedPoint();
            }
        });
    }
    return trackTable;
}

From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java

/**
 * Singleton pattern : private constructor Use instead.
 *//*from   w w  w  .  java  2s .c  o  m*/
private MMMainFrame() {
    super(NODE_NAME, false, true, false, true);
    instancing = true;
    // --------------
    // INITIALIZATION
    // --------------
    _sysConfigFile = "";
    _isConfigLoaded = false;
    _root = PluginPreferences.getPreferences().node(NODE_NAME);
    final MainFrame mainFrame = Icy.getMainInterface().getMainFrame();

    // --------------
    // PROGRESS FRAME
    // --------------
    ThreadUtil.invokeLater(new Runnable() {
        @Override
        public void run() {
            _progressFrame = new IcyFrame("", false, false, false, false);
            _progressBar = new JProgressBar();
            _progressBar.setString("Please wait while loading...");
            _progressBar.setStringPainted(true);
            _progressBar.setIndeterminate(true);
            _progressBar.setMinimum(0);
            _progressBar.setMaximum(1000);
            _progressBar.setBounds(50, 50, 100, 30);
            _progressFrame.setSize(300, 100);
            _progressFrame.setResizable(false);
            _progressFrame.add(_progressBar);
            _progressFrame.addToMainDesktopPane();
            loadConfig(true);
            if (_sysConfigFile == "") {
                instancing = false;
                return;
            }
            ThreadUtil.bgRun(new Runnable() {

                @Override
                public void run() {
                    while (!_isConfigLoaded) {
                        if (!instancing)
                            return;
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                        }
                    }
                    ThreadUtil.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            // --------------------
                            // START INITIALIZATION
                            // --------------------
                            if (_progressBar != null)
                                getContentPane().remove(_progressBar);
                            if (mCore == null) {
                                close();
                                return;
                            }

                            // ReportingUtils.setCore(mCore);
                            _afMgr = new AutofocusManager(MMMainFrame.this);
                            acqMgr = new AcquisitionManager();
                            PositionList posList = new PositionList();

                            _camera_label = MMCoreJ.getG_Keyword_CameraName();
                            if (_camera_label == null)
                                _camera_label = "";
                            try {
                                setPositionList(posList);
                            } catch (MMScriptException e1) {
                                e1.printStackTrace();
                            }
                            posListDlg_ = new PositionListDlg(mCore, MMMainFrame.this, _posList, null, dlg);
                            posListDlg_.setModalityType(ModalityType.APPLICATION_MODAL);

                            callback = new EventCallBackManager();
                            mCore.registerCallback(callback);

                            engine_ = new AcquisitionWrapperEngineIcy();
                            engine_.setParentGUI(MMMainFrame.this);
                            engine_.setCore(mCore, getAutofocusManager());
                            engine_.setPositionList(getPositionList());

                            setSystemMenuCallback(new MenuCallback() {

                                @Override
                                public JMenu getMenu() {
                                    JMenu toReturn = MMMainFrame.this.getDefaultSystemMenu();
                                    JMenuItem hconfig = new JMenuItem("Configuration Wizard");
                                    hconfig.setIcon(new IcyIcon("cog", MENU_ICON_SIZE));

                                    hconfig.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            if (!_pluginListEmpty && !ConfirmDialog.confirm("Are you sure ?",
                                                    "<html>Loading the Configuration Wizard will unload all the devices and pause all running acquisitions.</br> Are you sure you want to continue ?</html>"))
                                                return;
                                            notifyConfigAboutToChange(null);
                                            try {
                                                mCore.unloadAllDevices();
                                            } catch (Exception e1) {
                                                e1.printStackTrace();
                                            }
                                            String previous_config = _sysConfigFile;
                                            ConfiguratorDlg2 configurator = new ConfiguratorDlg2(mCore,
                                                    _sysConfigFile);
                                            configurator.setVisible(true);
                                            String res = configurator.getFileName();
                                            if (_sysConfigFile == "" || _sysConfigFile == res || res == "") {
                                                _sysConfigFile = previous_config;
                                                loadConfig();
                                            }
                                            refreshGUI();
                                            notifyConfigChanged(null);
                                        }
                                    });

                                    JMenuItem menuPxSizeConfigItem = new JMenuItem("Pixel Size Config");
                                    menuPxSizeConfigItem.setIcon(new IcyIcon("link", MENU_ICON_SIZE));
                                    menuPxSizeConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    menuPxSizeConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            CalibrationListDlg dlg = new CalibrationListDlg(mCore);
                                            dlg.setDefaultCloseOperation(2);
                                            dlg.setParentGUI(MMMainFrame.this);
                                            dlg.setVisible(true);
                                            dlg.addWindowListener(new WindowAdapter() {
                                                @Override
                                                public void windowClosed(WindowEvent e) {
                                                    super.windowClosed(e);
                                                    notifyConfigChanged(null);
                                                }
                                            });
                                            notifyConfigAboutToChange(null);
                                        }
                                    });

                                    JMenuItem loadConfigItem = new JMenuItem("Load Configuration");
                                    loadConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    loadConfigItem.setIcon(new IcyIcon("folder_open", MENU_ICON_SIZE));
                                    loadConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            loadConfig();
                                            initializeGUI();
                                            refreshGUI();
                                        }
                                    });
                                    JMenuItem saveConfigItem = new JMenuItem("Save Configuration");
                                    saveConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    saveConfigItem.setIcon(new IcyIcon("save", MENU_ICON_SIZE));
                                    saveConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            saveConfig();
                                        }
                                    });
                                    JMenuItem advancedConfigItem = new JMenuItem("Advanced Configuration");
                                    advancedConfigItem.setIcon(new IcyIcon("wrench_plus", MENU_ICON_SIZE));
                                    advancedConfigItem.addActionListener(new ActionListener() {

                                        /**
                                         */
                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            new ToolTipFrame(
                                                    "<html><h3>About Advanced Config</h3><p>Advanced Configuration is a tool "
                                                            + "in which you fill some data <br/>about your configuration that some "
                                                            + "plugins may need to access to.<br/> Exemple: the real values of the magnification"
                                                            + "of your objectives.</p></html>",
                                                    "MM4IcyAdvancedConfig");
                                            if (advancedDlg == null)
                                                advancedDlg = new AdvancedConfigurationDialog();
                                            advancedDlg.setVisible(!advancedDlg.isVisible());
                                            advancedDlg.setLocationRelativeTo(mainFrame);
                                        }
                                    });
                                    JMenuItem loadPresetConfigItem = new JMenuItem(
                                            "Load Configuration Presets");
                                    loadPresetConfigItem.setIcon(new IcyIcon("doc_import", MENU_ICON_SIZE));
                                    loadPresetConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            notifyConfigAboutToChange(null);
                                            loadPresets();
                                            notifyConfigChanged(null);
                                        }
                                    });
                                    JMenuItem savePresetConfigItem = new JMenuItem(
                                            "Save Configuration Presets");
                                    savePresetConfigItem.setIcon(new IcyIcon("doc_export", MENU_ICON_SIZE));
                                    savePresetConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            savePresets();
                                        }
                                    });
                                    JMenuItem aboutItem = new JMenuItem("About");
                                    aboutItem.setIcon(new IcyIcon("info", MENU_ICON_SIZE));
                                    aboutItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            final JDialog dialog = new JDialog(mainFrame, "About");
                                            JPanel panel_container = new JPanel();
                                            panel_container
                                                    .setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
                                            JPanel center = new JPanel(new BorderLayout());
                                            final JLabel value = new JLabel("<html><body>"
                                                    + "<h2>About</h2><p>Micro-Manager for Icy is being developed by Thomas Provoost."
                                                    + "<br/>Copyright 2011, Institut Pasteur</p><br/>"
                                                    + "<p>This plugin is based on Micro-Manager v1.4.6. which is developed under the following license:<br/>"
                                                    + "<i>This software is distributed free of charge in the hope that it will be<br/>"
                                                    + "useful, but WITHOUT ANY WARRANTY; without even the implied<br/>"
                                                    + "warranty of merchantability or fitness for a particular purpose. In no<br/>"
                                                    + "event shall the copyright owner or contributors be liable for any direct,<br/>"
                                                    + "indirect, incidental spacial, examplary, or consequential damages.<br/>"
                                                    + "Copyright University of California San Francisco, 2007, 2008, 2009,<br/>"
                                                    + "2010. All rights reserved.</i>" + "</p>"
                                                    + "</body></html>");
                                            JLabel link = new JLabel(
                                                    "<html><a href=\"\">For more information, please follow this link.</a></html>");
                                            link.addMouseListener(new MouseAdapter() {
                                                @Override
                                                public void mousePressed(MouseEvent mouseevent) {
                                                    NetworkUtil.openBrowser(
                                                            "http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager");
                                                }
                                            });
                                            value.setSize(new Dimension(50, 18));
                                            value.setAlignmentX(SwingConstants.HORIZONTAL);
                                            value.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0));

                                            center.add(value, BorderLayout.CENTER);
                                            center.add(link, BorderLayout.SOUTH);

                                            JPanel panel_south = new JPanel();
                                            panel_south.setLayout(new BoxLayout(panel_south, BoxLayout.X_AXIS));
                                            JButton btn = new JButton("OK");
                                            btn.addActionListener(new ActionListener() {

                                                @Override
                                                public void actionPerformed(ActionEvent actionevent) {
                                                    dialog.dispose();
                                                }
                                            });
                                            panel_south.add(Box.createHorizontalGlue());
                                            panel_south.add(btn);
                                            panel_south.add(Box.createHorizontalGlue());

                                            dialog.setLayout(new BorderLayout());
                                            panel_container.setLayout(new BorderLayout());
                                            panel_container.add(center, BorderLayout.CENTER);
                                            panel_container.add(panel_south, BorderLayout.SOUTH);
                                            dialog.add(panel_container, BorderLayout.CENTER);
                                            dialog.setResizable(false);
                                            dialog.setVisible(true);
                                            dialog.pack();
                                            dialog.setLocation(
                                                    (int) mainFrame.getSize().getWidth() / 2
                                                            - dialog.getWidth() / 2,
                                                    (int) mainFrame.getSize().getHeight() / 2
                                                            - dialog.getHeight() / 2);
                                            dialog.setLocationRelativeTo(mainFrame);
                                        }
                                    });
                                    JMenuItem propertyBrowserItem = new JMenuItem("Property Browser");
                                    propertyBrowserItem.setAccelerator(
                                            KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, SHORTCUTKEY_MASK));
                                    propertyBrowserItem.setIcon(new IcyIcon("db", MENU_ICON_SIZE));
                                    propertyBrowserItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            editor.setVisible(!editor.isVisible());
                                        }
                                    });
                                    int idx = 0;
                                    toReturn.insert(hconfig, idx++);
                                    toReturn.insert(loadConfigItem, idx++);
                                    toReturn.insert(saveConfigItem, idx++);
                                    toReturn.insert(advancedConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(loadPresetConfigItem, idx++);
                                    toReturn.insert(savePresetConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(propertyBrowserItem, idx++);
                                    toReturn.insert(menuPxSizeConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(aboutItem, idx++);
                                    return toReturn;
                                }
                            });

                            saveConfigButton_ = new JButton("Save Button");

                            // SETUP
                            _groupPad = new ConfigGroupPad();
                            _groupPad.setParentGUI(MMMainFrame.this);
                            _groupPad.setFont(new Font("", 0, 10));
                            _groupPad.setCore(mCore);
                            _groupPad.setParentGUI(MMMainFrame.this);
                            _groupButtonsPanel = new ConfigButtonsPanel();
                            _groupButtonsPanel.setCore(mCore);
                            _groupButtonsPanel.setGUI(MMMainFrame.this);
                            _groupButtonsPanel.setConfigPad(_groupPad);

                            // LEFT PART OF INTERFACE
                            _panelConfig = new JPanel();
                            _panelConfig.setLayout(new BoxLayout(_panelConfig, BoxLayout.Y_AXIS));
                            _panelConfig.add(_groupPad, BorderLayout.CENTER);
                            _panelConfig.add(_groupButtonsPanel, BorderLayout.SOUTH);
                            _panelConfig.setPreferredSize(new Dimension(300, 300));

                            // MIDDLE PART OF INTERFACE
                            _panel_cameraSettings = new JPanel();
                            _panel_cameraSettings.setLayout(new GridLayout(5, 2));
                            _panel_cameraSettings.setMinimumSize(new Dimension(100, 200));

                            _txtExposure = new JTextField();
                            try {
                                mCore.setExposure(90.0D);
                                _txtExposure.setText(String.valueOf(mCore.getExposure()));
                            } catch (Exception e2) {
                                _txtExposure.setText("90");
                            }
                            _txtExposure.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20));
                            _txtExposure.addKeyListener(new KeyAdapter() {
                                @Override
                                public void keyPressed(KeyEvent keyevent) {
                                    if (keyevent.getKeyCode() == KeyEvent.VK_ENTER)
                                        setExposure();
                                }
                            });
                            _panel_cameraSettings.add(new JLabel("Exposure [ms]: "));
                            _panel_cameraSettings.add(_txtExposure);

                            _combo_binning = new JComboBox();
                            _combo_binning.setMaximumRowCount(4);
                            _combo_binning.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
                            _combo_binning.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    changeBinning();
                                }
                            });

                            _panel_cameraSettings.add(new JLabel("Binning: "));
                            _panel_cameraSettings.add(_combo_binning);

                            _combo_shutters = new JComboBox();
                            _combo_shutters.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent arg0) {
                                    try {
                                        if (_combo_shutters.getSelectedItem() != null) {
                                            mCore.setShutterDevice((String) _combo_shutters.getSelectedItem());
                                            _prefs.put(PREF_SHUTTER, (String) _combo_shutters
                                                    .getItemAt(_combo_shutters.getSelectedIndex()));
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                            _combo_shutters.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
                            _panel_cameraSettings.add(new JLabel("Shutter : "));
                            _panel_cameraSettings.add(_combo_shutters);

                            ActionListener action_listener = new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    updateHistogram();
                                }
                            };

                            _cbAbsoluteHisto = new JCheckBox();
                            _cbAbsoluteHisto.addActionListener(action_listener);
                            _cbAbsoluteHisto.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent actionevent) {
                                    _comboBitDepth.setEnabled(_cbAbsoluteHisto.isSelected());
                                    _prefs.putBoolean(PREF_ABS_HIST, _cbAbsoluteHisto.isSelected());
                                }
                            });
                            _panel_cameraSettings.add(new JLabel("Display absolute histogram ?"));
                            _panel_cameraSettings.add(_cbAbsoluteHisto);

                            _comboBitDepth = new JComboBox(new String[] { "8-bit", "9-bit", "10-bit", "11-bit",
                                    "12-bit", "13-bit", "14-bit", "15-bit", "16-bit" });
                            _comboBitDepth.addActionListener(action_listener);
                            _comboBitDepth.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent actionevent) {
                                    _prefs.putInt(PREF_BITDEPTH, _comboBitDepth.getSelectedIndex());
                                }
                            });
                            _comboBitDepth.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20));
                            _comboBitDepth.setEnabled(false);
                            _panel_cameraSettings.add(new JLabel("Select your bit depth for abs. hitogram: "));
                            _panel_cameraSettings.add(_comboBitDepth);

                            // Acquisition
                            _panelAcquisitions = new JPanel();
                            _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS));

                            // Color settings
                            _panelColorChooser = new JPanel();
                            _panelColorChooser.setLayout(new BoxLayout(_panelColorChooser, BoxLayout.Y_AXIS));
                            painterPreferences = MicroscopePainterPreferences.getInstance();
                            painterPreferences.setPreferences(_prefs.node("paintersPreferences"));
                            painterPreferences.loadColors();

                            HashMap<String, Color> allColors = painterPreferences.getColors();
                            String[] allKeys = (String[]) allColors.keySet().toArray(new String[0]);
                            String[] columnNames = { "Painter", "Color", "Transparency" };
                            Object[][] data = new Object[allKeys.length][3];

                            for (int i = 0; i < allKeys.length; ++i) {
                                final int actualRow = i;
                                String actualKey = allKeys[i].toString();
                                data[i][0] = actualKey;
                                data[i][1] = allColors.get(actualKey);
                                final JSlider slider = new JSlider(0, 255, allColors.get(actualKey).getAlpha());
                                slider.addChangeListener(new ChangeListener() {

                                    @Override
                                    public void stateChanged(ChangeEvent changeevent) {
                                        painterTable.setValueAt(slider, actualRow, 2);
                                    }
                                });
                                data[i][2] = slider;
                            }
                            final AbstractTableModel tableModel = new JTableEvolvedModel(columnNames, data);
                            painterTable = new JTable(tableModel);
                            painterTable.getModel().addTableModelListener(new TableModelListener() {

                                @Override
                                public void tableChanged(TableModelEvent tablemodelevent) {
                                    if (tablemodelevent.getType() == TableModelEvent.UPDATE) {
                                        int row = tablemodelevent.getFirstRow();
                                        int col = tablemodelevent.getColumn();
                                        String columnName = tableModel.getColumnName(col);
                                        String painterName = (String) tableModel.getValueAt(row, 0);
                                        if (columnName.contains("Color")) {
                                            // New color value
                                            int alpha = painterPreferences.getColor(painterName).getAlpha();
                                            Color coloNew = (Color) tableModel.getValueAt(row, 1);
                                            painterPreferences.setColor(painterName, new Color(coloNew.getRed(),
                                                    coloNew.getGreen(), coloNew.getBlue(), alpha));
                                        } else if (columnName.contains("Transparency")) {
                                            // New alpha value
                                            Color c = painterPreferences.getColor(painterName);
                                            int alphaValue = ((JSlider) tableModel.getValueAt(row, 2))
                                                    .getValue();
                                            painterPreferences.setColor(painterName, new Color(c.getRed(),
                                                    c.getGreen(), c.getBlue(), alphaValue));
                                        }
                                        /*
                                         * for (int i = 0; i <
                                         * tableModel.getRowCount(); ++i) { try {
                                         * String painterName = (String)
                                         * tableModel.getValueAt(i, 0); Color c =
                                         * (Color) tableModel.getValueAt(i, 1); int
                                         * alphaValue; if (ASpinnerChanged &&
                                         * tablemodelevent.getFirstRow() == i) {
                                         * alphaValue = ((JSlider)
                                         * tableModel.getValueAt(i, 2)).getValue();
                                         * } else { alphaValue =
                                         * painterPreferences.getColor
                                         * (painterPreferences
                                         * .getPainterName(i)).getAlpha(); }
                                         * painterPreferences.setColor(painterName,
                                         * new Color(c.getRed(), c.getGreen(),
                                         * c.getBlue(), alphaValue)); } catch
                                         * (Exception e) { System.out.println(
                                         * "error with painter table update"); } }
                                         */
                                    }
                                }
                            });
                            painterTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
                            painterTable.setFillsViewportHeight(true);

                            // Create the scroll pane and add the table to it.
                            JScrollPane scrollPane = new JScrollPane(painterTable);

                            // Set up renderer and editor for the Favorite Color
                            // column.
                            painterTable.setDefaultRenderer(Color.class, new ColorRenderer(true));
                            painterTable.setDefaultEditor(Color.class, new ColorEditor());

                            painterTable.setDefaultRenderer(JSlider.class, new SliderRenderer(0, 255));
                            painterTable.setDefaultEditor(JSlider.class, new SliderEditor());

                            _panelColorChooser.add(scrollPane);
                            _panelColorChooser.add(Box.createVerticalGlue());

                            _mainPanel = new JPanel();
                            _mainPanel.setLayout(new BorderLayout());

                            // EDITOR
                            // will refresh the data and verify if any change
                            // occurs.
                            // editor = new PropertyEditor(MMMainFrame.this);
                            // editor.setCore(mCore);
                            // editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
                            // editor.addToMainDesktopPane();
                            // editor.refresh();
                            // editor.start();

                            editor = new PropertyEditor();
                            editor.setGui(MMMainFrame.this);
                            editor.setCore(mCore);
                            editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
                            // editor.addToMainDesktopPane();
                            // editor.refresh();
                            // editor.start();

                            add(_mainPanel);
                            initializeGUI();
                            loadPreferences();
                            refreshGUI();
                            setResizable(true);
                            addToMainDesktopPane();
                            instanced = true;
                            instancing = false;
                            _singleton = MMMainFrame.this;
                            setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                            addFrameListener(new IcyFrameAdapter() {
                                @Override
                                public void icyFrameClosing(IcyFrameEvent e) {
                                    customClose();
                                }
                            });
                            acceptListener = new AcceptListener() {

                                @Override
                                public boolean accept(Object source) {
                                    close();
                                    return _pluginListEmpty;
                                }
                            };

                            adapter = new MainAdapter() {

                                @Override
                                public void sequenceOpened(MainEvent event) {
                                    updateHistogram();
                                }

                            };
                            Icy.getMainInterface().addCanExitListener(acceptListener);
                            Icy.getMainInterface().addListener(adapter);
                        }
                    });
                }
            });
        }
    });
}