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:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java

private AbstractWizardPage getAddTagsPage() {
    //setup page//from  w  ww .  java 2 s .c om
    final DefaultWizardPage page = new DefaultWizardPage("Add Tags") {
        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK);
            fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
        }
    };

    page.addText("Variants can be filtered by tag value in the Filter section.");
    page.addText("Add tags for this set of variants:");

    final String[] patternExamples = { "<Tag Name>", "Sequencer", "Sequencer Version", "Variant Caller",
            "Variant Caller Version", "Technician" };

    locationField = new JComboBox(patternExamples);
    locationField.setEditable(true);

    final JPanel tagContainer = new JPanel();
    ViewUtil.applyVerticalBoxLayout(tagContainer);

    final JTextField valueField = new JTextField();

    final String startingValue = "<Value>";
    valueField.setText(startingValue);

    final JTextArea ta = new JTextArea();
    ta.setRows(10);
    ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    ta.setEditable(false);

    JLabel button = ViewUtil.createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD));
    button.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {

            if (locationField.getSelectedItem().toString().isEmpty()) {
                DialogUtils.displayError("Tag cannot be empty");
                locationField.requestFocus();
                return;
            } else if (locationField.getSelectedItem().toString().equals(patternExamples[0])) {
                DialogUtils.displayError("Enter a valid tag name");
                locationField.requestFocus();
                return;
            }

            if (valueField.getText().toString().isEmpty()) {
                DialogUtils.displayError("Value cannot be empty");
                valueField.requestFocus();
                return;
            } else if (valueField.getText().equals(startingValue)) {
                DialogUtils.displayError("Enter a valid value");
                valueField.requestFocus();
                return;
            }

            VariantTag tag = new VariantTag((String) locationField.getSelectedItem(), valueField.getText());

            variantTags.add(tag);
            ta.append(tag.toString() + "\n");
            valueField.setText("");
        }
    });

    JPanel container2 = new JPanel();
    ViewUtil.clear(container2);
    ViewUtil.applyHorizontalBoxLayout(container2);
    container2.add(locationField);
    container2.add(ViewUtil.clear(new JLabel(" = ")));
    container2.add(valueField);
    container2.add(button);

    page.addComponent(container2);
    locationField.setToolTipText("Current display range");

    locationField.setPreferredSize(LOCATION_SIZE);
    locationField.setMinimumSize(LOCATION_SIZE);

    valueField.setPreferredSize(LOCATION_SIZE);
    valueField.setMinimumSize(LOCATION_SIZE);

    page.addComponent(tagContainer);

    page.addComponent(new JScrollPane(ta));

    JButton clear = new JButton("Clear");
    clear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            variantTags.clear();
            ta.setText("");
            addDefaultTags(variantTags, ta);
        }
    });

    addDefaultTags(variantTags, ta);

    page.addComponent(ViewUtil.alignRight(clear));

    return page;

}

From source file:com.smanempat.controller.ControllerEvaluation.java

