Example usage for java.awt Cursor Cursor

List of usage examples for java.awt Cursor Cursor

Introduction

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

Prototype

protected Cursor(String name) 

Source Link

Document

Creates a new custom cursor object with the specified name.

Note: this constructor should only be used by AWT implementations as part of their support for custom cursors.

Usage

From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateImportDialog.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);
    getContentPane().setBackground(getBackground());

    topPanel = new JPanel();
    topPanel.setBackground(getBackground());

    linkPanel = new JPanel();
    linkPanel.setBackground(topPanel.getBackground());

    linkLeftPanel = new JPanel();
    linkLeftPanel.setBackground(linkPanel.getBackground());

    linkLeftSelectAllLabel = new JLabel("<html><u>All</u></html>");
    linkLeftSelectAllLabel.setForeground(Color.BLUE);
    linkLeftSelectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkLeftSelectAllLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                importTreeTable.getModel().setValueAt(true, row, IMPORT_SELECTED_COLUMN);
            }//  ww  w .  j a va2 s. co m
        }
    });

    linkLeftDeselectAllLabel = new JLabel("<html><u>None</u></html>");
    linkLeftDeselectAllLabel.setForeground(Color.BLUE);
    linkLeftDeselectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkLeftDeselectAllLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                importTreeTable.getModel().setValueAt(false, row, IMPORT_SELECTED_COLUMN);
            }
        }
    });

    linkRightPanel = new JPanel();
    linkRightPanel.setBackground(linkPanel.getBackground());

    linkRightOverwriteAllLabel = new JLabel("<html><u>All</u></html>");
    linkRightOverwriteAllLabel.setForeground(Color.BLUE);
    linkRightOverwriteAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkRightOverwriteAllLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                TreePath path = importTreeTable.getPathForRow(row);
                if (path != null) {
                    ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent();
                    if (node instanceof ImportLibraryTreeTableNode) {
                        ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node;
                        if (libraryNode.getConflicts().getMatchingLibrary() != null) {
                            importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    } else if (node instanceof ImportCodeTemplateTreeTableNode) {
                        ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node;
                        if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) {
                            importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    }
                }
            }
        }
    });

    linkRightOverwriteNoneLabel = new JLabel("<html><u>None</u></html>");
    linkRightOverwriteNoneLabel.setForeground(Color.BLUE);
    linkRightOverwriteNoneLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkRightOverwriteNoneLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                TreePath path = importTreeTable.getPathForRow(row);
                if (path != null) {
                    ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent();
                    if (node instanceof ImportLibraryTreeTableNode) {
                        ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node;
                        if (libraryNode.getConflicts().getMatchingLibrary() != null) {
                            importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    } else if (node instanceof ImportCodeTemplateTreeTableNode) {
                        ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node;
                        if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) {
                            importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    }
                }
            }
        }
    });

    final TableCellEditor templateCellEditor = new NameCellEditor();

    importTreeTable = new JXTreeTable() {
        @Override
        public boolean isCellEditable(int row, int column) {
            return (column == IMPORT_OVERWRITE_COLUMN || column == IMPORT_SELECTED_COLUMN
                    || column == IMPORT_NAME_COLUMN);
        }

        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            if (isHierarchical(column)) {
                return templateCellEditor;
            } else {
                return super.getCellEditor(row, column);
            }
        }
    };

    importTreeTable.setLargeModel(true);
    DefaultTreeTableModel model = new ImportTreeTableModel();
    model.setColumnIdentifiers(Arrays.asList(new String[] { "", "Name", "Overwrite", "Conflicts", "Id" }));

    DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode();
    model.setRoot(rootNode);
    importTreeTable.setTreeTableModel(model);

    Set<String> addedCodeTemplateIds = new HashSet<String>();

    if (unassignedCodeTemplates) {
        ImportTreeTableNode libraryNode = new ImportUnassignedLibraryTreeTableNode("Select a library", "");
        CodeTemplateLibrary library = importLibraries.get(0);

        for (CodeTemplate codeTemplate : library.getCodeTemplates()) {
            if (!addedCodeTemplateIds.contains(codeTemplate.getId())) {
                libraryNode
                        .add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(), codeTemplate.getId()));
                addedCodeTemplateIds.add(codeTemplate.getId());
                importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate);
            }
        }

        rootNode.add(libraryNode);
    } else {
        Set<String> addedLibraryIds = new HashSet<String>();

        for (CodeTemplateLibrary library : importLibraries) {
            if (!addedLibraryIds.contains(library.getId())) {
                ImportTreeTableNode libraryNode = new ImportLibraryTreeTableNode(library.getName(),
                        library.getId());
                importLibraryMap.put(library.getId(), library);

                for (CodeTemplate codeTemplate : library.getCodeTemplates()) {
                    if (!addedCodeTemplateIds.contains(codeTemplate.getId())) {
                        libraryNode.add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(),
                                codeTemplate.getId()));
                        addedCodeTemplateIds.add(codeTemplate.getId());
                        importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate);
                    }
                }

                rootNode.add(libraryNode);
                addedLibraryIds.add(library.getId());
            }
        }
    }

    importTreeTable.setOpenIcon(null);
    importTreeTable.setClosedIcon(null);
    importTreeTable.setLeafIcon(null);
    importTreeTable.setRootVisible(false);
    importTreeTable.setDoubleBuffered(true);
    importTreeTable.setDragEnabled(false);
    importTreeTable.setRowSelectionAllowed(true);
    importTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    importTreeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    importTreeTable.setFocusable(true);
    importTreeTable.setOpaque(true);
    importTreeTable.getTableHeader().setReorderingAllowed(false);
    importTreeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    importTreeTable.setEditable(true);
    importTreeTable.setSortable(false);
    importTreeTable.setAutoCreateColumnsFromModel(false);
    importTreeTable.setShowGrid(true, true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        importTreeTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }

    importTreeTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent evt) {
            checkSelection(evt);
        }

        @Override
        public void mouseReleased(MouseEvent evt) {
            checkSelection(evt);
        }

        private void checkSelection(MouseEvent evt) {
            int row = importTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY()));

            if (row < 0) {
                importTreeTable.clearSelection();
            }
        }
    });

    importTreeTable.addTreeWillExpandListener(new TreeWillExpandListener() {
        @Override
        public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
        }

        @Override
        public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
            throw new ExpandVetoException(event);
        }
    });

    importTreeTable.setTreeCellRenderer(new NameCellRenderer());

    importTreeTable.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent evt) {
            if (evt.getColumn() != IMPORT_CONFLICTS_COLUMN) {
                for (int row = evt.getFirstRow(); row <= evt.getLastRow()
                        && row < importTreeTable.getRowCount(); row++) {
                    TreePath path = importTreeTable.getPathForRow(row);
                    if (path != null) {
                        ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent();

                        if (path.getPathCount() == 2) {
                            if (node instanceof ImportUnassignedLibraryTreeTableNode) {
                                String libraryName = (String) node.getValueAt(IMPORT_NAME_COLUMN);
                                String libraryId = null;
                                for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel
                                        .getCachedCodeTemplateLibraries().values()) {
                                    if (library.getName().equals(libraryName)) {
                                        libraryId = library.getId();
                                        break;
                                    }
                                }
                                node.setValueAt(libraryId, IMPORT_ID_COLUMN);
                            } else if (node instanceof ImportLibraryTreeTableNode) {
                                ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node;
                                libraryNode.setConflicts(getLibraryConflicts(node));
                            }

                            for (Enumeration<? extends TreeTableNode> codeTemplateNodes = node
                                    .children(); codeTemplateNodes.hasMoreElements();) {
                                ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes
                                        .nextElement();
                                codeTemplateNode.setConflicts(getCodeTemplateConflicts(codeTemplateNode));
                            }

                            importTreeTable.updateUI();
                        } else if (path.getPathCount() == 3) {
                            ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node;
                            codeTemplateNode.setConflicts(getCodeTemplateConflicts(node));
                        }
                    }
                }
            }

            updateImportButton();
            updateErrorsAndWarnings();
        }
    });

    importTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                updateImportButton();
                updateErrorsAndWarnings();
            }
        }
    });

    importTreeTable.expandAll();

    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMinWidth(20);
    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMaxWidth(20);
    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN)
            .setCellRenderer(new ImportSelectedCellRenderer());
    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN)
            .setCellEditor(new ImportSelectedCellEditor());

    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMinWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMaxWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN)
            .setCellRenderer(new OverwriteCellRenderer());
    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN)
            .setCellEditor(new OverwriteCellEditor());

    importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMinWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMaxWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setCellRenderer(new IconCellRenderer());

    importTreeTable.getColumnModel().removeColumn(importTreeTable.getColumnModel().getColumn(IMPORT_ID_COLUMN));

    importTreeTableScrollPane = new JScrollPane(importTreeTable);
    importTreeTableScrollPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(0x6E6E6E)));

    warningsPanel = new JPanel();
    warningsPanel.setBackground(getBackground());
    warningsPanel.setVisible(false);

    warningsLabel = new JLabel(UIConstants.ICON_WARNING);

    warningsTextArea = new JTextArea();
    warningsTextArea.setLineWrap(true);
    warningsTextArea.setWrapStyleWord(true);

    errorsPanel = new JPanel();
    errorsPanel.setBackground(getBackground());
    errorsPanel.setVisible(false);

    errorsLabel = new JLabel(UIConstants.ICON_ERROR);

    errorsTextArea = new JTextArea();
    errorsTextArea.setLineWrap(true);
    errorsTextArea.setWrapStyleWord(true);

    separator = new JSeparator();

    buttonPanel = new JPanel();
    buttonPanel.setBackground(getBackground());

    importButton = new JButton("Import");
    importButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                boolean warnings = false;
                for (Enumeration<? extends TreeTableNode> libraryNodes = ((TreeTableNode) importTreeTable
                        .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) {
                    for (Enumeration<? extends TreeTableNode> codeTemplateNodes = libraryNodes.nextElement()
                            .children(); codeTemplateNodes.hasMoreElements();) {
                        ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes
                                .nextElement();

                        if ((boolean) codeTemplateNode.getValueAt(IMPORT_SELECTED_COLUMN)) {
                            CodeTemplateConflicts conflicts = codeTemplateNode.getConflicts();
                            if (conflicts.getMatchingCodeTemplate() != null) {
                                warnings = true;
                                break;
                            }
                        }
                    }

                    if (warnings) {
                        break;
                    }
                }

                if (!warnings || PlatformUI.MIRTH_FRAME.alertOption(CodeTemplateImportDialog.this,
                        "Some selected rows have warnings. Are you sure you wish to continue?")) {
                    save();
                    dispose();
                }
            } catch (Exception e) {
                PlatformUI.MIRTH_FRAME.alertThrowable(CodeTemplateImportDialog.this, e,
                        "Unable to import: " + e.getMessage());
            }
        }
    });

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            if (confirmClose()) {
                dispose();
            }
        }
    });

    updateImportButton();
}

