List of usage examples for java.awt Cursor Cursor
protected Cursor(String name)
Note: this constructor should only be used by AWT implementations as part of their support for custom cursors.
From source file:com.josescalia.tumblr.form.TumblrImageViewer.java
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed frame = (MainFrame) this.getTopLevelAncestor(); form = this;//from ww w. j a va 2 s . com //busy cursor and progress bar in frame and panel form.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.startProgressBar("Processing"); new SwingWorker<JDialog, JDialog>() { @Override protected JDialog doInBackground() throws Exception { return new TumblrFavLinkListDialog(null, true); } @Override protected void done() { TumblrFavLinkListDialog dlg = null; String urlToFetch = ""; try { dlg = (TumblrFavLinkListDialog) get(); dlg.showDialog(); } catch (InterruptedException e) { logger.error(e); } catch (ExecutionException e) { logger.error(e); } if (dlg != null) { form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.stopProgressBar(""); urlToFetch = dlg.getFieldText(); } if (!urlToFetch.equals("")) { setUrl(urlToFetch); } } }.execute(); }
From source file:savant.view.swing.GraphPane.java
/** * {@inheritDoc}/*from w w w. ja v a 2 s . co m*/ */ @Override public void mouseDragged(MouseEvent event) { setMouseModifier(event); GraphPaneController gpc = GraphPaneController.getInstance(); int x2 = getConstrainedX(event); isDragging = true; if (gpc.isPanning()) { setCursor(new Cursor(Cursor.HAND_CURSOR)); } else if (gpc.isZooming() || gpc.isSelecting()) { setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); } // Check if scrollbar is present (only vertical pan if present) JScrollBar scroller = getVerticalScrollBar(); boolean scroll = scroller.isVisible(); if (scroll) { //get new points Point l = event.getLocationOnScreen(); int currX = l.x; int currY = l.y; //magnitude int magX = Math.abs(currX - startX); int magY = Math.abs(currY - startY); if (magX >= magY) { //pan horizontally, reset vertical pan panVert = false; gpc.setMouseReleasePosition(transformXPixel(x2)); scroller.setValue(initialScroll); } else { //pan vertically, reset horizontal pan panVert = true; gpc.setMouseReleasePosition(baseX); scroller.setValue(initialScroll - (currY - startY)); } } else { //pan horizontally panVert = false; gpc.setMouseReleasePosition(transformXPixel(x2)); } }
From source file:com.josescalia.tumblr.form.TumblrImageViewer.java
private void btnFetchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFetchActionPerformed frame = (MainFrame) this.getTopLevelAncestor(); form = this;/*from w w w.j a v a2s.c o m*/ validateUrl(); //busy cursor and progress bar form.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.startProgressBar("Fetching"); new SwingWorker<RssHeader, RssHeader>() { @Override protected RssHeader doInBackground() throws Exception { return service.getRssHeader(url + "/rss"); } protected void done() { try { setRssHeader(get()); } catch (InterruptedException e) { logger.error(e); } catch (ExecutionException e) { logger.error(e); } form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.stopProgressBar(""); } }.execute(); }
From source file:userinterface.properties.GUIGraphHandler.java
public void plotNewFunction() { JDialog dialog;//from w w w . ja v a 2 s .co m JRadioButton radio2d, radio3d, newGraph, existingGraph; JTextField functionField, seriesName; JButton ok, cancel; JComboBox<String> chartOptions; JLabel example; //init all the fields of the dialog dialog = new JDialog(GUIPrism.getGUI()); radio2d = new JRadioButton("2D"); radio3d = new JRadioButton("3D"); newGraph = new JRadioButton("New Graph"); existingGraph = new JRadioButton("Exisiting"); chartOptions = new JComboBox<String>(); functionField = new JTextField(); ok = new JButton("Plot"); cancel = new JButton("Cancel"); seriesName = new JTextField(); example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); example.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { example.setCursor(new Cursor(Cursor.HAND_CURSOR)); example.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); example.setForeground(Color.BLACK); } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (radio2d.isSelected()) { functionField.setText("x/2 + 5"); } else { functionField.setText("x+y+5"); } functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setForeground(Color.BLACK); } } }); //set dialog properties dialog.setSize(400, 350); dialog.setTitle("Plot a new function"); dialog.setModal(true); dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); dialog.setLocationRelativeTo(GUIPrism.getGUI()); //add every component to their dedicated panels JPanel graphTypePanel = new JPanel(new FlowLayout()); graphTypePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type")); graphTypePanel.add(radio2d); graphTypePanel.add(radio3d); JPanel functionFieldPanel = new JPanel(new BorderLayout()); functionFieldPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function")); functionFieldPanel.add(functionField, BorderLayout.CENTER); functionFieldPanel.add(example, BorderLayout.SOUTH); JPanel chartSelectPanel = new JPanel(); chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS)); chartSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to")); JPanel radioPlotPanel = new JPanel(new FlowLayout()); radioPlotPanel.add(newGraph); radioPlotPanel.add(existingGraph); JPanel chartOptionsPanel = new JPanel(new FlowLayout()); chartOptionsPanel.add(chartOptions); chartSelectPanel.add(radioPlotPanel); chartSelectPanel.add(chartOptionsPanel); JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomControlPanel.add(ok); bottomControlPanel.add(cancel); JPanel seriesNamePanel = new JPanel(new BorderLayout()); seriesNamePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); seriesNamePanel.add(seriesName, BorderLayout.CENTER); // add all the panels to the dialog dialog.add(graphTypePanel); dialog.add(functionFieldPanel); dialog.add(chartSelectPanel); dialog.add(seriesNamePanel); dialog.add(bottomControlPanel); // do all the enables and set properties radio2d.setSelected(true); newGraph.setSelected(true); chartOptions.setEnabled(false); functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); seriesName.setText("New function"); ok.setMnemonic('P'); cancel.setMnemonic('C'); example.setToolTipText("click to try out"); ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); cancel.getActionMap().put("cancel", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); boolean found = false; for (int i = 0; i < theTabs.getTabCount(); i++) { if (theTabs.getComponentAt(i) instanceof Graph) { chartOptions.addItem(getGraphName(i)); found = true; } } if (!found) { existingGraph.setEnabled(false); chartOptions.setEnabled(false); } //add all the action listeners radio2d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio2d.isSelected()) { radio3d.setSelected(false); if (chartOptions.getItemCount() > 0) { existingGraph.setEnabled(true); chartOptions.setEnabled(true); } example.setText( "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); } } }); radio3d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio3d.isSelected()) { radio2d.setSelected(false); newGraph.setSelected(true); existingGraph.setEnabled(false); chartOptions.setEnabled(false); example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>"); } } }); newGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGraph.isSelected()) { existingGraph.setSelected(false); chartOptions.setEnabled(false); } } }); existingGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existingGraph.isSelected()) { newGraph.setSelected(false); chartOptions.setEnabled(true); } } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String function = functionField.getText(); Expression expr = null; try { expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function); expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.typeCheck(); expr.semanticCheck(); } catch (PrismLangException e1) { // for copying style JLabel label = new JLabel(); // html content in our case the error we want to show JEditorPane ep = new JEditorPane("text/html", "<html> There was an error parsing the function. To read about what built-in" + " functions are supported <br>and some more information on the functions, visit " + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>." + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } } }); ep.setEditable(false); ep.setBackground(label.getBackground()); // show the error dialog JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE); return; } if (radio2d.isSelected()) { ParametricGraph graph = null; if (newGraph.isSelected()) { graph = new ParametricGraph(""); } else { for (int i = 0; i < theTabs.getComponentCount(); i++) { if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) { graph = (ParametricGraph) theTabs.getComponent(i); } } } dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true); } else if (radio3d.isSelected()) { try { expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.semanticCheck(); expr.typeCheck(); } catch (PrismLangException e1) { e1.printStackTrace(); } if (expr.getAllConstants().size() < 2) { JOptionPane.showMessageDialog(dialog, "There are not enough variables in the function to plot a 3D chart!", "Error", JOptionPane.ERROR_MESSAGE); return; } // its always a new graph ParametricGraph3D graph = new ParametricGraph3D(expr); dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false); } dialog.dispose(); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // we will show info about the function when field is out of focus functionField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!functionField.getText().equals("")) { return; } functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); } @Override public void focusGained(FocusEvent e) { if (!functionField.getText().equals("Add function expression here....")) { return; } functionField.setForeground(Color.BLACK); functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setText(""); } }); // show the dialog dialog.setVisible(true); }
From source file:com.vgi.mafscaling.ClosedLoop.java
public void saveData() { if (JFileChooser.APPROVE_OPTION != fileChooser.showSaveDialog(this)) return;/*w w w.j a va 2s.co m*/ File file = fileChooser.getSelectedFile(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); int i, j; FileWriter out = null; try { out = new FileWriter(file); // write string identifier out.write(SaveDataFileHeader + "\n"); // write maf data for (i = 0; i < mafTable.getRowCount(); ++i) { for (j = 0; j < mafTable.getColumnCount(); ++j) out.write(mafTable.getValueAt(i, j).toString() + ","); out.write("\n"); } // write log data for (i = 0; i < logDataTable.getRowCount(); ++i) { for (j = 0; j < logDataTable.getColumnCount(); ++j) out.write(logDataTable.getValueAt(i, j).toString() + ","); out.write("\n"); } } catch (Exception e) { e.printStackTrace(); logger.error(e); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (out != null) { try { out.close(); } catch (IOException e) { logger.error(e); } } } }
From source file:us.paulevans.basicxslt.BasicXSLTFrame.java
/** * Method to handle button clicks.//from w w w.j a v a 2 s .co m * @param evt */ public void actionPerformed(ActionEvent evt) { String actionCommand, action, allConfigurations[]; Object eventSource; XSLRow xslRow; eventSource = evt.getSource(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); try { if (eventSource == transformBtn) { if (areAnyStylesheets()) { doTransform(); } else { Utils.showDialog(this, stringFactory .getString(LabelStringFactory.MAIN_FRAME_SPECIFICY_AT_LEAST_ONE_STYLESHEET), stringFactory.getString(LabelStringFactory.MAIN_FRAME_TRANSFORM_MESSAGE), JOptionPane.ERROR_MESSAGE); } } else if (eventSource == about) { about(); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == exit) { destroy(); } else if (eventSource == transformTimings) { new TimingsFrame(this, Utils.toArray(xslRows)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == validateAutosaveBtn) { doValidateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XML_FILE), autosavePathTf, false); } else if (eventSource == exitBtn) { destroy(); } else if (eventSource == resetForm) { resetForm(); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == browseAutosavePathBtn) { populateTFFromFileDialog(autosavePathTf); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == browseXmlBtn) { populateTFFromFileDialog(sourceXmlTf); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == autosaveCb) { autosavePathTf.setEnabled(autosaveCb.isSelected()); browseAutosavePathBtn.setEnabled(autosaveCb.isSelected()); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == suppressOutputWindowCb) { outputAsTextIfXmlLabel.setEnabled(!suppressOutputWindowCb.isSelected()); outputAsTextIfXml.setEnabled(!suppressOutputWindowCb.isSelected()); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == removeCheckedBtn) { transformTimings.setEnabled(false); XSLRow.removeChecked(xslRows); if (xslRows.size() == 0) { addXSLRow(); refreshXSLPanel(); } enableRemoveCheckedBtn(); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == addXslBtn) { transformTimings.setEnabled(false); addXSLRow(); refreshXSLPanel(); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == saveConfiguration) { persistUserPrefs(); userPrefs.persistUserPrefs(); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == saveAsConfiguration) { new SaveAsConfigurationFrame(this, userPrefs.getConfiguration()); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (eventSource == loadConfiguration) { allConfigurations = userPrefs.getAllConfigurations(); if (allConfigurations.length > 0) { new LoadConfigurationFrame(this, userPrefs.getConfiguration(), allConfigurations); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); Utils.showDialog(this, MessageFormat.format( stringFactory.getString(LabelStringFactory.MAIN_FRAME_ONLY_CONFIGURATION), userPrefs.getConfiguration(), saveAsConfiguration.getText()), stringFactory.getString(LabelStringFactory.MAIN_FRAME_MESSAGE), JOptionPane.INFORMATION_MESSAGE); } } else if (eventSource == xmlAction) { if (xmlAction.getItemCount() > 0) { action = (String) xmlAction.getSelectedItem(); xmlAction.setSelectedIndex(0); if (action.equals(XML_ACTIONS[XML_VALIDATE_ACTION_INDEX])) { components.clear(); components.add(sourceXmlTf); components.add(xmlAction); components.add(browseXmlBtn); doValidateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XML_FILE), sourceXmlTf, false); } else if (action.equals(XML_ACTIONS[XML_VIEW_EDIT_OUTPUT_PROPS_INDEX])) { new TransformOutputPropertiesFrame(this, xmlIdentityTransformOutputProps, sourceXmlTf.getText()); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (action.equals(XML_ACTIONS[XML_CLEAR_OUTPUT_PROPS_INDEX])) { xmlIdentityTransformOutputProps.clear(); setAreOutputPropertiesSet(false); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (action.equals(XML_ACTIONS[XML_DO_IDENTITY_TRANSFORM_ACTION_INDEX])) { if (validateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XML_FILE), sourceXmlTf, true)) { components.clear(); components.add(sourceXmlTf); components.add(browseXmlBtn); components.add(xmlAction); doIdentityTransform( stringFactory .getString(LabelStringFactory.MAIN_FRAME_SELECT_FILE_FOR_IT_RESULT), sourceXmlTf.getText(), sourceXmlTf.getText()); } else { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } } else { actionCommand = evt.getActionCommand(); if (AppConstants.INSERT.equals(actionCommand)) { xslRow = XSLRow.getRowByInsertBtn(xslRows, (JButton) eventSource); insertXSLRow(xslRow.getIndex()); refreshXSLPanel(); } else if (AppConstants.REMOVE_CB.equals(actionCommand)) { enableRemoveCheckedBtn(); } else if (stringFactory.getString(LabelStringFactory.MAIN_FRAME_BROWSE_BTN) .equals(actionCommand)) { xslRow = XSLRow.getRowByBrowseBtn(xslRows, (JButton) eventSource); populateTFFromFileDialog(xslRow.getTextField()); } else if (AppConstants.TAKE_ACTION.equals(actionCommand)) { xslRow = XSLRow.getRowByAction(xslRows, (JComboBox) eventSource); if (xslRow.getAction().getItemCount() > 0) { action = (String) xslRow.getAction().getSelectedItem(); xslRow.setSelectedActionIndex(0); if (action.equals(XSLRow.ACTIONS[XSLRow.VALIDATE_INDEX])) { components.clear(); components.add(xslRow.getTextField()); components.add(xslRow.getAction()); components.add(xslRow.getRemoveCb()); components.add(xslRow.getInsertBtn()); components.add(xslRow.getBrowseBtn()); doValidateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XSL_PREFIX) + (xslRow.getIndex() + 1), xslRow.getTextField(), false); } else if (action.startsWith(XSLRow.ON_OFF_ITEM_PREFIX)) { xslRow.toggleOnOffBtn(); } else if (action.equals(XSLRow.ACTIONS[XSLRow.VIEW_EDIT_OUTPUT_PROPS_INDEX])) { new TransformOutputPropertiesFrame(this, xslRow); } else if (action.equals(XSLRow.ACTIONS[XSLRow.CLEAR_OUTPUT_PROPS_INDEX])) { xslRow.setAreOutputPropertiesSet(false); xslRow.clearOutputProperties(); } else if (action.equals(XSLRow.ACTIONS[XSLRow.CLEAR_ALL_PARAMETERS_INDEX])) { xslRow.clearAllParameters(); } else if (action.equals(XSLRow.ACTIONS[XSLRow.VIEW_EDIT_PARAMETERS_INDEX])) { new TransformParametersFrame(this, xslRow); } else if (action.equals(XSLRow.ACTIONS[XSLRow.PERFORM_IDENTITY_TRANSFORM_INDEX])) { if (validateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XSL_PREFIX) + (xslRow.getIndex() + 1), xslRow.getTextField(), true)) { components.clear(); components.add(xslRow.getBrowseBtn()); components.add(xslRow.getRemoveCb()); components.add(xslRow.getInsertBtn()); components.add(xslRow.getTextField()); doIdentityTransform( stringFactory.getString(LabelStringFactory.MAIN_FRAME_PICK_FILE_FOR_IT), xslRow.getTextField().getText(), xslRow.getTextField().getText()); } else { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } catch (Throwable aAny) { // log and show dialog... logger.error(ExceptionUtils.getFullStackTrace(aAny)); Utils.showErrorDialog(this, aAny); } }
From source file:com.vgi.mafscaling.ClosedLoop.java
public void loadData() { fileChooser.setMultiSelectionEnabled(false); if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this)) return;// w w w . j av a 2s . c o m File file = fileChooser.getSelectedFile(); int i, j; setCursor(new Cursor(Cursor.WAIT_CURSOR)); BufferedReader br = null; try { br = new BufferedReader(new FileReader(file.getAbsoluteFile())); String line = br.readLine(); if (line == null || !line.equals(SaveDataFileHeader)) { JOptionPane.showMessageDialog(null, "Invalid saved data file!", "Error", JOptionPane.ERROR_MESSAGE); return; } line = br.readLine(); String[] elements; i = 0; int offset = 0; boolean isLogData = false; while (line != null) { elements = line.split(",", -1); switch (i) { case 0: Utils.ensureColumnCount(elements.length - 1, mafTable); for (j = 0; j < elements.length - 1; ++j) mafTable.setValueAt(elements[j], i, j); break; case 1: Utils.ensureColumnCount(elements.length - 1, mafTable); for (j = 0; j < elements.length - 1; ++j) mafTable.setValueAt(elements[j], i, j); break; default: if (elements.length - 1 == logDataTable.getColumnCount()) { if (!isLogData) { offset = i; isLogData = true; } Utils.ensureRowCount(i - offset + 1, logDataTable); for (j = 0; j < elements.length - 1; ++j) logDataTable.setValueAt(elements[j], i - offset, j); } } i += 1; line = br.readLine(); } } catch (Exception e) { e.printStackTrace(); logger.error(e); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (br != null) { try { br.close(); } catch (IOException e) { logger.error(e); } } } }
From source file:com.josescalia.tumblr.form.TumblrImageViewer.java
private void setDisplay(List<DownloadableImage> downloadableImageList) { frame = (MainFrame) this.getTopLevelAncestor(); form = this;// w w w. j a v a 2 s . c o m final List<DownloadableImage> downloadableImages = downloadableImageList; form.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); frame.startProgressBar("Viewing"); if (downloadableImages != null && downloadableImages.size() > 0) { new SwingWorker<String, String>() { @Override protected String doInBackground() throws Exception { String sReturn = ""; for (DownloadableImage image : downloadableImages) { String fileName = image.getUrl().substring(image.getUrl().lastIndexOf("/") + 1); String downloadUrl = image.getUrl(); if (sReturn.length() > 0) { sReturn += "<br>"; } sReturn += "<img src='file:///" + BinaryCacheUtil.getBinaryImagePath(".cache", fileName, downloadUrl) + "'>"; } return sReturn; } @Override protected void done() { try { setImageDisplay(get()); } catch (InterruptedException e) { logger.error(e); } catch (ExecutionException e) { logger.error(e); } form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); frame.stopProgressBar(""); } }.execute(); } }
From source file:com.vgi.mafscaling.LogView.java
private void addXYSeries(TableModel model, int column, String name, Color color) { setCursor(new Cursor(Cursor.WAIT_CURSOR)); try {// w w w.j a v a 2 s. c o m XYSeries series; if (column == rpmCol) { series = rpmDataset.getSeries(0); ((NumberAxis) plot.getRangeAxis(0)).setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getRangeAxis(0).setTickLabelsVisible(true); rpmPlotRenderer.setSeriesPaint(0, color); rpmPlotRenderer.setSeriesVisible(0, true); } else { series = dataset.getSeries(column); plot.getRangeAxis(1).setTickLabelsVisible(true); plotRenderer.setSeriesPaint(column, color); plotRenderer.setSeriesVisible(column, true); displCount += 1; } if (xyMarker.count() > 0) xyMarker.addLabel(series.getDescription() + ": " + series.getY((int) xyMarker.getValue()), color, true); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } chartPanel.revalidate(); }
From source file:edu.harvard.i2b2.previousquery.ui.QueryPreviousRunsPanel.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Rename ...")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null, ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1)); if (inputValue != null) { String newQueryName = (String) inputValue; String requestXml = ndata.writeRenameQueryXML(newQueryName); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); }// w ww .ja va 2s.com if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { ndata.name(newQueryName + " [" + ndata.userId() + "]"); node.setUserObject(ndata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?", "Delete Query Dialog", JOptionPane.YES_NO_OPTION); if (selectedValue.equals(JOptionPane.YES_OPTION)) { System.out.println("delete " + ndata.name()); String requestXml = ndata.writeDeleteQueryXML(); // System.out.println(requestXml); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { treeModel.removeNodeFromParent(node); // jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) { String status = loadPreviousQueries(false); if (status.equalsIgnoreCase("")) { reset(200, false); } else if (status.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } } }