List of usage examples for java.awt Cursor getDefaultCursor
public static Cursor getDefaultCursor()
From source file:biz.wolschon.finance.jgnucash.actions.OpenFilePluginMenuAction.java
@Override public void actionPerformed(final ActionEvent e) { try {/*w w w. ja v a 2s .co m*/ // Activate plug-in that declares extension. myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId()); // Get plug-in class loader. ClassLoader classLoader = myJGnucashEditor.getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()); // Load Tool class. Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString()); // Create Tool instance. Object o = toolCls.newInstance(); if (!(o instanceof DataSourcePlugin)) { LOGGER.error("Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface."); JOptionPane.showMessageDialog(myJGnucashEditor, "Error", "Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.", JOptionPane.ERROR_MESSAGE); return; } DataSourcePlugin importer = (DataSourcePlugin) o; try { myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); //workaround because of a deadlock in log4j-consoleAppender in the JPf-classloader Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").removeAllAppenders(); Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").setLevel(Level.FATAL); GnucashWritableFile loadedFile = importer.loadFile(); if (loadedFile != null) { myJGnucashEditor.setWritableModel(loadedFile); } } catch (Exception e1) { LOGGER.error("Load via Plugin '" + pluginName + "' failed.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Load via Plugin '" + pluginName + "' failed.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } finally { myJGnucashEditor.setCursor(Cursor.getDefaultCursor()); } } catch (Exception e1) { LOGGER.error("Could not activate requested Loader-plugin '" + pluginName + "'.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Could not activate requested Loader-plugin '" + pluginName + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } }
From source file:edu.uchc.octane.OctanePlugin.java
/** * Load dataset from disk// w w w .j av a 2 s . com * @param f File on disk * @return The dataset * @throws IOException * @throws ClassNotFoundException */ TrajDataset readDataset(File f) throws IOException, ClassNotFoundException { TrajDataset dataset; IJ.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); IJ.showStatus("Loading data ..."); dataset = TrajDataset.loadDataset(f); IJ.showStatus(""); IJ.getInstance().setCursor(Cursor.getDefaultCursor()); return dataset; }
From source file:org.languagetool.gui.ResultArea.java
ResultArea(final ResourceBundle messages, final LanguageToolSupport ltSupport, final JTextPane statusPane) { this.messages = messages; this.ltSupport = ltSupport; this.statusPane = statusPane; statusPane.setContentType("text/html"); statusPane.setText(Main.HTML_GREY_FONT_START + messages.getString("resultAreaText") + Main.HTML_FONT_END); statusPane.setEditable(false);/*w w w .j ava 2 s. c om*/ statusPane.addHyperlinkListener(new MyHyperlinkListener()); statusPane.setTransferHandler(new RetainLineBreakTransferHandler()); ltSupport.addLanguageToolListener(new LanguageToolListener() { @Override public void languageToolEventOccurred(LanguageToolEvent event) { if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) { final Language lang = ltSupport.getLanguage(); final String langName; if (lang.isExternal()) { langName = lang.getTranslatedName(messages) + Main.EXTERNAL_LANGUAGE_SUFFIX; } else { langName = lang.getTranslatedName(messages); } final String startCheckText = Main.HTML_GREY_FONT_START + Tools.makeTexti18n(messages, "startChecking", langName) + "..." + Main.HTML_FONT_END; statusPane.setText(startCheckText); setStartText(startCheckText); if (event.getCaller() == marker) { statusPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) { inputText = event.getSource().getTextComponent().getText(); setRuleMatches(event.getSource().getMatches()); if (event.getCaller() == marker || event.getCaller() == null) { displayResult(); if (event.getCaller() == marker) { statusPane.setCursor(Cursor.getDefaultCursor()); } } } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED || event.getType() == LanguageToolEvent.Type.RULE_ENABLED) { inputText = event.getSource().getTextComponent().getText(); setRuleMatches(event.getSource().getMatches()); displayResult(); } } }); }
From source file:biz.wolschon.finance.jgnucash.actions.ToolPluginMenuAction.java
@Override public void actionPerformed(final ActionEvent e) { try {//www .j a va 2 s. c o m GnucashWritableFile wModel = myJGnucashEditor.getWritableModel(); if (wModel == null) { JOptionPane.showMessageDialog(myJGnucashEditor, "No open file.", "Please open a gnucash-file first!", JOptionPane.WARNING_MESSAGE); return; } // Activate plug-in that declares extension. myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId()); // Get plug-in class loader. ClassLoader classLoader = myJGnucashEditor.getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()); // Load Tool class. Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString()); // Create Tool instance. Object o = toolCls.newInstance(); if (!(o instanceof ToolPlugin)) { LOGGER.error("Plugin '" + pluginName + "' does not implement ToolPlugin-interface."); JOptionPane.showMessageDialog(myJGnucashEditor, "Error", "Plugin '" + pluginName + "' does not implement ToolPlugin-interface.", JOptionPane.ERROR_MESSAGE); return; } ToolPlugin importer = (ToolPlugin) o; try { myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); GnucashWritableAccount selectedAccount = (GnucashWritableAccount) myJGnucashEditor .getSelectedAccount(); String message = importer.runTool(wModel, selectedAccount); if (message != null && message.length() > 0) { JOptionPane.showMessageDialog(myJGnucashEditor, "Tool OK", "The tool-use was a success:\n" + message, JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e1) { LOGGER.error("Tool-use via Plugin '" + pluginName + "' failed.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Tool-use via Plugin '" + pluginName + "' failed.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } finally { myJGnucashEditor.setCursor(Cursor.getDefaultCursor()); } } catch (Exception e1) { LOGGER.error("Could not activate requested Tool-plugin '" + pluginName + "'.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Could not activate requested Tool-plugin '" + pluginName + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } }
From source file:org.kalypso.ui.rrm.internal.map.editRelation.EditRelationWidget.java
@Override public void finish() { /* FIXME: should be handled by framework */ final IMapPanel mapPanel = getMapPanel(); if (mapPanel != null) mapPanel.setCursor(Cursor.getDefaultCursor()); }
From source file:biz.wolschon.finance.jgnucash.actions.ImportPluginMenuAction.java
@Override public void actionPerformed(final ActionEvent e) { try {/*from ww w . java 2s . c o m*/ GnucashWritableFile wModel = myJGnucashEditor.getWritableModel(); if (wModel == null) { JOptionPane.showMessageDialog(myJGnucashEditor, "No open file.", "Please open a gnucash-file first!", JOptionPane.WARNING_MESSAGE); return; } // Activate plug-in that declares extension. myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId()); // Get plug-in class loader. ClassLoader classLoader = myJGnucashEditor.getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()); // Load Tool class. Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString()); // Create Tool instance. Object o = toolCls.newInstance(); if (!(o instanceof ImporterPlugin)) { LOGGER.error("Plugin '" + pluginName + "' does not implement ImporterPlugin-interface."); JOptionPane.showMessageDialog(myJGnucashEditor, "Error", "Plugin '" + pluginName + "' does not implement ImporterPlugin-interface.", JOptionPane.ERROR_MESSAGE); return; } ImporterPlugin importer = (ImporterPlugin) o; try { myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); GnucashWritableAccount selectedAccount = (GnucashWritableAccount) myJGnucashEditor .getSelectedAccount(); String message = importer.runImport(wModel, selectedAccount); if (message != null && message.length() > 0) { JOptionPane.showMessageDialog(myJGnucashEditor, "Import OK", "The import was a success:\n" + message, JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e1) { LOGGER.error("Import via Plugin '" + pluginName + "' failed.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Import via Plugin '" + pluginName + "' failed.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } finally { myJGnucashEditor.setCursor(Cursor.getDefaultCursor()); } } catch (Exception e1) { LOGGER.error("Could not activate requested import-plugin '" + pluginName + "'.", e1); JOptionPane .showMessageDialog( myJGnucashEditor, "Error", "Could not activate requested import-plugin '" + pluginName + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(), JOptionPane.ERROR_MESSAGE); } }
From source file:EditorPaneExample6.java
public EditorPaneExample6() { super("JEditorPane Example 6"); pane = new JEditorPane(); pane.setEditable(false); // Start read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/* w ww. j a v a 2 s . c o m*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; textField = new JTextField(32); panel.add(textField, c); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; c.gridwidth = 2; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); // Add a "Save" button saveButton = new JButton("Save"); saveButton.setEnabled(false); c.gridwidth = 1; c.gridx = 2; c.gridy = 0; c.weightx = 0.0; panel.add(saveButton, c); getContentPane().add(panel, "South"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String fileName = textField.getText().trim(); file = new File(fileName); absolutePath = file.getAbsolutePath(); String url = "file:///" + absolutePath; try { // Check if the new page and the old // page are the same. URL newURL = new URL(url); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(newURL)) { return; } // Try to display the page textField.setEnabled(false); // Disable input textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height); saveButton.setEnabled(false); saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); pane.setEditable(false); pane.setPage(url); loadedType.setText(pane.getContentType()); } catch (Exception e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); textField.setEnabled(true); setCursor(Cursor.getDefaultCursor()); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadingState.setText("Page loaded."); textField.setEnabled(true); // Allow entry of new file name textField.requestFocus(); setCursor(Cursor.getDefaultCursor()); // Allow editing and saving if appropriate pane.setEditable(file.canWrite()); saveButton.setEnabled(file.canWrite()); } } }); // Save button saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String type = pane.getContentType(); OutputStream os = new BufferedOutputStream(new FileOutputStream(file + ".save")); pane.setEditable(false); textField.setEnabled(false); saveButton.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Document doc = pane.getDocument(); int length = doc.getLength(); if (type.endsWith("/rtf")) { // Saving RTF - use the OutputStream try { pane.getEditorKit().write(os, doc, 0, length); os.close(); } catch (BadLocationException ex) { } } else { // Not RTF - use a Writer. Writer w = new OutputStreamWriter(os); pane.write(w); w.close(); } } catch (IOException e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to save file", file.getAbsolutePath(), }, "File Save Error", JOptionPane.ERROR_MESSAGE); } pane.setEditable(file.canWrite()); textField.setEnabled(true); saveButton.setEnabled(file.canWrite()); setCursor(Cursor.getDefaultCursor()); } }); }
From source file:org.yccheok.jstock.gui.analysis.WizardDownloadIndicatorJPanel.java
private void jLabel3MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseExited this.setCursor(Cursor.getDefaultCursor()); }
From source file:EditorPaneExample7.java
public EditorPaneExample7() { super("JEditorPane Example 7"); pane = new JEditorPane(); pane.setEditable(false); // Start read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/*from w ww .j a v a 2 s .c o m*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; textField = new JTextField(32); panel.add(textField, c); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; c.gridwidth = 2; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); getContentPane().add(panel, "South"); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); saveButton = new JButton("Save"); plain = new JCheckBox("Plain Text"); html = new JCheckBox("HTML"); rtf = new JCheckBox("RTF"); panel.add(plain); panel.add(html); panel.add(rtf); ButtonGroup group = new ButtonGroup(); group.add(plain); group.add(html); group.add(rtf); plain.setSelected(true); panel.add(Box.createVerticalStrut(10)); panel.add(saveButton); panel.add(Box.createVerticalGlue()); panel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); getContentPane().add(panel, "East"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String fileName = textField.getText().trim(); file = new File(fileName); absolutePath = file.getAbsolutePath(); String url = "file:///" + absolutePath; try { // Check if the new page and the old // page are the same. URL newURL = new URL(url); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(newURL)) { return; } // Try to display the page textField.setEnabled(false); // Disable input textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height); saveButton.setEnabled(false); saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); pane.setEditable(false); pane.setPage(url); loadedType.setText(pane.getContentType()); } catch (Exception e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); textField.setEnabled(true); setCursor(Cursor.getDefaultCursor()); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadingState.setText("Page loaded."); textField.setEnabled(true); // Allow entry of new file name textField.requestFocus(); setCursor(Cursor.getDefaultCursor()); // Allow editing and saving if appropriate pane.setEditable(file.canWrite()); saveButton.setEnabled(file.canWrite()); } } }); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Writer w = null; OutputStream os = System.out; String contentType; if (plain.isSelected()) { contentType = "text/plain"; w = new OutputStreamWriter(os); } else if (html.isSelected()) { contentType = "text/html"; w = new OutputStreamWriter(os); } else { contentType = "text/rtf"; } EditorKit kit = pane.getEditorKitForContentType(contentType); try { if (w != null) { kit.write(w, pane.getDocument(), 0, pane.getDocument().getLength()); w.flush(); } else { kit.write(os, pane.getDocument(), 0, pane.getDocument().getLength()); os.flush(); } } catch (Exception e) { System.out.println("Write failed"); } } }); }
From source file:org.earthtime.UPb_Redux.dateInterpretation.WeightedMeanGraphPanel.java
/** * Creates a new instance of WeightedMeanGraphPanel * * @param sample/* www . j a v a 2 s . c o m*/ */ public WeightedMeanGraphPanel(Sample sample) { super(); this.sample = sample; setOpaque(true); setBackground(Color.white); graphWidth = 775; graphHeight = 600; selectedSampleDateModels = new Object[0][0]; weightedMeanCursor = Cursor.getDefaultCursor(); imageMode = "PAN"; // setInRandomMode( false ); weightedMeanOptions = new SampleDateInterpretationGUIOptions().getWeightedMeanOptions(); addMouseListener(this); addMouseMotionListener(this); }