Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

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

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

From source file:edu.harvard.mcz.imagecapture.ui.ButtonEditor.java

@Override
public void actionPerformed(ActionEvent e) {

    // Action might not be event_button_pressed on all systems.
    log.debug("Button event actionCommand: " + e.getActionCommand());
    if (e.getActionCommand().equals(EVENT_PRESSED)) {
        // Event is a click on the cell
        // Identify the row that was clicked on.
        JTable table = (JTable) ((JButton) e.getSource()).getParent();
        log.debug(e.getSource());//  ww  w .  j  a  v a  2s  . c  o m
        log.debug(table);
        int row = table.getEditingRow();
        // Stop editing - note, we need to have gotten e.getSource.getParent and getEditingRow first.
        fireEditingStopped(); //Make the renderer reappear.
        Singleton.getSingletonInstance().getMainFrame()
                .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        switch (formToOpen) {
        case OPEN_SPECIMEN_DETAILS:
            // Load the selected specimen record from its ID (the data value behind the button).
            //SpecimenLifeCycle sls = new SpecimenLifeCycle();
            //Specimen specimen = sls.findById((Long)targetId);
            //if (specimen!=null) {
            if (targetId != null) {
                // a specimen with this ID exists, bring up the details editor.
                try {
                    //SpecimenControler sc = new SpecimenControler(specimen);
                    if (((Specimen) targetId).getSpecimenId() != null) {
                        if (((Specimen) targetId).isStateDone()) {
                            // Specimens in state_done are no longer editable
                            JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                                    "This Specimen record has been migrated and can no longer be edited here ["
                                            + ((Specimen) targetId).getLoadFlags()
                                            + "].\nSee: http://mczbase.mcz.harvard.edu/guid/MCZ:Ent:"
                                            + ((Specimen) targetId).getCatNum(),
                                    "Migrated Specimen", JOptionPane.WARNING_MESSAGE);
                        } else {
                            // Specimen is still editable
                            if (table != null) {
                                // Pass the specimen object for the row, the table model, and the row number on to the specimen controler.
                                try {
                                    SpecimenControler sc = new SpecimenControler((Specimen) targetId,
                                            (SpecimenListTableModel) table.getModel(), table, row);
                                    if (table.getParent().getParent().getParent().getParent()
                                            .getClass() == SpecimenBrowser.class) {
                                        sc.addListener((DataChangeListener) table.getParent());
                                    } else {
                                        Component x = table;
                                        boolean done = false;
                                        while (!done) {
                                            log.debug(x.getParent());
                                            x = x.getParent();
                                            if (x.getClass() == SpecimenBrowser.class) {
                                                sc.addListener((DataChangeListener) x);
                                                done = true;
                                            }
                                        }
                                    }
                                    sc.displayInEditor();
                                } catch (java.lang.ClassCastException eNotSp) {
                                    // Request isn't coming from a SpecimenListTableModel
                                    // View just the specimen record.
                                    SpecimenControler sc = new SpecimenControler((Specimen) targetId);
                                    sc.displayInEditor();
                                }
                            } else {
                                log.debug(e.getSource());
                                //SpecimenControler sc = new SpecimenControler((Specimen)targetId);
                                //sc.displayInEditor();
                            }
                        }
                    } else {
                        log.debug("User clicked on table row containing a new Specimen()");
                        JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                                "No Specimen for this image", "Load Specimen Failed",
                                JOptionPane.WARNING_MESSAGE);
                    }
                } catch (NoSuchRecordException e1) {
                    log.error("Tested for specimen!=null, but SpecimenControler threw null specimen exception");
                    log.error(e1);
                }
            } else {
                log.debug("No matches found to specimen id=" + targetId);
                // TODO: Create new specimen record and bring up dialog
                JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                        "No specimen record.");
            }
            break;
        case OPEN_TEMPLATE:
            // Load the selected specimen record from its ID (the data value behind the button).
            try {
                // a template with this targetID exists, display it.
                ((PositionTemplateEditor) parentComponent).setTemplate((String) targetId);
            } catch (NoSuchTemplateException e1) {
                log.error("No such template on button press on a template in list.");
                log.error(e1);
                log.trace(e1);
            }

            break;
        case OPEN_USER:
            //TODO: tie to user
            log.debug("Open user");
            ((UserListBrowser) parentComponent).getEditUserPanel().setUser((Users) targetId);
            break;
        case OPEN_SPECIMEN_VERBATIM:
            log.debug("Open Verbatim Transcription");
            SpecimenLifeCycle sls = new SpecimenLifeCycle();
            List<Specimen> toTranscribe = sls.findForVerbatim(((GenusSpeciesCount) targetId).getGenus(),
                    ((GenusSpeciesCount) targetId).getSpecificEpithet(), WorkFlowStatus.STAGE_1);
            log.debug(toTranscribe.size());
            SpecimenListTableModel stm = new SpecimenListTableModel(toTranscribe);
            JTable stable = new JTable();
            stable.setModel(stm);
            SpecimenControler verbCont;
            try {
                verbCont = new SpecimenControler(toTranscribe.get(0), stm, stable, 0);
                VerbatimCaptureDialog dialog = new VerbatimCaptureDialog(toTranscribe.get(0), verbCont);
                dialog.setVisible(true);
            } catch (NoSuchRecordException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            break;
        case OPEN_VERBATIM_CLASSIFY:
            log.debug("Open Verbatim Classify dialog");
            try {
                VerbatimClassifyDialog dialog = new VerbatimClassifyDialog(
                        (VerbatimCount) table.getModel().getValueAt(row, 0));
                dialog.setVisible(true);
            } catch (ClassCastException e1) {
                log.error(e1.getMessage(), e1);
            }
            break;
        case ACTION_CANCEL_JOB:
            log.debug("Action Cancel requested on job " + targetId);
            Singleton.getSingletonInstance().getJobList().getJobAt((Integer) targetId).cancel();
            break;
        case OPEN_SPECIMENPARTATTRIBUTES:
            SpecimenPartAttributeDialog attrDialog = new SpecimenPartAttributeDialog((SpecimenPart) targetId);
            attrDialog.setVisible(true);
            break;
        }
        Singleton.getSingletonInstance().getMainFrame()
                .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        System.gc();
    }
}