From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java

/**
 * Helper method to add a contextual menu on a text component that will allow for Copy & Select All text actions.
 *//*from w w w .  ja va2 s. c o m*/
protected void addCopyMenu(final JTextComponent component) {
    Preconditions.checkNotNull(component);

    if (!component.isEditable()) {
        component.setCursor(new Cursor(Cursor.TEXT_CURSOR));
    }

    final JPopupMenu contextMenu = new JPopupMenu();
    JMenuItem copy = new JMenuItem(component.getActionMap().get(DefaultEditorKit.copyAction));
    copy.setText(i18n.getString(I18n.TEXT_COPY_ID));
    contextMenu.add(copy);
    contextMenu.addSeparator();

    JMenuItem selectAll = new JMenuItem(component.getActionMap().get(DefaultEditorKit.selectAllAction));
    selectAll.setText(i18n.getString(I18n.TEXT_SELECT_ALL_ID));
    contextMenu.add(selectAll);

    component.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                contextMenu.show(component, e.getX(), e.getY());
            }
        }
    });
}

From source file:org.ut.biolab.medsavant.client.view.Menu.java

public void addSection(SectionView section) {

    final JPanel sectionPanel = ViewUtil.getClearPanel();
    sectionPanel.setLayout(new BoxLayout(sectionPanel, BoxLayout.Y_AXIS));
    sectionPanel.setVisible(false);//from   www  .  j  av  a2s.  c o m

    //HoverButton sectionButton = new SectionButton(section, sectionPanel);
    //sectionButton.setSelectedColor(ViewUtil.getSecondaryMenuColor());

    final JToggleButton sectionButton = ViewUtil.getTogglableIconButton(section.getIcon());
    sectionButton.setName(section.getName());
    sectionButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    sectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            primaryMenuButtons.setSelected(sectionButton.getModel(), true);
            if (previousSectionPanel != null) {
                previousSectionPanel.setVisible(false);
            }
            // Act as if we clicked the first sub-section button.
            ((SubSectionButton) sectionPanel.getComponent(0)).subSectionClicked();
            sectionPanel.setVisible(true);

            previousSectionPanel = sectionPanel;
            primaryMenu.invalidate();
        }
    });

    ButtonGroup subSectionsGroup = new ButtonGroup();

    for (SubSectionView v : section.getSubSections()) {
        subSectionViews.add(v);

        SubSectionButton subSectionButton = new SubSectionButton(v, subSectionsGroup);
        sectionPanel.add(subSectionButton);
        subSectionsGroup.add(subSectionButton);

        map.put(v, subSectionButton);
    }

    primaryMenuButtons.add(sectionButton);

    sectionPanel.add(Box.createVerticalStrut(50));

    secondaryMenu.add(sectionPanel);

    primaryMenuSectionButtonContainer.add(ViewUtil.subTextComponent(sectionButton, section.getName()));
    primaryMenuSectionButtonContainer.add(ViewUtil.getLargeSeparator());

}