public void proccessMining(JTable tableDataSetModel, JTable tableDataSetTesting, JTextField txtNumberOfK,
        JLabel labelPesanError, JTabbedPane jTabbedPane1, JTable tableResult, JTable tableConfMatrix,
        JTable tableTahunTesting, JLabel totalAccuracy, JPanel panelChart, JPanel panelChart1,
        JPanel panelChart2, JRadioButton singleTesting, JRadioButton multiTesting, JTextArea txtArea)
        throws SQLException {
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
    modelEvaluation = new ModelEvaluation();
    int rowCountModel = tableDataSetModel.getRowCount();
    int rowCountTest = tableDataSetTesting.getRowCount();
    int[] tempK;//  w ww.j  ava  2 s.c o  m
    double[][] tempEval;
    double[][] evalValue;
    boolean valid = false;

    /*Validasi Dataset Model dan Dataset Uji*/
    if (rowCountModel == 0) {
        JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error",
                JOptionPane.INFORMATION_MESSAGE,
                new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
        txtNumberOfK.requestFocus();
    } else if (rowCountTest == 0) {
        JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error",
                JOptionPane.INFORMATION_MESSAGE,
                new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
        txtNumberOfK.requestFocus();
    } else {
        valid = true;
    }
    /*Validasi Dataset Model dan Dataset Uji*/

    if (valid == true) {
        if (multiTesting.isSelected()) {
            String iterasi = JOptionPane.showInputDialog("Input Jumlah Iterasi Pengujian :");
            boolean validMulti = false;

            if (iterasi != null) {

                /*Validasi Jumlah Iterasi*/
                if (Pattern.matches("[0-9]+", iterasi) == false && iterasi.length() > 0) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi tidak valid!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (iterasi.isEmpty()) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi tidak boleh kosong!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (iterasi.length() == 9) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi terlalu panjang!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (rowCountTest > rowCountModel) {

                    JOptionPane.showMessageDialog(null, "Data Uji tidak boleh lebih besar daripada data Model!",
                            "Error", JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else {
                    validMulti = true;
                    System.out.println("valiMulti = " + validMulti + " Kok");
                }
                /*Validasi Jumlah Iterasi*/
            }

            if (validMulti == true) {
                tempK = new int[Integer.parseInt(iterasi)];
                evalValue = new double[3][tempK.length];
                for (int i = 0; i < Integer.parseInt(iterasi); i++) {
                    validMulti = false;
                    String k = JOptionPane
                            .showInputDialog("Input Nilai Nearest Neighbor (k) ke " + (i + 1) + " :");
                    if (k != null) {
                        /*Validasi Nilai K Tiap Iterasi*/
                        if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) {
                            JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) tidak valid!",
                                    "Error", JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else if (k.isEmpty()) {
                            JOptionPane.showMessageDialog(null,
                                    "Nilai nearest neighbor (k) tidak boleh kosong!", "Error",
                                    JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else if (k.length() == 9) {
                            JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) terlalu panjang!",
                                    "Error", JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else {
                            validMulti = true;
                        }
                        /*Validasi Nilai K Tiap Iterasi*/
                    }

                    if (validMulti == true) {
                        tempK[i] = Integer.parseInt(k);
                        System.out.println(tempK[i]);
                    } else {
                        break;
                    }
                }

                if (validMulti == true) {
                    for (int i = 0; i < tempK.length; i++) {
                        int kValue = tempK[i];
                        String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel);
                        double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting);
                        String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue,
                                kValue);
                        tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy,
                                tableTahunTesting, tableDataSetTesting, knnValue, i, tempK, panelChart);
                        //Menampung nilai Accuracy
                        evalValue[0][i] = tempEval[0][i];
                        //Menampung nilai Recall
                        evalValue[1][i] = tempEval[1][i];
                        //Menampung nilai Precision
                        evalValue[2][i] = tempEval[2][i];
                        jTabbedPane1.setSelectedIndex(1);
                        txtArea.append(
                                "Tingkat Keberhasilan Sistem dengan Nilai Number of Nearest Neighbor (K) = "
                                        + tempK[i] + "\n");
                        txtArea.append("Akurasi\t\t: " + evalValue[0][i] * 100 + " %\n");
                        txtArea.append("Recall\t\t: " + evalValue[1][i] * 100 + " %\n");
                        txtArea.append("Precision\t: " + evalValue[2][i] * 100 + " %\n");
                        txtArea.append(
                                "=============================================================================\n");
                    }
                    showChart(tempK, evalValue, panelChart, panelChart1, panelChart2);
                }
            }
        } else if (singleTesting.isSelected()) {
            boolean validSingle = false;
            String k = txtNumberOfK.getText();
            int nilaiK = 0;
            evalValue = new double[3][1];

            /*Validasi Nilai Number of Nearest Neighbor*/
            if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) {
                labelPesanError.setText("Number of Nearest Neighbor tidak valid");
                JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (k.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong");
                txtNumberOfK.requestFocus();
            } else if (rowCountModel == 0 && Integer.parseInt(k) >= rowCountModel) {
                JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (rowCountTest == 0 && Integer.parseInt(k) >= rowCountTest) {
                JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (Integer.parseInt(k) >= rowCountModel) {
                JOptionPane.showMessageDialog(null,
                        "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else {
                validSingle = true;
                nilaiK = Integer.parseInt(k);
            }
            /*Validasi Nilai Number of Nearest Neighbor*/

            if (validSingle == true) {
                int confirm;
                int i = 0;
                confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?",
                        "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        null, null);
                if (confirm == JOptionPane.OK_OPTION) {

                    int kValue = Integer.parseInt(txtNumberOfK.getText());
                    String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel);
                    double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting);
                    String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue, kValue);
                    tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy, tableTahunTesting,
                            tableDataSetTesting, knnValue, nilaiK, panelChart);
                    evalValue[0][i] = tempEval[0][0];
                    evalValue[1][i] = tempEval[1][0];
                    evalValue[2][i] = tempEval[2][0];
                    jTabbedPane1.setSelectedIndex(1);
                }
                System.out.println("com.smanempat.controller.ControllerEvaluation.proccessMining()OKOKOK");
                showChart(nilaiK, evalValue, panelChart, panelChart1, panelChart2);
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
            }
        }
    }

}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorComponent.java

/** 
 * Implemented as specified by the {@link Editor} interface.
 * @see Editor#setStructuredDataResults()
 *//*from  w  ww . j av  a 2 s.  c  o  m*/
public void setStructuredDataResults() {
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    view.layoutUI();
    view.setStatus(false);
}

From source file:org.omegat.gui.main.ProjectUICommands.java

public static void projectTeamCreate() {
    UIThreadsUtil.mustBeSwingThread();//from   w w w.  j ava2s .c  o m

    if (Core.getProject().isProjectLoaded()) {
        return;
    }
    new SwingWorker<Object, Void>() {
        File projectRoot;

        protected Object doInBackground() throws Exception {
            Core.getMainWindow().showStatusMessageRB(null);

            final NewTeamProject dialog = new NewTeamProject(Core.getMainWindow().getApplicationFrame());
            dialog.setVisible(true);

            if (!dialog.ok) {
                Core.getMainWindow().showStatusMessageRB("TEAM_CANCELLED");
                return null;
            }

            IMainWindow mainWindow = Core.getMainWindow();
            Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
            Cursor oldCursor = mainWindow.getCursor();
            mainWindow.setCursor(hourglassCursor);
            Core.getMainWindow().showStatusMessageRB("CT_DOWNLOADING_PROJECT");

            // retrieve omegat.project
            projectRoot = new File(dialog.getSaveLocation());
            List<RepositoryDefinition> repos = new ArrayList<RepositoryDefinition>();
            RepositoryDefinition repo = new RepositoryDefinition();
            repos.add(repo);
            repo.setType(dialog.getRepoType());
            repo.setUrl(dialog.getRepoUrl());
            RepositoryMapping mapping = new RepositoryMapping();
            mapping.setLocal("");
            mapping.setRepository("");
            repo.getMapping().add(mapping);

            RemoteRepositoryProvider remoteRepositoryProvider = new RemoteRepositoryProvider(projectRoot,
                    repos);
            remoteRepositoryProvider.switchAllToLatest();
            for (String file : new String[] { OConsts.FILE_PROJECT,
                    OConsts.DEFAULT_INTERNAL + '/' + FilterMaster.FILE_FILTERS,
                    OConsts.DEFAULT_INTERNAL + '/' + SRX.CONF_SENTSEG }) {
                remoteRepositoryProvider.copyFilesFromRepoToProject(file);
            }

            // update repo into
            ProjectProperties props = ProjectFileStorage.loadProjectProperties(projectRoot);
            props.setRepositories(repos);
            ProjectFileStorage.writeProjectFile(props);

            //String projectFileURL = dialog.txtRepositoryOrProjectFileURL.getText();
            //File localDirectory = new File(dialog.txtDirectory.getText());
            //                try {
            //                    localDirectory.mkdirs();
            //                    byte[] projectFile = WikiGet.getURLasByteArray(projectFileURL);
            //                    FileUtils.writeByteArrayToFile(new File(localDirectory, OConsts.FILE_PROJECT), projectFile);
            //                } catch (Exception ex) {
            //                    ex.printStackTrace();
            //                    Core.getMainWindow().displayErrorRB(ex, "TEAM_CHECKOUT_ERROR");
            //                    mainWindow.setCursor(oldCursor);
            //                    return null;
            //                }

            //                projectOpen(localDirectory);

            mainWindow.setCursor(oldCursor);
            return null;
        }

        @Override
        protected void done() {
            Core.getMainWindow().showProgressMessage(" ");
            try {
                get();
                if (projectRoot != null) {
                    // don't ask open if user cancelled previous dialog
                    SwingUtilities.invokeLater(() -> {
                        Core.getEditor().requestFocus();
                        projectOpen(projectRoot);
                    });

                }
            } catch (Exception ex) {
                Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_DOWNLOAD_TEAM_PROJECT");
                Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_DOWNLOAD_TEAM_PROJECT");
            }
        }
    }.execute();
}