From source file:FTPApp.java

protected void disconnect() {
    if (ftpClient != null) {
        try {/*from  w ww  . j  a va2 s  . com*/
            ftpClient.closeServer();
        } catch (IOException ex) {
        }
        ftpClient = null;
    }
    Runnable runner = new Runnable() {
        public void run() {
            m_progress.setValue(0);
            putButton.setEnabled(true);
            getButton.setEnabled(true);
            fileButton.setEnabled(true);
            closeButton.setText("Close");
            FTPApp.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        }
    };
    SwingUtilities.invokeLater(runner);
}

From source file:aurelienribon.gdxsetupui.ui.MainPanel.java

private void initUI() {
    startSetupBtn.addActionListener(new ActionListener() {
        @Override/*from  ww  w. j  a  v  a  2 s. c om*/
        public void actionPerformed(ActionEvent e) {
            showSetupView();
        }
    });

    startUpdateBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showUpdateView();
        }
    });

    changeModeBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showInitView();
        }
    });

    JLabel aboutLabel = new JLabel("About this app >");
    Style.registerCssClasses(aboutLabel, ".linkLabel");
    aboutLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    versionLabel.setLayout(new BorderLayout());
    versionLabel.add(aboutLabel, BorderLayout.EAST);

    aboutLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            showAboutPanel();
        }
    });
}

From source file:org.drugis.addis.gui.WelcomeDialog.java

private JButton createButton(String text, String icon, AbstractAction action) {
    JButton button = new JButton(text, Main.IMAGELOADER.getIcon(icon));
    button.setPreferredSize(new Dimension(BUTTON_WIDTH, COMP_HEIGHT));
    button.setHorizontalAlignment(SwingConstants.LEFT);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.addActionListener(action);/*from   www .j a v  a2  s  .com*/
    return button;
}

From source file:com.microsoftopentechnologies.intellij.forms.TableForm.java