From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java

private void formMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMousePressed
    if (evt.getButton() == MouseEvent.BUTTON1) {
        oldX = evt.getX();//from   ww  w.  j  av  a2 s  . c  om
        oldY = evt.getY();
        if (!noObjects) {
            move = true;
            this.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        }
    }
}

From source file:client.ui.FilePane.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*  w  ww . j  av  a  2 s .  c om*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    fileButtonPane = new JPanel();
    uploadFileButton = new JButton();
    downloadFileButton = new JButton();
    deleteFileButton = new JButton();
    renameFileButton = new JButton();
    authorizationButton = new JButton();
    jSeparator1 = new JSeparator();
    addNoteButton = new JButton();
    deleteNoteButton = new JButton();
    jSeparator2 = new JSeparator();
    targetIDField = new JTextField();
    searchUserButton = new JButton();
    returnButton = new JButton();
    jSeparator3 = new JSeparator();
    refreshButton = new JButton();
    jSeparator4 = new JSeparator();
    changePasswdButton = new JButton();
    fileSplitPane = new JSplitPane();
    jSplitPane2 = new JSplitPane();
    fileInfoScroll = new JScrollPane();
    fileInfoTable = new JTable();
    noteDisplayScroll = new JScrollPane();
    noteTable = new JTable();
    jSplitPane1 = new JSplitPane();
    fileDisplayScroll = new JScrollPane();
    fileContentArea = new JTextArea();
    noteInputScroll = new JScrollPane();
    noteInputArea = new JTextArea();

    FormListener formListener = new FormListener();

    setForeground(new Color(240, 240, 240));
    setFont(new Font("", 0, 12)); // NOI18N
    setMaximumSize(new Dimension(1366, 768));
    setPreferredSize(new Dimension(1366, 700));

    fileButtonPane.setMaximumSize(new Dimension(32767, 50));
    fileButtonPane.setMinimumSize(new Dimension(404, 50));

    uploadFileButton.setFont(new Font("", 0, 12)); // NOI18N
    uploadFileButton.setText("");
    uploadFileButton.setActionCommand("JButton1");
    uploadFileButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    uploadFileButton.setBorderPainted(false);
    uploadFileButton.setContentAreaFilled(false);
    uploadFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    uploadFileButton.setFocusPainted(false);
    uploadFileButton.setMaximumSize(new Dimension(30, 20));
    uploadFileButton.setMinimumSize(new Dimension(30, 20));
    uploadFileButton.addMouseListener(formListener);
    uploadFileButton.addActionListener(formListener);

    downloadFileButton.setFont(new Font("", 0, 12)); // NOI18N
    downloadFileButton.setText("");
    downloadFileButton.setActionCommand("JButton1");
    downloadFileButton.setBorder(null);
    downloadFileButton.setBorderPainted(false);
    downloadFileButton.setContentAreaFilled(false);
    downloadFileButton.setEnabled(false);
    downloadFileButton.setFocusPainted(false);
    downloadFileButton.setMaximumSize(new Dimension(30, 20));
    downloadFileButton.setMinimumSize(new Dimension(30, 20));
    downloadFileButton.setPreferredSize(new Dimension(30, 20));
    downloadFileButton.addMouseListener(formListener);
    downloadFileButton.addActionListener(formListener);

    deleteFileButton.setFont(new Font("", 0, 12)); // NOI18N
    deleteFileButton.setText("");
    deleteFileButton.setBorder(null);
    deleteFileButton.setBorderPainted(false);
    deleteFileButton.setContentAreaFilled(false);
    deleteFileButton.setEnabled(false);
    deleteFileButton.setFocusPainted(false);
    deleteFileButton.addMouseListener(formListener);
    deleteFileButton.addActionListener(formListener);

    renameFileButton.setFont(new Font("", 0, 12)); // NOI18N
    renameFileButton.setText("???");
    renameFileButton.setBorder(null);
    renameFileButton.setBorderPainted(false);
    renameFileButton.setContentAreaFilled(false);
    renameFileButton.setEnabled(false);
    renameFileButton.setFocusPainted(false);
    renameFileButton.addMouseListener(formListener);
    renameFileButton.addActionListener(formListener);

    authorizationButton.setFont(new Font("", 0, 12)); // NOI18N
    authorizationButton.setText("??");
    authorizationButton.setBorder(null);
    authorizationButton.setBorderPainted(false);
    authorizationButton.setContentAreaFilled(false);
    authorizationButton.setEnabled(false);
    authorizationButton.setFocusPainted(false);
    authorizationButton.addMouseListener(formListener);
    authorizationButton.addActionListener(formListener);

    jSeparator1.setOrientation(SwingConstants.VERTICAL);

    addNoteButton.setFont(new Font("", 0, 12)); // NOI18N
    addNoteButton.setText("");
    addNoteButton.setActionCommand("JButton1");
    addNoteButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    addNoteButton.setBorderPainted(false);
    addNoteButton.setContentAreaFilled(false);
    addNoteButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    addNoteButton.setEnabled(false);
    addNoteButton.setFocusPainted(false);
    addNoteButton.setMaximumSize(new Dimension(30, 20));
    addNoteButton.setMinimumSize(new Dimension(30, 20));
    addNoteButton.addMouseListener(formListener);
    addNoteButton.addActionListener(formListener);

    deleteNoteButton.setFont(new Font("", 0, 12)); // NOI18N
    deleteNoteButton.setText("");
    deleteNoteButton.setActionCommand("JButton1");
    deleteNoteButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    deleteNoteButton.setBorderPainted(false);
    deleteNoteButton.setContentAreaFilled(false);
    deleteNoteButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    deleteNoteButton.setEnabled(false);
    deleteNoteButton.setFocusPainted(false);
    deleteNoteButton.setMaximumSize(new Dimension(30, 20));
    deleteNoteButton.setMinimumSize(new Dimension(30, 20));
    deleteNoteButton.addMouseListener(formListener);
    deleteNoteButton.addActionListener(formListener);

    jSeparator2.setOrientation(SwingConstants.VERTICAL);

    targetIDField.setFont(new Font("", 0, 12)); // NOI18N

    searchUserButton.setFont(new Font("", 0, 12)); // NOI18N
    searchUserButton.setText("");
    searchUserButton.setActionCommand("JButton1");
    searchUserButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    searchUserButton.setBorderPainted(false);
    searchUserButton.setContentAreaFilled(false);
    searchUserButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    searchUserButton.setFocusPainted(false);
    searchUserButton.setMaximumSize(new Dimension(30, 20));
    searchUserButton.setMinimumSize(new Dimension(30, 20));
    searchUserButton.addMouseListener(formListener);
    searchUserButton.addActionListener(formListener);

    returnButton.setFont(new Font("", 0, 12)); // NOI18N
    returnButton.setText("");
    returnButton.setActionCommand("JButton1");
    returnButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    returnButton.setBorderPainted(false);
    returnButton.setContentAreaFilled(false);
    returnButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    returnButton.setFocusPainted(false);
    returnButton.setMaximumSize(new Dimension(30, 20));
    returnButton.setMinimumSize(new Dimension(30, 20));
    returnButton.addMouseListener(formListener);
    returnButton.addActionListener(formListener);

    jSeparator3.setOrientation(SwingConstants.VERTICAL);

    refreshButton.setFont(new Font("", 0, 12)); // NOI18N
    refreshButton.setText("");
    refreshButton.setActionCommand("JButton1");
    refreshButton.setBorder(null);
    refreshButton.setBorderPainted(false);
    refreshButton.setContentAreaFilled(false);
    refreshButton.setFocusPainted(false);
    refreshButton.setMaximumSize(new Dimension(30, 20));
    refreshButton.setMinimumSize(new Dimension(30, 20));
    refreshButton.setPreferredSize(new Dimension(30, 20));
    refreshButton.addMouseListener(formListener);
    refreshButton.addActionListener(formListener);

    jSeparator4.setOrientation(SwingConstants.VERTICAL);

    changePasswdButton.setFont(new Font("", 0, 12)); // NOI18N
    changePasswdButton.setText("?");
    changePasswdButton.setActionCommand("JButton1");
    changePasswdButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    changePasswdButton.setBorderPainted(false);
    changePasswdButton.setContentAreaFilled(false);
    changePasswdButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    changePasswdButton.setFocusPainted(false);
    changePasswdButton.setMaximumSize(new Dimension(30, 20));
    changePasswdButton.setMinimumSize(new Dimension(30, 20));
    changePasswdButton.addMouseListener(formListener);
    changePasswdButton.addActionListener(formListener);

    GroupLayout fileButtonPaneLayout = new GroupLayout(fileButtonPane);
    fileButtonPane.setLayout(fileButtonPaneLayout);
    fileButtonPaneLayout.setHorizontalGroup(fileButtonPaneLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(fileButtonPaneLayout.createSequentialGroup()
                    .addComponent(uploadFileButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(downloadFileButton, GroupLayout.PREFERRED_SIZE, 46,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(deleteFileButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(renameFileButton, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(authorizationButton, GroupLayout.PREFERRED_SIZE, 63,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(addNoteButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(deleteNoteButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(targetIDField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(searchUserButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(returnButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(refreshButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator4, GroupLayout.PREFERRED_SIZE, 2, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(changePasswdButton,
                            GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(18, Short.MAX_VALUE)));
    fileButtonPaneLayout.setVerticalGroup(fileButtonPaneLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING,
                    fileButtonPaneLayout.createSequentialGroup().addContainerGap().addGroup(fileButtonPaneLayout
                            .createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(jSeparator4)
                            .addGroup(fileButtonPaneLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                    .addGroup(fileButtonPaneLayout
                                            .createParallelGroup(GroupLayout.Alignment.TRAILING)
                                            .addComponent(changePasswdButton, GroupLayout.PREFERRED_SIZE, 25,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addGroup(fileButtonPaneLayout
                                                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                                                    .addComponent(refreshButton, GroupLayout.PREFERRED_SIZE, 25,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addGroup(fileButtonPaneLayout
                                                            .createParallelGroup(
                                                                    GroupLayout.Alignment.TRAILING, false)
                                                            .addComponent(jSeparator2)
                                                            .addGroup(fileButtonPaneLayout
                                                                    .createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                    .addComponent(addNoteButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(deleteNoteButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jSeparator1)
                                                            .addGroup(fileButtonPaneLayout
                                                                    .createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                    .addComponent(downloadFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(deleteFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(renameFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(authorizationButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(uploadFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jSeparator3)
                                                            .addGroup(GroupLayout.Alignment.LEADING,
                                                                    fileButtonPaneLayout.createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                            .addComponent(targetIDField)
                                                                            .addComponent(searchUserButton,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    25,
                                                                                    GroupLayout.PREFERRED_SIZE)
                                                                            .addComponent(returnButton,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    25,
                                                                                    GroupLayout.PREFERRED_SIZE)))))))
                            .addGap(15, 15, 15)));

    fileSplitPane.setBackground(new Color(255, 255, 255));
    fileSplitPane.setDividerLocation(750);
    fileSplitPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    fileSplitPane.setMaximumSize(new Dimension(1366, 768));
    fileSplitPane.setPreferredSize(new Dimension(701, 646));

    jSplitPane2.setDividerLocation(400);
    jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane2.setContinuousLayout(true);
    jSplitPane2.setMaximumSize(new Dimension(1366, 768));

    fileInfoScroll.setBackground(new Color(255, 255, 255));
    fileInfoScroll.setFont(new Font("", 0, 12)); // NOI18N
    fileInfoScroll.getViewport().setBackground(Color.WHITE);
    fileInfoScroll.addMouseListener(formListener);

    fileInfoTable.setAutoCreateRowSorter(true);
    fileInfoTable.setFont(new Font("", 0, 12)); // NOI18N
    fileInfoTable.setModel(fileTableModel);
    fileInfoTable.getTableHeader().setFont(new Font("", 0, 12));
    fileInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    fileInfoTable.setRowHeight(20);
    fileInfoTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fileInfoTable.setShowHorizontalLines(false);
    fileInfoTable.setShowVerticalLines(false);
    fileInfoTable.addMouseListener(formListener);
    fileInfoTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            fileSelectedChanged(evt);
        }
    });
    fileInfoScroll.setViewportView(fileInfoTable);

    jSplitPane2.setTopComponent(fileInfoScroll);

    noteDisplayScroll.setBackground(new Color(255, 255, 255));
    noteDisplayScroll.setFont(new Font("", 0, 12)); // NOI18N
    noteDisplayScroll.getViewport().setBackground(Color.WHITE);
    noteDisplayScroll.addMouseListener(formListener);

    noteTable.setAutoCreateRowSorter(true);
    noteTable.setFont(new Font("", 0, 12)); // NOI18N
    noteTable.setModel(noteTableModel);
    noteTable.getTableHeader().setFont(new Font("", 0, 12));
    noteTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    noteTable.setRowHeight(20);
    noteTable.setShowHorizontalLines(false);
    noteTable.setShowVerticalLines(false);
    noteTable.addMouseListener(formListener);
    noteTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            noteSelectedChanged(evt);
        }
    });
    noteDisplayScroll.setViewportView(noteTable);

    jSplitPane2.setBottomComponent(noteDisplayScroll);

    fileSplitPane.setLeftComponent(jSplitPane2);

    jSplitPane1.setDividerLocation(500);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);

    fileDisplayScroll.setFont(new Font("", 0, 12)); // NOI18N
    fileDisplayScroll.setMinimumSize(new Dimension(30, 30));

    fileContentArea.setEditable(false);
    fileContentArea.setColumns(20);
    fileContentArea.setFont(new Font("", 0, 12)); // NOI18N
    fileContentArea.setRows(5);
    fileContentArea.setToolTipText("");
    fileContentArea
            .setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N
    fileDisplayScroll.setViewportView(fileContentArea);

    jSplitPane1.setTopComponent(fileDisplayScroll);

    noteInputScroll.setFont(new Font("", 0, 12)); // NOI18N
    noteInputScroll.setMaximumSize(new Dimension(1366, 768));
    noteInputScroll.setMinimumSize(new Dimension(30, 30));

    noteInputArea.setColumns(20);
    noteInputArea.setFont(new Font("", 0, 12)); // NOI18N
    noteInputArea.setRows(5);
    noteInputArea.setToolTipText("");
    noteInputArea
            .setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N
    noteInputScroll.setViewportView(noteInputArea);

    jSplitPane1.setBottomComponent(noteInputScroll);

    fileSplitPane.setRightComponent(jSplitPane1);

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(fileSplitPane, GroupLayout.DEFAULT_SIZE, 1346, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(fileButtonPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(fileButtonPane, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(fileSplitPane,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
}

From source file:graphviewer.GraphCreate.java

/**
 * Create an instance of a directed graph
 *///  w  w w.j  a  v a 2s  .c o  m
public GraphCreate() {
    super("SCCFinder");
    this.graph = new DirectedSparseMultigraph<Integer, Integer>();
    this.layout = new StaticLayout<Integer, Integer>(this.graph, new Dimension(600, 600));
    final Transformer<Integer, Paint> redVertexPaint = new Transformer<Integer, Paint>() {
        public Paint transform(Integer i) {
            return Color.RED;
        }
    };

    this.vv = new VisualizationViewer<Integer, Integer>(this.layout);
    this.vv.setBackground(Color.white);
    this.vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>());
    this.vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    Container content = getContentPane();
    content.add(this.vv);
    this.vv.getRenderContext().setVertexFillPaintTransformer(redVertexPaint);

    // add listeners to our visual component
    Factory<Integer> vertexFactory = new VertexFactory();
    Factory<Integer> edgeFactory = new EdgeFactory();
    this.graphMouse = new EditingModalGraphMouse<Integer, Integer>(this.vv.getRenderContext(), vertexFactory,
            edgeFactory);
    this.vv.setGraphMouse(this.graphMouse);
    this.vv.addKeyListener(new MyKeyListener());
    final MouseListener[] mls = (MouseListener[]) (this.vv.getListeners(MouseListener.class));
    final MouseListener wrapper = new MyWrapperMouseListener(mls[1]);

    this.graphMouse.setMode(ModalGraphMouse.Mode.EDITING);
    this.vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    this.controls = new JPanel();
    final ScalingControl scaler = new CrossoverScalingControl();
    // add some buttons
    this.plus = new JButton("+");
    this.plus.setToolTipText("Press this button or use the mouse wheel to zoom out");
    this.plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
            setFocusable(false);
        }
    });
    this.minus = new JButton("-");
    this.minus.setToolTipText("Press this button or use the mouse wheel to zoom in");
    this.minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
            setFocusable(false);
        }
    });
    this.edit = new JRadioButton("Editing");
    this.edit.setToolTipText("You can just press 'e' to select this radiobutton");
    this.edit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            graphMouse.setMode(ModalGraphMouse.Mode.EDITING);
            vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
            setFocusable(false);
        }
    });
    this.transform = new JRadioButton("Transforming");
    this.transform.setToolTipText("You can just press 't' to select this radiobutton");
    this.transform.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
            vv.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            setFocusable(false);
        }
    });
    this.pick = new JRadioButton("Picking");
    this.pick.setToolTipText("You can just press 'p' to select this radiobutton");
    this.pick.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
            vv.setCursor(new Cursor(Cursor.HAND_CURSOR));
            setFocusable(false);
        }
    });
    GraphCreate.scc = new JButton("SCC");
    GraphCreate.scc.setToolTipText("Strongly Connected Components algorithm");
    GraphCreate.scc.setEnabled(false);
    GraphCreate.scc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            createMathgraph();
            GraphCreate.scc.setEnabled(false);
            edit.setEnabled(false);
            pick.setSelected(true);
            setFocusable(false);
            sccButtonPressed = true;
            graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
            vv.setCursor(new Cursor(Cursor.HAND_CURSOR));
            vv.removeMouseListener(mls[1]);
            vv.addMouseListener(wrapper);
        }
    });
    GraphCreate.clear = new JButton("Clear");
    GraphCreate.clear.setToolTipText("Clears our graph");
    GraphCreate.clear.setEnabled(false);
    GraphCreate.clear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int k = 0; k <= numberOfVertices; k++) {
                graph.removeVertex(k);
            }

            GraphCreate.scc.setEnabled(false);
            GraphCreate.clear.setEnabled(false);
            edit.setEnabled(true);
            edit.setSelected(true);
            setFocusable(false);
            graphMouse.setMode(ModalGraphMouse.Mode.EDITING);
            vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
            vv.getRenderContext().setVertexFillPaintTransformer(redVertexPaint);

            if (sccButtonPressed) {
                vv.removeMouseListener(wrapper);
                vv.addMouseListener(mls[1]);
            }

            vv.repaint();
            // calling garbage collector here
            Runtime r = Runtime.getRuntime();
            r.gc();
            GraphCreate.numberOfEdges = 0;
            GraphCreate.numberOfVertices = 0;
            sccButtonPressed = false;
        }
    });

    ButtonGroup actions = new ButtonGroup();
    actions.add(this.edit);
    actions.add(this.transform);
    actions.add(this.pick);
    this.edit.setSelected(true);
    this.controls.add(this.plus);
    this.controls.add(this.minus);
    this.controls.add(this.edit);
    this.controls.add(this.transform);
    this.controls.add(this.pick);
    this.controls.add(GraphCreate.scc);
    controls.add(GraphCreate.clear);
    this.help = new JButton("Help");
    this.help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(vv, instructions);
            setFocusable(false);
        }
    });
    this.controls.add(this.help);
    content.add(this.controls, BorderLayout.SOUTH);
}

