Example usage for java.awt Cursor getDefaultCursor

List of usage examples for java.awt Cursor getDefaultCursor

Introduction

In this page you can find the example usage for java.awt Cursor getDefaultCursor.

Prototype

public static Cursor getDefaultCursor() 

Source Link

Document

Return the system default cursor.

Usage

From source file:au.com.jwatmuff.eventmanager.gui.wizard.SeedingPanel.java

@Override
public boolean nextButtonPressed() {
    if (!GUIUtils.confirmLock(null, "all players and fights in division " + pool.getDescription()))
        return false;

    // TODO: I would like this to be wrapped in a transaction, so that it can't fail halfway (e.g. players
    // locked, but fights not), but I couldn't get this working easily.
    boolean result = false;
    try {/*from  w  w  w . j av a2 s . c  o m*/
        context.detectExternalChanges = false;
        context.wizardWindow.disableNavigation();
        seedingTable.setEnabled(false);
        context.wizardWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        result = commitChanges();
    } finally {
        context.wizardWindow.enableNavigation();
        seedingTable.setEnabled(true);
        context.wizardWindow.setCursor(Cursor.getDefaultCursor());
        if (!result)
            context.detectExternalChanges = true;
    }

    return result;
}

From source file:de.main.sessioncreator.DesktopApplication1View.java

private void showReportPanel() {
    sessionWizardMenuItem.setEnabled(true);
    reviewVieMenuItem.setEnabled(true);/*from  w  w w  .j  av a2 s .  c  o m*/
    sessionReportMenuItem.setEnabled(false);
    viewReviewsPanel.setVisible(false);
    mainPanel.validate();
    wizardPanel.setVisible(false);
    mainPanel.validate();
    reportOverviewTable.setVisible(false);
    reportPanel.setVisible(true);
    mainPanel.validate();
    this.getFrame().setTitle("SessionCreator - Report");
    //Backgroundprozess to fill data to the reportPanel
    class ReportData extends SwingWorker<DefaultTableModel, Void> {

        @Override
        protected DefaultTableModel doInBackground() throws Exception {
            rh.addReport(reportChartPanel);
            reportScrollPOverviewTabel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            reportScrollPOverviewTabel.setToolTipText("Please wait...");
            reportlblSum.setText("Sums of Charters done: <counting>");
            progressBar.setIndeterminate(true);
            progressBar.setVisible(true);
            model = new DefaultTableModel();
            reportOverviewTable.removeAll();
            model = rh.getTableModel();
            reportOverviewTable.setModel(model);
            reportOverviewTable.setVisible(true);

            String count = rh.getAllSessionCount(model);
            reportlblSum.setText("Sums of Charters done: " + count);
            String[] text = rh.getAllBugsAndIssues();
            reportlblBug.setText(text[0]);
            reportlblIssue.setText(text[1]);

            return model;
        }

        @Override
        protected void done() {
            try {
                reportScrollPOverviewTabel.setCursor(Cursor.getDefaultCursor());
                reportScrollPOverviewTabel.setToolTipText("");
                progressBar.setIndeterminate(false);
                progressBar.setVisible(false);
                reportScrollPOverviewTabel.setEnabled(true);
                reportOverviewTable.setFillsViewportHeight(true);
                reportOverviewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                TableRowSorter<DefaultTableModel> rowSorter = new TableRowSorter<DefaultTableModel>(model);
                reportOverviewTable.setRowSorter(rowSorter);
                rowSorter.setComparator(1, new Comparator<Integer>() {

                    @Override
                    public int compare(Integer int1, Integer int2) {
                        return int1.intValue() - int2.intValue();
                    }
                });
                TableColumn column = null;

                for (int i = 0; i < 2; i++) {
                    column = reportOverviewTable.getColumnModel().getColumn(i);
                    if (i == 1) {
                        column.setPreferredWidth(10); //third column is bigger
                        DefaultTableCellRenderer myRenderer = new DefaultTableCellRenderer();
                        //Textalignment in second column right
                        myRenderer.setHorizontalAlignment(SwingConstants.RIGHT);
                        column.setCellRenderer(myRenderer);
                    } else {
                        column.setPreferredWidth(490);
                    }
                }

            } catch ( /* InterruptedException, ExecutionException */Exception e) {
            }
        }
    }
    new ReportData().execute();
}