public TableForm() {
    final TableForm form = this;
    this.setResizable(false);
    this.setModal(true);
    this.setTitle("Create new table");
    this.setContentPane(mainPanel);

    createButton.setEnabled(false);/*from  ww w .j a v  a  2 s  .co  m*/

    tableNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent keyEvent) {
            super.keyTyped(keyEvent);

            createButton.setEnabled(!tableNameTextField.getText().isEmpty());
        }
    });

    final PermissionItem[] tablePermissions = PermissionItem.getTablePermissions();

    insertPermisssionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));
    deletePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));
    updatePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));
    readPermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));

    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            form.setVisible(false);
            form.dispose();
        }
    });

    createButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        TablePermissions tablePermissions = new TablePermissions();

                        tablePermissions.setDelete(
                                ((PermissionItem) deletePermissionComboBox.getSelectedItem()).getType());
                        tablePermissions.setUpdate(
                                ((PermissionItem) updatePermissionComboBox.getSelectedItem()).getType());
                        tablePermissions
                                .setRead(((PermissionItem) readPermissionComboBox.getSelectedItem()).getType());
                        tablePermissions.setInsert(
                                ((PermissionItem) insertPermisssionComboBox.getSelectedItem()).getType());

                        final String tableName = tableNameTextField.getText().trim();

                        if (!tableName.matches("^[A-Za-z][A-Za-z0-9_]+")) {
                            JOptionPane.showMessageDialog(form,
                                    "Invalid table name. Table name must start with a letter, \n"
                                            + "contain only letters, numbers, and underscores.",
                                    "Error creating the table", JOptionPane.ERROR_MESSAGE);
                            return;
                        }

                        int tableNameIndex = -1;
                        if (existingTableNames != null) {
                            tableNameIndex = Iterables.indexOf(existingTableNames, new Predicate<String>() {
                                @Override
                                public boolean apply(String name) {
                                    return tableName.equalsIgnoreCase(name);
                                }
                            });
                        }

                        if (tableNameIndex != -1) {
                            JOptionPane.showMessageDialog(form,
                                    "Invalid table name. A table with that name already exists in this service.",
                                    "Error creating the table", JOptionPane.ERROR_MESSAGE);
                            return;
                        }

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

                        if (editingTable == null) {
                            AzureRestAPIManager.getManager().createTable(subscriptionId, serviceName, tableName,
                                    tablePermissions);
                        } else {
                            AzureRestAPIManager.getManager().updateTable(subscriptionId, serviceName, tableName,
                                    tablePermissions);
                        }
                        if (afterSave != null)
                            afterSave.run();

                        form.setVisible(false);
                        form.dispose();
                        form.setCursor(Cursor.getDefaultCursor());

                    } catch (Throwable e) {
                        form.setCursor(Cursor.getDefaultCursor());
                        UIHelper.showException("Error creating table", e);
                    }

                }
            });
        }
    });
}

From source file:savant.view.swing.NavigationBar.java