From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java

private void formMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseReleased
    if (evt.getButton() == MouseEvent.BUTTON1) {
        move = false;/*from  w ww .  ja  v  a2  s .com*/
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:org.apache.jmeter.gui.MainFrame.java

/**
 * Create a new JMeter frame./*from ww w.j  a va2 s .c  o m*/
 *
 * @param treeModel
 *            the model for the test tree
 * @param treeListener
 *            the listener for the test tree
 */
public MainFrame(TreeModel treeModel, JMeterTreeListener treeListener) {

    // TODO: Make the running indicator its own class instead of a JButton
    runningIndicator = new JButton(stoppedIcon);
    runningIndicator.setFocusable(false);
    runningIndicator.setBorderPainted(false);
    runningIndicator.setContentAreaFilled(false);
    runningIndicator.setMargin(new Insets(0, 0, 0, 0));

    testTimeDuration = new JLabel("00:00:00"); //$NON-NLS-1$
    testTimeDuration.setToolTipText(JMeterUtils.getResString("duration_tooltip")); //$NON-NLS-1$
    testTimeDuration
            .setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

    totalThreads = new JLabel("0"); // $NON-NLS-1$
    totalThreads.setToolTipText(JMeterUtils.getResString("total_threads_tooltip")); // $NON-NLS-1$

    activeThreads = new JLabel("0"); // $NON-NLS-1$
    activeThreads.setToolTipText(JMeterUtils.getResString("active_threads_tooltip")); // $NON-NLS-1$

    warnIndicator = new JButton(warningIcon);
    warnIndicator.setMargin(new Insets(0, 0, 0, 0));
    // Transparent JButton with no border
    warnIndicator.setOpaque(false);
    warnIndicator.setContentAreaFilled(false);
    warnIndicator.setBorderPainted(false);
    warnIndicator.setCursor(new Cursor(Cursor.HAND_CURSOR));
    warnIndicator.setToolTipText(JMeterUtils.getResString("error_indicator_tooltip")); // $NON-NLS-1$
    warnIndicator.addActionListener(this);

    errorsOrFatalsLabel = new JLabel("0"); // $NON-NLS-1$
    errorsOrFatalsLabel.setToolTipText(JMeterUtils.getResString("error_indicator_tooltip")); // $NON-NLS-1$

    tree = makeTree(treeModel, treeListener);

    GuiPackage.getInstance().setMainFrame(this);
    init();
    initTopLevelDndHandler();
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
}

From source file:edu.umn.ecology.populus.plot.BasicPlotCanvas.java

private void jbInit() throws Exception {
    /*/* w  w  w .jav a 2  s  . co  m*/
    if( info != null ) {
       mainCaption = new HTMLLabel( info.getMainCaption() );
       xCaption = new HTMLLabel( info.getXCaptions()[0] );
       yCaption = new HTMLLabel( info.getYCaptions()[0] );
       yCaption.setDirection( HTMLLabel.DOWN_TO_UP );
    } else {
       mainCaption = new HTMLLabel( "Main Caption" );
       xCaption = new HTMLLabel( "X Caption" );
       yCaption = new HTMLLabel( "Y Caption" );
    }
     */
    //*
    if (info != null) {
        mainCaption = new HTMLMultiLabel(info.getMainCaption());
        xCaption = new HTMLMultiLabel(info.getXCaptions());
        yCaption = new HTMLMultiLabel(info.getYCaptions());
        yCaption.setDirection(HTMLLabel.DOWN_TO_UP);
    } else {
        mainCaption = new HTMLMultiLabel("Main Caption");
        xCaption = new HTMLMultiLabel("X Caption");
        yCaption = new HTMLMultiLabel("Y Caption");
        yCaption.setDirection(HTMLLabel.DOWN_TO_UP);
    }
    setLayout(borderLayout1);
    if (PopPreferencesStorage.isUseJFreeClass()) {
        NumberAxis yAxis = new NumberAxis(null);
        NumberAxis xAxis = new NumberAxis(null);
        xAxis.setAutoRangeIncludesZero(false);

        AbstractXYItemRenderer renderer = null;
        if (info.isBarChart) {
            renderer = new XYBarRenderer();
        } else {
            renderer = new XYLineAndShapeRenderer(true, false);
        }

        XYPlot plot = new XYPlot(null, xAxis, yAxis, renderer);
        plot.setOrientation(PlotOrientation.VERTICAL);

        JFreeChart jfchart = new JFreeChart(null, null, plot, false);
        jfchartpanel = new ChartPanel(jfchart);
        plot.setBackgroundPaint(ColorScheme.bG);

        info.styleJFree(jfchart);
        add(jfchartpanel, MacroLayout.CENTER);
    } else {
        chart = new JCChart(JCChart.PLOT);
        info.styleJC(chart);
        chart.setBackground(ColorScheme.bG);
        chart.setAllowUserChanges(true);
        chart.setTrigger(0, new EventTrigger(InputEvent.SHIFT_MASK, EventTrigger.CUSTOMIZE));
        chart.setTrigger(1, new EventTrigger(InputEvent.BUTTON1_MASK, EventTrigger.ZOOM));
        chart.setResetKey('r');
        chart.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent e) {
                if ((e.getModifiers() & InputEvent.META_MASK) != 0) {
                    info.setAxis(chart);
                    chart.reset();
                }
            }
        });
        chart.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
        chart.setWarningDialog(false);
        add(chart, MacroLayout.CENTER);
    }
    setBGColor();
    add(mainCaption, MacroLayout.NORTH);
    add(xCaption, MacroLayout.SOUTH);
    add(yCaption, MacroLayout.WEST);
}

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * On any menu item click.// ww w.  j  av  a 2 s.  co  m
 */