From source file:util.ui.UiUtilities.java

/**
 * Creates a Html EditorPane that holds a HTML-Help Text
 *
 * Links will be displayed and are clickable
 *
 * @param html//from   w ww .  jav  a 2  s. c om
 *          HTML-Text to display
 * @param background The color for the background.
 * @return EditorPane that holds a Help Text
 * @since 2.7.2
 */
public static JEditorPane createHtmlHelpTextArea(String html, Color background) {
    return createHtmlHelpTextArea(html, new HyperlinkListener() {
        private String mTooltip;

        public void hyperlinkUpdate(HyperlinkEvent evt) {
            JEditorPane pane = (JEditorPane) evt.getSource();
            if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                mTooltip = pane.getToolTipText();
                pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                if (evt.getURL() != null) {
                    pane.setToolTipText(evt.getURL().toExternalForm());
                }
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(Cursor.getDefaultCursor());
                pane.setToolTipText(mTooltip);
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                URL url = evt.getURL();
                if (url != null) {
                    Launch.openURL(url.toString());
                }
            }
        }
    }, background);
}

From source file:TextSamplerDemo.java

protected void addStylesToDocument(StyledDocument doc) {
    //Initialize some styles.
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style s = doc.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);

    s = doc.addStyle("bold", regular);
    StyleConstants.setBold(s, true);

    s = doc.addStyle("small", regular);
    StyleConstants.setFontSize(s, 10);

    s = doc.addStyle("large", regular);
    StyleConstants.setFontSize(s, 16);

    s = doc.addStyle("icon", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon pigIcon = createImageIcon("images/Pig.gif", "a cute pig");
    if (pigIcon != null) {
        StyleConstants.setIcon(s, pigIcon);
    }/*from   www  . j  a v a  2 s .  co m*/

    s = doc.addStyle("button", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon soundIcon = createImageIcon("images/sound.gif", "sound icon");
    JButton button = new JButton();
    if (soundIcon != null) {
        button.setIcon(soundIcon);
    } else {
        button.setText("BEEP");
    }
    button.setCursor(Cursor.getDefaultCursor());
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setActionCommand(buttonString);
    button.addActionListener(this);
    StyleConstants.setComponent(s, button);
}

From source file:org.yccheok.jstock.gui.SaveToCloudJDialog.java

private void jLabel7MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel7MouseExited
    this.setCursor(Cursor.getDefaultCursor());
}

From source file:apidemo.PanScrollZoomDemo.java

/**
 * Sets the pan mode./*from www .  j a  va 2s .c o  m*/
 * 
 * @param val  a boolean.
 */