NavigationBar() {

    this.setOpaque(false);
    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    String buttonStyle = "segmentedCapsule";

    String shortcutMod = MiscUtils.MAC ? "Cmd" : "Ctrl";

    add(getRigidPadding());//from   w w w  .j ava 2  s.c  om

    JButton loadGenomeButton = (JButton) add(new JButton(""));
    loadGenomeButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.GENOME));
    loadGenomeButton.setToolTipText("Load or change genome");
    loadGenomeButton.setFocusable(false);
    loadGenomeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().showOpenGenomeDialog();
        }
    });
    loadGenomeButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadGenomeButton.putClientProperty("JButton.segmentPosition", "first");
    loadGenomeButton.setPreferredSize(ICON_SIZE);
    loadGenomeButton.setMinimumSize(ICON_SIZE);
    loadGenomeButton.setMaximumSize(ICON_SIZE);

    JButton loadTrackButton = (JButton) add(new JButton(""));
    loadTrackButton.setFocusable(false);
    loadTrackButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK));
    loadTrackButton.setToolTipText("Load a track");
    loadTrackButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().openTrack();
        }
    });
    loadTrackButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadTrackButton.putClientProperty("JButton.segmentPosition", "last");
    loadTrackButton.setPreferredSize(ICON_SIZE);
    loadTrackButton.setMinimumSize(ICON_SIZE);
    loadTrackButton.setMaximumSize(ICON_SIZE);

    if (!Savant.getInstance().isStandalone()) {
        add(loadGenomeButton);
        add(loadTrackButton);
        add(getRigidPadding());
        add(getRigidPadding());
    } else {
        loadGenomeButton.setVisible(false);
        loadTrackButton.setVisible(false);
    }

    JLabel rangeText = new JLabel("Location ");
    add(rangeText);

    String[] a = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " };
    locationField = new JComboBox(a);
    locationField.setEditable(true);
    locationField.setRenderer(new ReferenceListRenderer());

    // When the item is chosen from the menu, navigate to the given feature/reference.
    locationField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (!currentlyPopulating) {
                if (ae.getActionCommand().equals("comboBoxChanged")) {
                    // Assumes that combo-box items created by populateCombo() are of the form "GENE (chrX:1-1000)".
                    String itemText = locationField.getSelectedItem().toString();
                    int lastBracketPos = itemText.lastIndexOf('(');
                    if (lastBracketPos > 0) {
                        itemText = itemText.substring(lastBracketPos + 1, itemText.length() - 1);
                    }
                    setRangeFromText(itemText);

                }
            }
        }
    });

    // When the combo-box is popped open, we may want to repopulate the menu.
    locationField.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
            String text = (String) locationField.getEditor().getItem();
            if (!text.equals(lastPoppedUp)) {
                try {
                    // Building the menu could take a while.
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    populateCombo();
                } finally {
                    setCursor(Cursor.getDefaultCursor());
                }
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent pme) {
        }
    });

    // Add our special keystroke-handling to the JComboBox' text-field.
    // We have to turn off default tab-handling so that tab can pop up our list.
    Component textField = locationField.getEditor().getEditorComponent();
    textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
    textField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                locationField.showPopup();
            } else if (evt.getModifiers() == KeyEvent.SHIFT_MASK) {
                switch (evt.getKeyCode()) {
                case KeyEvent.VK_LEFT:
                    locationController.shiftRangeLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_RIGHT:
                    locationController.shiftRangeRight();
                    evt.consume();
                    break;
                case KeyEvent.VK_UP:
                    locationController.zoomIn();
                    evt.consume();
                    break;
                case KeyEvent.VK_DOWN:
                    locationController.zoomOut();
                    evt.consume();
                    break;
                case KeyEvent.VK_HOME:
                    locationController.shiftRangeFarLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_END:
                    locationController.shiftRangeFarRight();
                    evt.consume();
                    break;
                }
            }
        }
    });
    add(locationField);
    locationField.setToolTipText("Current display range");
    locationField.setPreferredSize(LOCATION_SIZE);
    locationField.setMaximumSize(LOCATION_SIZE);
    locationField.setMinimumSize(LOCATION_SIZE);

    add(getRigidPadding());

    JButton goButton = (JButton) add(new JButton("  Go  "));
    goButton.putClientProperty("JButton.buttonType", buttonStyle);
    goButton.putClientProperty("JButton.segmentPosition", "only");
    goButton.setToolTipText("Go to specified range (Enter)");
    goButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setRangeFromText(locationField.getEditor().getItem().toString());
        }
    });

    add(getRigidPadding());

    JLabel l = new JLabel("Length: ");
    add(l);

    lengthLabel = (JLabel) add(new JLabel());
    lengthLabel.setToolTipText("Length of the current range");
    lengthLabel.setPreferredSize(LENGTH_SIZE);
    lengthLabel.setMaximumSize(LENGTH_SIZE);
    lengthLabel.setMinimumSize(LENGTH_SIZE);

    add(Box.createGlue());

    double screenwidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth();

    JButton afterGo = null;
    //if (screenwidth > 800) {
    final JButton undoButton = (JButton) add(new JButton(""));
    afterGo = undoButton;
    undoButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UNDO));
    undoButton.setToolTipText("Undo range change (" + shortcutMod + "+Z)");
    undoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.undoLocationChange();
        }
    });
    undoButton.putClientProperty("JButton.buttonType", buttonStyle);
    undoButton.putClientProperty("JButton.segmentPosition", "first");
    undoButton.setPreferredSize(ICON_SIZE);
    undoButton.setMinimumSize(ICON_SIZE);
    undoButton.setMaximumSize(ICON_SIZE);

    final JButton redo = (JButton) add(new JButton(""));
    redo.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.REDO));
    redo.setToolTipText("Redo range change (" + shortcutMod + "+Y)");
    redo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.redoLocationChange();
        }
    });
    redo.putClientProperty("JButton.buttonType", buttonStyle);
    redo.putClientProperty("JButton.segmentPosition", "last");
    redo.setPreferredSize(ICON_SIZE);
    redo.setMinimumSize(ICON_SIZE);
    redo.setMaximumSize(ICON_SIZE);
    //}

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton zoomInButton = (JButton) add(new JButton());
    if (afterGo == null) {
        afterGo = zoomInButton;
    }
    zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN));
    zoomInButton.putClientProperty("JButton.buttonType", buttonStyle);
    zoomInButton.putClientProperty("JButton.segmentPosition", "first");
    zoomInButton.setPreferredSize(ICON_SIZE);
    zoomInButton.setMinimumSize(ICON_SIZE);
    zoomInButton.setMaximumSize(ICON_SIZE);
    zoomInButton.setToolTipText("Zoom in (Shift+Up)");
    zoomInButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomIn();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "in"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton zoomOut = (JButton) add(new JButton(""));
    zoomOut.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT));
    zoomOut.setToolTipText("Zoom out (Shift+Down)");
    zoomOut.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomOut();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "out"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });
    zoomOut.putClientProperty("JButton.buttonType", buttonStyle);
    zoomOut.putClientProperty("JButton.segmentPosition", "last");
    zoomOut.setPreferredSize(ICON_SIZE);
    zoomOut.setMinimumSize(ICON_SIZE);
    zoomOut.setMaximumSize(ICON_SIZE);

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton shiftFarLeft = (JButton) add(new JButton());
    shiftFarLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARLEFT));
    shiftFarLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarLeft.putClientProperty("JButton.segmentPosition", "first");
    shiftFarLeft.setToolTipText("Move to the beginning of the genome (Shift+Home)");
    shiftFarLeft.setPreferredSize(ICON_SIZE);
    shiftFarLeft.setMinimumSize(ICON_SIZE);
    shiftFarLeft.setMaximumSize(ICON_SIZE);
    shiftFarLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftLeft = (JButton) add(new JButton());
    shiftLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_LEFT));
    shiftLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
    shiftLeft.setToolTipText("Move left (Shift+Left)");
    shiftLeft.setPreferredSize(ICON_SIZE);
    shiftLeft.setMinimumSize(ICON_SIZE);
    shiftLeft.setMaximumSize(ICON_SIZE);
    shiftLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftRight = (JButton) add(new JButton());
    shiftRight.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_RIGHT));
    shiftRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftRight.putClientProperty("JButton.segmentPosition", "middle");
    shiftRight.setToolTipText("Move right (Shift+Right)");
    shiftRight.setPreferredSize(ICON_SIZE);
    shiftRight.setMinimumSize(ICON_SIZE);
    shiftRight.setMaximumSize(ICON_SIZE);
    shiftRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftFarRight = (JButton) add(new JButton());
    shiftFarRight
            .setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARRIGHT));
    shiftFarRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarRight.putClientProperty("JButton.segmentPosition", "last");
    shiftFarRight.setToolTipText("Move to the end of the genome (Shift+End)");
    shiftFarRight.setPreferredSize(ICON_SIZE);
    shiftFarRight.setMinimumSize(ICON_SIZE);
    shiftFarRight.setMaximumSize(ICON_SIZE);
    shiftFarRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    add(getRigidPadding());

    locationController.addListener(new Listener<LocationChangedEvent>() {
        @Override
        public void handleEvent(LocationChangedEvent event) {
            updateLocation(event.getReference(), (Range) event.getRange());
        }
    });

    // When the genome changes, we may need to invalidate our menu.
    GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() {
        @Override
        public void handleEvent(GenomeChangedEvent event) {
            lastPoppedUp = "INVALID";
        }
    });

    this.addComponentListener(new ComponentListener() {
        @Override
        public void componentResized(ComponentEvent ce) {
            int width = ce.getComponent().getWidth();

            undoButton.setVisible(true);
            redo.setVisible(true);
            zoomInButton.setVisible(true);
            zoomOut.setVisible(true);
            shiftFarLeft.setVisible(true);
            shiftLeft.setVisible(true);
            shiftRight.setVisible(true);
            shiftFarRight.setVisible(true);

            // hide some components if the window isn't wide enough
            if (width < 1200) {
                undoButton.setVisible(false);
                redo.setVisible(false);
            }
            if (width < 1000) {
                shiftFarLeft.setVisible(false);
                shiftFarRight.setVisible(false);

                shiftRight.putClientProperty("JButton.segmentPosition", "last");
                shiftLeft.putClientProperty("JButton.segmentPosition", "first");
            } else {
                shiftRight.putClientProperty("JButton.segmentPosition", "middle");
                shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
            }
        }

        public void componentMoved(ComponentEvent ce) {
        }

        @Override
        public void componentShown(ComponentEvent ce) {
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
        }
    });
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.RefineFEGeometryWidget.java