From source file:util.ui.UiUtilities.java

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

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

From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorComponent.java

/** 
 * Implemented as specified by the {@link Editor} interface.
 * @see Editor#setRootObject(Object)//from   w w w . j  a v  a  2 s.c  om
 */
public void setRootObject(Object refObject) {
    if (refObject == null)
        throw new IllegalArgumentException("Root object not valid.");
    Object oldObject = model.getRefObject();

    model.setRootObject(refObject);
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    view.setRootObject(oldObject);
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java

/**
 * Creates an instance of <tt>ChatConversationPanel</tt>.
 *
 * @param chatContainer The parent <tt>ChatConversationContainer</tt>.
 *///from  w  w w .j a  v a 2s  .  c o  m
public ChatConversationPanel(ChatConversationContainer chatContainer) {
    editorKit = new ChatConversationEditorKit(this);

    this.chatContainer = chatContainer;

    isHistory = (chatContainer instanceof HistoryWindow);

    this.rightButtonMenu = new ChatRightButtonMenu(this);

    this.document = (HTMLDocument) editorKit.createDefaultDocument();

    this.document.addDocumentListener(editorKit);

    this.chatTextPane.setEditorKitForContentType("text/html", editorKit);
    this.chatTextPane.setEditorKit(editorKit);
    this.chatTextPane.setEditable(false);
    this.chatTextPane.setDocument(document);
    this.chatTextPane.setDragEnabled(true);

    chatTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
    Constants.loadSimpleStyle(document.getStyleSheet(), chatTextPane.getFont());

    this.chatTextPane.addHyperlinkListener(this);
    this.chatTextPane.addMouseListener(this);
    this.chatTextPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));

    this.addChatLinkClickedListener(showPreview);

    this.setWheelScrollingEnabled(true);

    this.setViewportView(chatTextPane);

    this.setBorder(null);

    this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    ToolTipManager.sharedInstance().registerComponent(chatTextPane);

    String copyLinkString = GuiActivator.getResources().getI18NString("service.gui.COPY_LINK");

    copyLinkItem = new JMenuItem(copyLinkString, new ImageIcon(ImageLoader.getImage(ImageLoader.COPY_ICON)));

    copyLinkItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            StringSelection stringSelection = new StringSelection(currentHref);
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            clipboard.setContents(stringSelection, ChatConversationPanel.this);
        }
    });

    String openLinkString = GuiActivator.getResources().getI18NString("service.gui.OPEN_IN_BROWSER");

    openLinkItem = new JMenuItem(openLinkString, new ImageIcon(ImageLoader.getImage(ImageLoader.BROWSER_ICON)));

    openLinkItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GuiActivator.getBrowserLauncher().openURL(currentHref);

            // after opening the link remove the currentHref to avoid
            // clicking on the window to gain focus to open the link again
            ChatConversationPanel.this.currentHref = "";
        }
    });

    openLinkItem.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OPEN_IN_BROWSER"));

    copyLinkItem.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.COPY_LINK"));

    configureReplacementItem = new JMenuItem(
            GuiActivator.getResources().getI18NString("plugin.chatconfig.replacement.CONFIGURE_REPLACEMENT"),
            GuiActivator.getResources().getImage("service.gui.icons.CONFIGURE_ICON"));

    configureReplacementItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final ConfigurationContainer configContainer = GuiActivator.getUIService()
                    .getConfigurationContainer();

            ConfigurationForm chatConfigForm = getChatConfigForm();

            if (chatConfigForm != null) {
                configContainer.setSelected(chatConfigForm);

                configContainer.setVisible(true);
            }
        }
    });

    this.isSimpleTheme = ConfigurationUtils.isChatSimpleThemeEnabled();

    /*
     * When we append a new message (regardless of whether it is a string or
     * an UI component), we want to make it visible in the viewport of this
     * JScrollPane so that the user can see it.
     */
    ComponentListener componentListener = new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            synchronized (scrollToBottomRunnable) {
                if (!scrollToBottomIsPending)
                    return;
                scrollToBottomIsPending = false;

                /*
                 * Yana Stamcheva, pointed out that Java 5 (on Linux only?)
                 * needs invokeLater for JScrollBar.
                 */
                SwingUtilities.invokeLater(scrollToBottomRunnable);
            }
        }
    };

    chatTextPane.addComponentListener(componentListener);
    getViewport().addComponentListener(componentListener);
}