private void setPanMode(final boolean val) {

    //        this.chartPanel.setHorizontalZoom(!val);
    // chartPanel.setHorizontalAxisTrace(! val);
    //      this.chartPanel.setVerticalZoom(!val);
    // chartPanel.setVerticalAxisTrace(! val);

    if (val) {
        this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {
        this.chartPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:org.yccheok.jstock.gui.SaveToCloudJDialog.java

private void jLabel9MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel9MouseExited
    this.setCursor(Cursor.getDefaultCursor());
}

From source file:com.floreantpos.config.ui.DatabaseConfigurationDialog.java

public void actionPerformed(ActionEvent e) {
    try {/*  w ww .j  a  v  a 2  s.  c o m*/
        String command = e.getActionCommand();

        Database selectedDb = (Database) databaseCombo.getSelectedItem();

        final String providerName = selectedDb.getProviderName();
        final String databaseURL = tfServerAddress.getText();
        final String databasePort = tfServerPort.getText();
        final String databaseName = tfDatabaseName.getText();
        final String user = tfUserName.getText();
        final String pass = new String(tfPassword.getPassword());

        final String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName);
        final String hibernateDialect = selectedDb.getHibernateDialect();
        final String driverClass = selectedDb.getHibernateConnectionDriverClass();

        if (CANCEL.equalsIgnoreCase(command)) {
            dispose();
            return;
        }

        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        Application.getInstance().setSystemInitialized(false);
        saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass,
                connectionString, hibernateDialect);

        if (TEST.equalsIgnoreCase(command)) {
            try {
                DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass);
            } catch (DatabaseConnectionException e1) {
                JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$
                return;
            }

            connectionSuccess = true;
            JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$
        } else if (UPDATE_DATABASE.equals(command)) {
            int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.0"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.1"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            if (i != JOptionPane.YES_OPTION) {
                return;
            }

            //isAuthorizedToPerformDbChange();

            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            boolean databaseUpdated = DatabaseUtil.updateDatabase(connectionString, hibernateDialect,
                    driverClass, user, pass);
            if (databaseUpdated) {
                connectionSuccess = true;
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.2")); //$NON-NLS-1$
            } else {
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.3")); //$NON-NLS-1$
            }
        } else if (CREATE_DATABASE.equals(command)) {

            int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            if (i != JOptionPane.YES_OPTION) {
                return;
            }

            i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.4"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.5"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            boolean generateSampleData = false;
            if (i == JOptionPane.YES_OPTION)
                generateSampleData = true;

            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            String createDbConnectString = selectedDb.getCreateDbConnectString(databaseURL, databasePort,
                    databaseName);

            boolean databaseCreated = DatabaseUtil.createDatabase(createDbConnectString, hibernateDialect,
                    driverClass, user, pass, generateSampleData);

            if (databaseCreated) {
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.6") + //$NON-NLS-1$
                                Messages.getString("DatabaseConfigurationDialog.7")); //$NON-NLS-1$

                Main.restart();
                connectionSuccess = true;
            } else {
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$
            }
        } else if (SAVE.equalsIgnoreCase(command)) {
            if (connectionSuccess) {
                Application.getInstance().initializeSystem();
            }
            dispose();
        }
    } catch (Exception e2) {
        PosLog.error(getClass(), e2);
        POSMessageDialog.showMessage(this, e2.getMessage());
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}

From source file:org.openscience.jmol.app.Jmol.java