@Override
public void leftPressed(final Point p) {
    m_warning = false;//  ww w.java 2 s  .co m

    try {
        if (m_geometryBuilder == null)
            return;

        final IMapPanel mapPanel = getMapPanel();
        final Object newNode = checkNewNode(p);
        if (newNode == null)
            mapPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

        if (newNode instanceof IFE1D2DNode) {
            final GM_Point point = ((IFE1D2DNode) newNode).getPoint();
            m_currentMapPoint = MapUtilities.retransform(getMapPanel(), point);
            m_geometryBuilder.addPoint(point);
        } else {
            m_currentMapPoint = p;
            m_geometryBuilder.addPoint(MapUtilities.transform(mapPanel, p));
        }
        mapPanel.setCursor(Cursor.getDefaultCursor());

    } catch (final Exception e) {
        e.printStackTrace();
        final IStatus status = StatusUtilities.statusFromThrowable(e);
        KalypsoModel1D2DPlugin.getDefault().getLog().log(status);
        reinit();
    }
}

From source file:Proiect.uploadFTP.java

public void propFTP() {
    uploadFTP.setBackground(Encrypter.color_light);
    pan1.setBackground(Encrypter.color_light);
    pan1.setBorder(BorderFactory.createEmptyBorder(6, 5, 10, 5));
    pan2.setBackground(Encrypter.color_light);
    inpan1.setBackground(Encrypter.color_light);
    inpan2.setBackground(Encrypter.color_light);
    pan3.setBackground(Encrypter.color_light);
    pan4.setBackground(Encrypter.color_light);

    adress.setForeground(Encrypter.color_blue);
    user.setForeground(Encrypter.color_blue);
    pass.setForeground(Encrypter.color_blue);
    folder.setForeground(Encrypter.color_blue);
    filen.setForeground(Encrypter.color_blue);

    adressf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    adressf.setSelectionColor(Encrypter.color_black);
    adressf.setSelectedTextColor(Encrypter.color_white);
    adressf.setBackground(Encrypter.color_light);

    userf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    userf.setSelectionColor(Encrypter.color_black);
    userf.setSelectedTextColor(Encrypter.color_white);
    userf.setBackground(Encrypter.color_light);

    passf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    passf.setSelectionColor(Encrypter.color_black);
    passf.setSelectedTextColor(Encrypter.color_white);
    passf.setBackground(Encrypter.color_light);

    folderf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    folderf.setSelectionColor(Encrypter.color_black);
    folderf.setSelectedTextColor(Encrypter.color_white);
    folderf.setBackground(Encrypter.color_light);

    status.setHorizontalAlignment(SwingConstants.RIGHT);

    ImageIcon title_icon = getImageIcon("assets/icons/upload.png");
    titleFTP.setForeground(Encrypter.color_blue);
    titleFTP.setFont(Encrypter.font16);/*from ww  w  .  ja  v  a  2  s.  c om*/
    titleFTP.setIcon(title_icon);

    connect.setBackground(Encrypter.color_light);
    connect.setBorder(BorderFactory.createEmptyBorder());
    connect.setForeground(Encrypter.color_black);
    connect.setFont(Encrypter.font16);
    connect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    connect.setToolTipText("Transfer File");

    browsef.setBackground(Encrypter.color_light);
    browsef.setBorder(BorderFactory.createEmptyBorder());
    browsef.setForeground(Encrypter.color_black);
    browsef.setFont(Encrypter.font16);
    browsef.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    browsef.setToolTipText("Add file");

    ImageIcon exit_icon = getImageIcon("assets/icons/exit.png");
    exit.setBackground(Encrypter.color_light);
    exit.setBorder(BorderFactory.createLineBorder(Encrypter.color_dark, 0));
    exit.setForeground(Encrypter.color_black);
    exit.setFont(Encrypter.font16);
    exit.setIcon(exit_icon);
    exit.setToolTipText("Exit");

    ImageIcon adv_icon = getImageIcon("assets/icons/adv_ftp.png");
    adv.setIcon(adv_icon);
    adv.setBackground(Encrypter.color_light);
    adv.setBorder(BorderFactory.createLineBorder(Encrypter.color_light, 0));
    adv.setFont(Encrypter.font16);
    adv.setToolTipText("Display server files");
    adv.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("Text", "txt"));
    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("HTM", "htm"));
    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("XHTML", "xhtml"));
    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("HTML", "html"));
    chooserf.setAcceptAllFileFilterUsed(false);
}