@Override
public void actionPerformed(ActionEvent arg0) {
    State.print(arg0.getActionCommand());
    switch (arg0.getActionCommand()) {
    case "new": //Try to save work, open new show
        try {
            newShow();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        break;
    case "open": //Try to save work, get new show
        openShow();
        break;
    case "save":
        Main.save();
        break;
    case "saveas":
        try {
            saveAs();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        break;
    case "printpage":
        try {
            desktop.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            desktop.printCurrentPageToPdf();
            desktop.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } catch (IOException e) {
            e.printStackTrace();
        }
        break;
    case "printshow":
        try {
            desktop.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            desktop.printAllPagesToPdf();
            desktop.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } catch (IOException e) {
            e.printStackTrace();
        }
        break;
    case "printdotsheets":
        try {
            desktop.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            new DotSheetMaker().printDotSheets();
            desktop.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        break;
    case "togglegrid":
        Main.getState().getSettings().setShowGrid(!Main.getState().getSettings().shouldShowGrid());
        ((JMenu) getComponent(2)).getMenuComponent(0)
                .setForeground(Main.getState().getSettings().shouldShowGrid() ? Color.BLACK : Color.RED);
        break;
    case "togglenames":
        Main.getState().getSettings().setShowNames(!Main.getState().getSettings().shouldShowNames());
        ((JMenu) getComponent(2)).getMenuComponent(1)
                .setForeground(Main.getState().getSettings().shouldShowNames() ? Color.BLACK : Color.RED);
        break;
    case "toggletext":
        Main.getState().getSettings().setShowText(!Main.getState().getSettings().shouldShowText());
        ((JMenu) getComponent(2)).getMenuComponent(2)
                .setForeground(Main.getState().getSettings().shouldShowText() ? Color.BLACK : Color.RED);
        break;
    case "colordots":
        Main.getState().getSettings().setColorDots(!Main.getState().getSettings().shouldColorDots());
        ((JMenu) getComponent(2)).getMenuComponent(3)
                .setForeground(Main.getState().getSettings().shouldColorDots() ? Color.BLACK : Color.RED);
        break;
    case "changehash":
        Main.getState().getSettings().setCollegeHashes(!Main.getState().getSettings().useCollegeHashes());
        ((JMenuItem) (((JMenu) getComponent(2)).getMenuComponent(4)))
                .setText(Main.getState().getSettings().useCollegeHashes() ? "Change to High School Hashes"
                        : "Change to College Hashes");
        try {
            desktop.getImage();
        } catch (IOException e) {
            e.printStackTrace();
        }
        desktop.getDotDataFrame().updatePosition();
        break;
    case "fontsize":
        changeFontSize();
        break;
    case "play":
        play();
        break;
    case "undo":
        Main.getState().undo();
        desktop.getIO().clearActivePoints();
        desktop.getDotDataFrame().updateAll(desktop.getActivePoints());
        break;
    case "redo":
        Main.getState().redo();
        desktop.getIO().clearActivePoints();
        desktop.getDotDataFrame().updateAll(desktop.getActivePoints());
        break;
    case "help":
        help();
        break;
    case "about":
        about();
        break;
    case "quit":
    default:
        gr.dispatchEvent(new WindowEvent(gr, WindowEvent.WINDOW_CLOSING));
    }
    desktop.getIO().fixControl();
}