Jmol(Splash splash, JFrame frame, Jmol parent, int startupWidth, int startupHeight, String commandOptions,
        Point loc) {/* w  w  w  .  ja  v a  2  s  . c o  m*/
    super(true);
    this.frame = frame;
    this.startupWidth = startupWidth;
    this.startupHeight = startupHeight;
    numWindows++;

    try {
        say("history file is " + historyFile.getFile().getAbsolutePath());
    } catch (Exception e) {
    }

    frame.setTitle("Jmol");
    frame.getContentPane().setBackground(Color.lightGray);
    frame.getContentPane().setLayout(new BorderLayout());

    this.splash = splash;

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());
    language = GT.getLanguage();

    status = (StatusBar) createStatusBar();
    say(GT._("Initializing 3D display..."));
    //
    display = new DisplayPanel(status, guimap, haveDisplay.booleanValue(), startupWidth, startupHeight);
    String adapter = System.getProperty("model");
    if (adapter == null || adapter.length() == 0)
        adapter = "smarter";
    if (adapter.equals("smarter")) {
        report("using Smarter Model Adapter");
        modelAdapter = new SmarterJmolAdapter();
    } else if (adapter.equals("cdk")) {
        report("the CDK Model Adapter is currently no longer supported. Check out http://bioclipse.net/. -- using Smarter");
        // modelAdapter = new CdkJmolAdapter(null);
        modelAdapter = new SmarterJmolAdapter();
    } else {
        report("unrecognized model adapter:" + adapter + " -- using Smarter");
        modelAdapter = new SmarterJmolAdapter();
    }
    appletContext = commandOptions;
    viewer = JmolViewer.allocateViewer(display, modelAdapter);
    viewer.setAppletContext("", null, null, commandOptions);

    if (display != null)
        display.setViewer(viewer);

    say(GT._("Initializing Preferences..."));
    preferencesDialog = new PreferencesDialog(frame, guimap, viewer);
    say(GT._("Initializing Recent Files..."));
    recentFiles = new RecentFilesDialog(frame);
    if (haveDisplay.booleanValue()) {
        say(GT._("Initializing Script Window..."));
        scriptWindow = new ScriptWindow(viewer, frame);
    }

    MyStatusListener myStatusListener;
    myStatusListener = new MyStatusListener();
    viewer.setJmolStatusListener(myStatusListener);

    say(GT._("Initializing Measurements..."));
    measurementTable = new MeasurementTable(viewer, frame);

    // Setup Plugin system
    // say(GT._("Loading plugins..."));
    // pluginManager = new CDKPluginManager(
    //     System.getProperty("user.home") + System.getProperty("file.separator")
    //     + ".jmol", new JmolEditBus(viewer)
    // );
    // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DirBrowserPlugin");
    // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DadmlBrowserPlugin");
    // pluginManager.loadPlugins(
    //     System.getProperty("user.home") + System.getProperty("file.separator")
    //     + ".jmol/plugins"
    // );
    // feature to allow for globally installed plugins
    // if (System.getProperty("plugin.dir") != null) {
    //     pluginManager.loadPlugins(System.getProperty("plugin.dir"));
    // }

    if (haveDisplay.booleanValue()) {

        // install the command table
        say(GT._("Building Command Hooks..."));
        commands = new Hashtable();
        if (display != null) {
            Action[] actions = getActions();
            for (int i = 0; i < actions.length; i++) {
                Action a = actions[i];
                commands.put(a.getValue(Action.NAME), a);
            }
        }

        menuItems = new Hashtable();
        say(GT._("Building Menubar..."));
        executeScriptAction = new ExecuteScriptAction();
        menubar = createMenubar();
        add("North", menubar);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.add("North", createToolbar());

        JPanel ip = new JPanel();
        ip.setLayout(new BorderLayout());
        ip.add("Center", display);
        panel.add("Center", ip);
        add("Center", panel);
        add("South", status);

        say(GT._("Starting display..."));
        display.start();

        //say(GT._("Setting up File Choosers..."));

        /*      pcs.addPropertyChangeListener(chemFileProperty, exportAction);
         pcs.addPropertyChangeListener(chemFileProperty, povrayAction);
         pcs.addPropertyChangeListener(chemFileProperty, writeAction);
         pcs.addPropertyChangeListener(chemFileProperty, toWebAction);
         pcs.addPropertyChangeListener(chemFileProperty, printAction);
         pcs.addPropertyChangeListener(chemFileProperty,
         viewMeasurementTableAction);
         */

        if (menuFile != null) {
            menuStructure = viewer.getFileAsString(menuFile);
        }
        jmolpopup = JmolPopup.newJmolPopup(viewer, true, menuStructure, true);

    }

    // prevent new Jmol from covering old Jmol
    if (loc != null) {
        frame.setLocation(loc);
    } else if (parent != null) {
        Point location = parent.frame.getLocationOnScreen();
        int maxX = screenSize.width - 50;
        int maxY = screenSize.height - 50;

        location.x += 40;
        location.y += 40;
        if ((location.x > maxX) || (location.y > maxY)) {
            location.setLocation(0, 0);
        }
        frame.setLocation(location);
    }
    frame.getContentPane().add("Center", this);

    frame.addWindowListener(new Jmol.AppCloser());
    frame.pack();
    frame.setSize(startupWidth, startupHeight);
    ImageIcon jmolIcon = JmolResourceHandler.getIconX("icon");
    Image iconImage = jmolIcon.getImage();
    frame.setIconImage(iconImage);

    // Repositionning windows
    if (scriptWindow != null)
        historyFile.repositionWindow(SCRIPT_WINDOW_NAME, scriptWindow, 200, 100);

    say(GT._("Setting up Drag-and-Drop..."));
    FileDropper dropper = new FileDropper();
    final JFrame f = frame;
    dropper.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            //System.out.println("Drop triggered...");
            f.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_FILENAME)) {
                final String filename = evt.getNewValue().toString();
                viewer.openFile(filename);
            } else if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_INLINE)) {
                final String inline = evt.getNewValue().toString();
                viewer.openStringInline(inline);
            }
            f.setCursor(Cursor.getDefaultCursor());
        }
    });

    this.setDropTarget(new DropTarget(this, dropper));
    this.setEnabled(true);

    say(GT._("Launching main frame..."));
}