From source file:com.intel.stl.ui.common.view.JumpChartPanel.java

@Override
public void chartMouseMoved(ChartMouseEvent cme) {
    JPopupMenu popup = getPopupMenu();
    if (popup != null && popup.isShowing()) {
        return;// ww  w . j  av  a  2  s.com
    }

    ChartEntity xyItem = cme.getEntity();
    if (xyItem instanceof CategoryLabelEntity) {
        CategoryLabelEntity newCatEntity = (CategoryLabelEntity) xyItem;
        if (highlightedEntity != null && newCatEntity.getKey().equals(highlightedEntity.getKey())) {
            return;
        }

        if (highlightedEntity != null) {
            highlightEntity(highlightedEntity, false);
        }

        highlightedEntity = (CategoryLabelEntity) xyItem;
        if (categoryAxis == null) {
            CategoryPlot plot = getChart().getCategoryPlot();
            categoryAxis = plot.getDomainAxis();
        }
        highlightEntity(highlightedEntity, true);
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {
        if (highlightedEntity != null) {
            highlightEntity(highlightedEntity, false);
            highlightedEntity = null;
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:it.imtech.metadata.MetaUtility.java

private JComboBox addClassificationChoice(JPanel choice, final String sequence, final String panelname) {

    int selected = 0;
    int index = 0;
    int count = 1;

    for (Map.Entry<String, String> vc : availableClassifications.entrySet()) {
        if (count == 1 && !selectedClassificationList.containsKey(panelname + "---" + sequence)) {
            selected = index;/* w w  w .  ja  v  a 2s.c o m*/
            selectedClassificationList.put(panelname + "---" + sequence, vc.getKey());
        }

        if (selectedClassificationList.containsKey(panelname + "---" + sequence)) {
            if (selectedClassificationList.get(panelname + "---" + sequence).equals(vc.getKey())) {
                selected = index;
            }
        }
        index++;
    }
    try {
        classifications_reader(sequence, panelname);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }

    final ComboMapImpl model = new ComboMapImpl();
    model.putAllLinked(availableClassifications);

    JComboBox result = new javax.swing.JComboBox(model);

    result.setSelectedIndex(selected);
    model.specialRenderCombo(result);

    result.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            JComboBox comboBox = (JComboBox) event.getSource();
            Map.Entry<String, String> c = (Map.Entry<String, String>) comboBox.getSelectedItem();

            selectedClassificationList.put(panelname + "---" + sequence, c.getKey());

            BookImporter.getInstance()
                    .createComponentMap(BookImporter.getInstance().metadatapanels.get(panelname).getPanel());
            JPanel innerPanel = (JPanel) BookImporter.getInstance()
                    .getComponentByName(panelname + "---ImPannelloClassif---" + sequence);
            innerPanel.removeAll();

            try {
                classifications_reader(sequence, panelname);
                addClassification(innerPanel, classificationMID, sequence, panelname);
            } catch (Exception ex) {
                logger.error(ex.getMessage());
            }

            innerPanel.revalidate();
            BookImporter.getInstance().setCursor(null);
        }
    });

    return result;
}