From source file:base.BasePlayer.BedCanvas.java

void drawScreen(Graphics g) {

    if (Main.readingbeds) {
        buf.setColor(Draw.backColor);//  w ww .  ja  v a  2s  .co m
        buf.fillRect(Main.sidebarWidth - 4, 0, this.getWidth(), nodeImage.getHeight());
        buf.drawString("Loading tracks...", 10, Main.bedScroll.getViewport().getHeight());
        g.drawImage(bufImage, 0, 0, null);
        return;
    }
    if (this.trackDivider.size() > 0 && this.trackDivider.get(this.trackDivider.size() - 1) != 1.0) {
        for (int i = 0; i < Main.bedCanvas.trackDivider.size(); i++) {
            Main.bedCanvas.trackDivider.set(i,
                    ((i + 1) * (this.getHeight() / (double) trackDivider.size()) / this.getHeight()));
        }
    }

    drawSidebar();

    if (Settings.wallpaper == null) {
        buf.setColor(Draw.backColor);
        buf.fillRect(Main.sidebarWidth - 4, 0, this.getWidth(), this.getHeight());
    } else {

        buf.drawImage(Settings.wallpaper, Main.sidebarWidth - 4, 0, this);
        buf.setColor(Draw.backColor);
        buf.fillRect(Main.sidebarWidth - 4, 0, this.getWidth(), this.getHeight());
    }
    //buf.setColor(Color.gray);

    if (!zoomDrag && !resize) {

        try {

            drawNodes();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (resizer && !mouseDrag) {
        resizer = false;
    }
    if (resize) {
        buf.drawImage(nodeImage, Main.sidebarWidth - 4, 0, nodeImage.getWidth(),
                (int) (Main.vardivider * Main.varPaneDivider.getY()), null);
    } else {
        buf.drawImage(nodeImage, Main.sidebarWidth - 4, 0, null);
    }
    for (int i = 0; i < bedTrack.size(); i++) {
        if (i < bedTrack.size() - 1) {
            buf.setColor(Color.lightGray);
            buf.drawLine(0, (int) (trackDivider.get(i) * this.getHeight()), this.getWidth(),
                    (int) (trackDivider.get(i) * this.getHeight()));

            buf.setColor(Color.gray);
            buf.drawLine(0, (int) (trackDivider.get(i) * this.getHeight()) + 1, this.getWidth(),
                    (int) (trackDivider.get(i) * this.getHeight()) + 1);

            if (!lineZoomer && mouseY < (int) (trackDivider.get(i) * this.getHeight()) + 4
                    && mouseY > (int) (trackDivider.get(i) * this.getHeight()) - 4) {
                resizer = true;
                if (getCursor().getType() != Cursor.N_RESIZE_CURSOR) {
                    resizeDivider = i;
                    setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
                }
            }
        }
        if (bedTrack.get(i).graph && bedTrack.get(i).minvalue != Double.MAX_VALUE
                && bedTrack.get(i).getHead().getNext() != null) {
            if (!buf.getColor().equals(Color.white)) {
                buf.setColor(Color.white);
            }
            if (bedTrack.get(i).getLogscale().isSelected()) {
                scaletext = "Log scale [" + MethodLibrary.round(bedTrack.get(i).minvalue, 2) + ", "
                        + MethodLibrary.round(bedTrack.get(i).maxvalue, 2) + "]";

                scalewidth = buf.getFontMetrics().stringWidth(scaletext);
                buf.fillRoundRect(Main.sidebarWidth + 5,
                        (int) (trackDivider.get(i) * this.getHeight()) - 5 - (Main.defaultFontSize + 4),
                        scalewidth + 4, Main.defaultFontSize + 4, 4, 4);
                buf.setColor(Color.black);
                buf.drawString(scaletext, Main.sidebarWidth + 7,
                        (int) (trackDivider.get(i) * this.getHeight()) - 9);

            } else {
                scaletext = "Scale [" + MethodLibrary.round(bedTrack.get(i).minvalue, 2) + ", "
                        + MethodLibrary.round(bedTrack.get(i).maxvalue, 2) + "]";
                scalewidth = buf.getFontMetrics().stringWidth(scaletext);
                buf.fillRoundRect(Main.sidebarWidth + 5,
                        (int) (trackDivider.get(i) * this.getHeight()) - 5 - (Main.defaultFontSize + 4),
                        scalewidth + 4, Main.defaultFontSize + 4, 4, 4);
                buf.setColor(Color.black);
                buf.drawString(scaletext, Main.sidebarWidth + 7,
                        (int) (trackDivider.get(i) * this.getHeight()) - 9);
            }
            buf.setColor(Color.black);
        }
    }
    if (overlap) {

        drawInfo();
    }
    if (!resizer && !overlapping) {
        if (getCursor().getType() != Cursor.DEFAULT_CURSOR) {
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        }
    }
    if (Main.drawCanvas.splits.get(0).pixel > 1) {
        // Middle line      
        buf.setColor(Color.black);
        buf.setStroke(Draw.dashed);
        buf.drawLine((Main.drawCanvas.getDrawWidth()) / 2 + Main.sidebarWidth - 2, 0,
                ((Main.drawCanvas.getDrawWidth())) / 2 + Main.sidebarWidth - 2,
                Main.bedScroll.getViewport().getHeight());
        buf.drawLine(
                (int) ((Main.drawCanvas.getDrawWidth()) / 2 + Main.drawCanvas.splits.get(0).pixel
                        + Main.sidebarWidth - 2),
                0, (int) (((Main.drawCanvas.getDrawWidth())) / 2 + Main.drawCanvas.splits.get(0).pixel
                        + Main.sidebarWidth - 2),
                Main.bedScroll.getViewport().getHeight());
        //      buf.setStroke(Draw.doubleStroke);
        buf.setStroke(Draw.basicStroke);
    }
    for (int i = 1; i < Main.drawCanvas.splits.size(); i++) {
        buf.setColor(Color.gray);
        buf.fillRect(Main.drawCanvas.splits.get(i).offset - 3, 0, 5, this.getHeight());
        buf.setColor(Color.lightGray);
        buf.fillRect(Main.drawCanvas.splits.get(i).offset - 1, 0, 2, this.getHeight());

    }
    if (getCursor().getType() != Cursor.N_RESIZE_CURSOR) {

        drawZoom();
    }
    g.drawImage(bufImage, 0, 0, null);
}

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

private void jLabel7MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel7MouseEntered
    this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}

From source file:org.docx4all.ui.menu.FileMenu.java

@Action
public void exportAsSharedDoc(ActionEvent actionEvent) {
    WordMLEditor editor = WordMLEditor.getInstance(WordMLEditor.class);
    JEditorPane view = editor.getCurrentEditor();
    if (view instanceof WordMLTextPane) {
        WordMLTextPane wmlTextPane = (WordMLTextPane) view;
        WordMLDocument doc = (WordMLDocument) wmlTextPane.getDocument();
        if (DocUtil.getChunkingStrategy(doc) == null) {
            displaySetupFirstMessage();//w  ww .  j a va  2s.co  m
            return;
        }

        NewShareDialog d = new NewShareDialog(editor.getWindowFrame());
        d.pack();
        d.setLocationRelativeTo(editor.getWindowFrame());
        d.setVisible(true);
        if (d.getValue() == NewShareDialog.NEXT_BUTTON_TEXT) {
            DocumentElement root = (DocumentElement) doc.getDefaultRootElement();
            DocumentML docML = (DocumentML) root.getElementML();
            WordprocessingMLPackage wmlPackage = docML.getWordprocessingMLPackage();
            XmlUtil.setPlutextCheckinMessageEnabledProperty(wmlPackage, d.isCommentOnEveryChange());

            RETURN_TYPE val = saveAsFile(EXPORT_AS_SHARED_DOC_ACTION_NAME, actionEvent, Constants.DOCX_STRING);

            Cursor origCursor = wmlTextPane.getCursor();
            wmlTextPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            if (val != RETURN_TYPE.APPROVE) {
                //Cancelled or Error
                XmlUtil.removePlutextProperty(wmlPackage,
                        Constants.PLUTEXT_CHECKIN_MESSAGE_ENABLED_PROPERTY_NAME);

            } else if (!DocUtil.isSharedDocument(doc)) {
                //Because user has saved to places other than predefined server.
                XmlUtil.removeSharedDocumentProperties(wmlPackage);
                //TODO: Display a message saying a shared document can only
                //be created in predefined server and ask user to try again.
            } else {

                String filepath = (String) doc.getProperty(WordMLDocument.FILE_PATH_PROPERTY);
                try {
                    FileObject fo = VFSUtils.getFileSystemManager().resolveFile(filepath);
                    doc = wmlTextPane.getWordMLEditorKit().read(fo);

                    doc.putProperty(WordMLDocument.FILE_PATH_PROPERTY, filepath);
                    doc.addDocumentListener(editor.getToolbarStates());
                    doc.setDocumentFilter(new WordMLDocumentFilter());

                    wmlTextPane.setDocument(doc);
                    wmlTextPane.putClientProperty(Constants.LOCAL_VIEWS_SYNCHRONIZED_FLAG, Boolean.TRUE);

                    if (DocUtil.isSharedDocument(doc)) {
                        wmlTextPane.getWordMLEditorKit().initPlutextClient(wmlTextPane);
                    }
                } catch (IOException exc) {
                    exc.printStackTrace();
                    //TODO:Display an IO error message and ask user to close the document
                    //and try to reopen it.
                }

            }

            wmlTextPane.setCursor(origCursor);
        }
        d.dispose();
    }
}