From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java

public MindMapPanel(final MindMapPanelController controller) {
    super(null);//from   w ww  .j a  v a2 s  . c om
    this.textEditorPanel.setLayout(new BorderLayout(0, 0));
    this.controller = controller;

    this.config = new MindMapPanelConfig(controller.provideConfigForMindMapPanel(this), false);

    this.textEditor.setMargin(new Insets(5, 5, 5, 5));
    this.textEditor.setBorder(BorderFactory.createEtchedBorder());
    this.textEditor.setTabSize(4);
    this.textEditor.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent e) {
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER: {
                e.consume();
            }
                break;
            case KeyEvent.VK_TAB: {
                if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) {
                    e.consume();
                    final Topic edited = elementUnderEdit.getModel();
                    final int[] topicPosition = edited.getPositionPath();
                    endEdit(true);
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            final Topic theTopic = model.findForPositionPath(topicPosition);
                            if (theTopic != null) {
                                makeNewChildAndStartEdit(theTopic, null);
                            }
                        }
                    });
                }
            }
                break;
            default:
                break;
            }
        }

        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) {
                    e.consume();
                    endEdit(true);
                } else {
                    e.consume();
                    textEditor.insert("\n", textEditor.getCaretPosition()); //NOI18N
                }
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_CANCEL_EDIT, e)) {
                e.consume();
                final Topic edited = elementUnderEdit == null ? null : elementUnderEdit.getModel();
                endEdit(false);
                if (edited != null && edited.canBeLost()) {
                    deleteTopics(edited);
                    if (pathToPrevTopicBeforeEdit != null) {
                        final int[] path = pathToPrevTopicBeforeEdit;
                        pathToPrevTopicBeforeEdit = null;
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                final Topic topic = model.findForPositionPath(path);
                                if (topic != null) {
                                    select(topic, false);
                                }
                            }
                        });
                    }
                }
            }
        }
    });

    this.textEditor.getDocument().addDocumentListener(new DocumentListener() {

        private void updateEditorPanelSize(final Dimension newSize) {
            final Dimension editorPanelMinSize = textEditorPanel.getMinimumSize();
            final Dimension newDimension = new Dimension(Math.max(editorPanelMinSize.width, newSize.width),
                    Math.max(editorPanelMinSize.height, newSize.height));
            textEditorPanel.setSize(newDimension);
            textEditorPanel.repaint();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }
    });
    this.textEditorPanel.add(this.textEditor, BorderLayout.CENTER);

    super.setOpaque(true);

    final KeyAdapter keyAdapter = new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_CHILD_AND_START_EDIT, e)) {
                if (!selectedTopics.isEmpty()) {
                    makeNewChildAndStartEdit(selectedTopics.get(0), null);
                }
            } else if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_SIBLING_AND_START_EDIT, e)) {
                if (!hasActiveEditor() && hasOnlyTopicSelected()) {
                    final Topic baseTopic = selectedTopics.get(0);
                    makeNewChildAndStartEdit(baseTopic.getParent() == null ? baseTopic : baseTopic.getParent(),
                            baseTopic);
                }
            } else if (config.isKeyEvent(MindMapPanelConfig.KEY_FOCUS_ROOT_OR_START_EDIT, e)) {
                if (!hasSelectedTopics()) {
                    select(getModel().getRoot(), false);
                } else if (hasOnlyTopicSelected()) {
                    startEdit((AbstractElement) selectedTopics.get(0).getPayload());
                }
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_DELETE_TOPIC, e)) {
                e.consume();
                deleteSelectedTopics();
            } else if (config.isKeyEventDetected(e, MindMapPanelConfig.KEY_FOCUS_MOVE_LEFT,
                    MindMapPanelConfig.KEY_FOCUS_MOVE_RIGHT, MindMapPanelConfig.KEY_FOCUS_MOVE_UP,
                    MindMapPanelConfig.KEY_FOCUS_MOVE_DOWN)) {
                e.consume();
                processMoveFocusByKey(e);
            }
        }
    };

    this.setFocusTraversalKeysEnabled(false);

    final MindMapPanel theInstance = this;

    final MouseAdapter adapter = new MouseAdapter() {

        @Override
        public void mouseEntered(final MouseEvent e) {
            setCursor(Cursor.getDefaultCursor());
        }

        @Override
        public void mouseMoved(final MouseEvent e) {
            if (!controller.isMouseMoveProcessingAllowed(theInstance)) {
                return;
            }
            final AbstractElement element = findTopicUnderPoint(e.getPoint());
            if (element == null) {
                setCursor(Cursor.getDefaultCursor());
                setToolTipText(null);
            } else {
                final ElementPart part = element.findPartForPoint(e.getPoint());
                setCursor(part == ElementPart.ICONS || part == ElementPart.COLLAPSATOR
                        ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
                        : Cursor.getDefaultCursor());
                if (part == ElementPart.ICONS) {
                    final Extra<?> extra = element.getIconBlock().findExtraForPoint(
                            e.getPoint().getX() - element.getBounds().getX(),
                            e.getPoint().getY() - element.getBounds().getY());
                    if (extra != null) {
                        setToolTipText(makeHtmlTooltipForExtra(extra));
                    } else {
                        setToolTipText(null);
                    }
                } else {
                    setToolTipText(null);
                }
            }
        }

        @Override
        public void mousePressed(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            try {
                if (e.isPopupTrigger()) {
                    mouseDragSelection = null;
                    MindMap theMap = model;
                    AbstractElement element = null;
                    if (theMap != null) {
                        element = findTopicUnderPoint(e.getPoint());
                    }
                    processPopUp(e.getPoint(), element);
                    e.consume();
                } else {
                    endEdit(elementUnderEdit != null);
                    mouseDragSelection = null;
                }
            } catch (Exception ex) {
                LOGGER.error("Error during mousePressed()", ex);
            }
        }

        @Override
        public void mouseReleased(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            try {
                if (draggedElement != null) {
                    draggedElement.updatePosition(e.getPoint());
                    if (endDragOfElement(draggedElement, destinationElement)) {
                        updateView(true);
                    }
                } else if (mouseDragSelection != null) {
                    final List<Topic> covered = mouseDragSelection.getAllSelectedElements(model);
                    if (e.isShiftDown()) {
                        for (final Topic m : covered) {
                            select(m, false);
                        }
                    } else if (e.isControlDown()) {
                        for (final Topic m : covered) {
                            select(m, true);
                        }
                    } else {
                        removeAllSelection();
                        for (final Topic m : covered) {
                            select(m, false);
                        }
                    }
                } else if (e.isPopupTrigger()) {
                    mouseDragSelection = null;
                    MindMap theMap = model;
                    AbstractElement element = null;
                    if (theMap != null) {
                        element = findTopicUnderPoint(e.getPoint());
                    }
                    processPopUp(e.getPoint(), element);
                    e.consume();
                }
            } catch (Exception ex) {
                LOGGER.error("Error during mouseReleased()", ex);
            } finally {
                mouseDragSelection = null;
                draggedElement = null;
                destinationElement = null;
                repaint();
            }
        }

        @Override
        public void mouseDragged(final MouseEvent e) {
            if (!controller.isMouseMoveProcessingAllowed(theInstance)) {
                return;
            }
            scrollRectToVisible(new Rectangle(e.getX(), e.getY(), 1, 1));

            if (!popupMenuActive) {
                if (draggedElement == null && mouseDragSelection == null) {
                    final AbstractElement elementUnderMouse = findTopicUnderPoint(e.getPoint());
                    if (elementUnderMouse == null) {
                        MindMap theMap = model;
                        if (theMap != null) {
                            final AbstractElement element = findTopicUnderPoint(e.getPoint());
                            if (controller.isSelectionAllowed(theInstance) && element == null) {
                                mouseDragSelection = new MouseSelectedArea(e.getPoint());
                            }
                        }
                    } else if (controller.isElementDragAllowed(theInstance)) {
                        if (elementUnderMouse.isMoveable()) {
                            selectedTopics.clear();

                            final Point mouseOffset = new Point(
                                    (int) Math
                                            .round(e.getPoint().getX() - elementUnderMouse.getBounds().getX()),
                                    (int) Math
                                            .round(e.getPoint().getY() - elementUnderMouse.getBounds().getY()));
                            draggedElement = new DraggedElement(elementUnderMouse, config, mouseOffset,
                                    e.isControlDown() || e.isMetaDown() ? DraggedElement.Modifier.MAKE_JUMP
                                            : DraggedElement.Modifier.NONE);
                            draggedElement.updatePosition(e.getPoint());
                            findDestinationElementForDragged();
                        } else {
                            draggedElement = null;
                        }
                        repaint();
                    }
                } else if (mouseDragSelection != null) {
                    if (controller.isSelectionAllowed(theInstance)) {
                        mouseDragSelection.update(e);
                    } else {
                        mouseDragSelection = null;
                    }
                    repaint();
                } else if (draggedElement != null) {
                    if (controller.isElementDragAllowed(theInstance)) {
                        draggedElement.updatePosition(e.getPoint());
                        findDestinationElementForDragged();
                    } else {
                        draggedElement = null;
                    }
                    repaint();
                }
            } else {
                mouseDragSelection = null;
            }
        }

        @Override
        public void mouseWheelMoved(final MouseWheelEvent e) {
            if (controller.isMouseWheelProcessingAllowed(theInstance)) {
                mouseDragSelection = null;
                draggedElement = null;

                final MindMapPanelConfig theConfig = config;

                if (!e.isConsumed() && (theConfig != null
                        && ((e.getModifiers() & theConfig.getScaleModifiers()) == theConfig
                                .getScaleModifiers()))) {
                    endEdit(elementUnderEdit != null);

                    setScale(
                            Math.max(0.3d, Math.min(getScale() + (SCALE_STEP * -e.getWheelRotation()), 10.0d)));

                    updateView(false);
                    e.consume();
                } else {
                    sendToParent(e);
                }
            }
        }

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            mouseDragSelection = null;
            draggedElement = null;

            MindMap theMap = model;
            AbstractElement element = null;
            if (theMap != null) {
                element = findTopicUnderPoint(e.getPoint());
            }

            if (element != null) {
                final ElementPart part = element.findPartForPoint(e.getPoint());
                if (part == ElementPart.COLLAPSATOR) {
                    removeAllSelection();

                    if (element.isCollapsed()) {
                        ((AbstractCollapsableElement) element).setCollapse(false);
                        if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
                            ((AbstractCollapsableElement) element).collapseAllFirstLevelChildren();
                        }
                    } else {
                        ((AbstractCollapsableElement) element).setCollapse(true);
                    }
                    invalidate();
                    fireNotificationMindMapChanged();
                    repaint();
                } else if (part != ElementPart.ICONS && e.getClickCount() > 1) {
                    startEdit(element);
                } else if (part == ElementPart.ICONS) {
                    final Extra<?> extra = element.getIconBlock().findExtraForPoint(
                            e.getPoint().getX() - element.getBounds().getX(),
                            e.getPoint().getY() - element.getBounds().getY());
                    if (extra != null) {
                        fireNotificationClickOnExtra(element.getModel(), e.getClickCount(), extra);
                    }
                } else {
                    if (!e.isControlDown()) {
                        // only
                        removeAllSelection();
                        select(element.getModel(), false);
                    } else // group
                    if (selectedTopics.isEmpty()) {
                        select(element.getModel(), false);
                    } else {
                        select(element.getModel(), true);
                    }
                }
            }
        }
    };

    addMouseWheelListener(adapter);
    addMouseListener(adapter);
    addMouseMotionListener(adapter);
    addKeyListener(keyAdapter);

    this.textEditorPanel.setVisible(false);
    this.add(this.textEditorPanel);
}