List of usage examples for java.awt Cursor getPredefinedCursor
public static Cursor getPredefinedCursor(int type)
From source file:com.sshtools.sshterm.SshTerminalPanel.java
public void printScreen() { try {//from www . ja v a2 s .c o m PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(terminal, pageFormat); if (job.printDialog()) { setCursor(Cursor.getPredefinedCursor(3)); job.print(); setCursor(Cursor.getPredefinedCursor(0)); } } catch (PrinterException pe) { JOptionPane.showMessageDialog(this, pe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:op.care.reports.PnlReport.java
private JPanel createContentPanel4Day(LocalDate day) { // OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage("misc.msg.wait", progress, progressMax)); // progress++; final String key = DateFormat.getDateInstance().format(day.toDate()); synchronized (contentmap) { if (contentmap.containsKey(key)) { return contentmap.get(key); }/*from w w w . j a va2 s. co m*/ } final JPanel dayPanel = new JPanel(new VerticalLayout()); dayPanel.setOpaque(false); synchronized (valuecache) { if (!valuecache.containsKey(key)) { valuecache.put(key, NReportTools.getNReports4Day(resident, day)); } int i = 0; // for zebra pattern for (final NReport nreport : valuecache.get(key)) { if (tbShowReplaced.isSelected() || !nreport.isObsolete()) { String title = SYSTools.toHTMLForScreen(SYSConst.html_table(SYSConst .html_table_tr("<td width=\"800\" align=\"left\">" + "<b><p>" + (nreport.isObsolete() ? SYSConst.html_16x16_Eraser_internal : "") + (nreport.isReplacement() ? SYSConst.html_16x16_Edited_internal : "") + DateFormat.getTimeInstance(DateFormat.SHORT).format(nreport.getPit()) + " " + SYSTools.xx("misc.msg.Time.short") + ", " + nreport.getMinutes() + " " + SYSTools.xx("misc.msg.Minute(s)") + ", " + nreport.getUser().getFullname() + (nreport.getCommontags().isEmpty() ? "" : " " + CommontagsTools.getAsHTML(nreport.getCommontags(), SYSConst.html_16x16_tagPurple_internal)) + "</p></b></td>") + SYSConst.html_table_tr("<td width=\"800\" align=\"left\">" + SYSTools.replace(nreport.getText(), "\n", "<br/>", false) + "</td>"), "0")); final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title), null); pnlSingle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup(GUITools.getHTMLPopup(pnlSingle.getButton(), NReportTools.getInfoAsHTML(nreport)), SwingConstants.NORTH); } }); if (!nreport.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(nreport.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure fileHandleClosure = OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? null : new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final NReport myReport = em.find(NReport.class, nreport.getID()); em.close(); final String keyNewDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } }; new DlgFiles(nreport, fileHandleClosure); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlSingle.getRight().add(btnFiles); } if (!nreport.getAttachedQProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(nreport.getAttachedQProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(nreport, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NReport myReport = em.merge(nreport); em.lock(myReport, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSNR2PROCESS> attached = new ArrayList<SYSNR2PROCESS>( myReport.getAttachedQProcessConnections()); for (SYSNR2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getNReport().getAttachedQProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess .getElements(); if (!listElements.contains(myReport)) { QProcess myQProcess = em.merge(qProcess); SYSNR2PROCESS myLinkObject = em .merge(new SYSNR2PROCESS(myQProcess, myReport)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedNReportConnections().add(myLinkObject); myReport.getAttachedQProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled( OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlSingle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane() .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(nreport); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!nreport.isObsolete()); pnlSingle.getRight().add(btnMenu); JPanel zebra = new JPanel(); zebra.setLayout(new BoxLayout(zebra, BoxLayout.LINE_AXIS)); zebra.setOpaque(true); if (i % 2 == 0) { zebra.setBackground(SYSConst.orange1[SYSConst.light2]); } else { zebra.setBackground(Color.WHITE); } zebra.add(pnlSingle.getMain()); i++; dayPanel.add(zebra); linemap.put(nreport, pnlSingle.getMain()); } } } synchronized (contentmap) { contentmap.put(key, dayPanel); } return dayPanel; }
From source file:neg.JRViewer.java
void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed {//GEN-HEADEREND:event_btnPrintActionPerformed // Add your handling code here: Thread thread = new Thread(new Runnable() { public void run() { try { btnPrint.setEnabled(false); JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JasperPrintManager.printReport(jasperPrint, true); } catch (Exception ex) { if (log.isErrorEnabled()) log.error("Print error.", ex); JOptionPane.showMessageDialog(JRViewer.this, getBundleString("error.printing")); } finally { JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); btnPrint.setEnabled(true); }/*from ww w . ja v a2 s .co m*/ } }); thread.start(); }
From source file:neg.JRViewerDet1.java
void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed {//GEN-HEADEREND:event_btnPrintActionPerformed // Add your handling code here: Thread thread = new Thread(new Runnable() { public void run() { try { btnPrint.setEnabled(false); JRViewerDet1.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JasperPrintManager.printReport(jasperPrint, true); } catch (Exception ex) { if (log.isErrorEnabled()) log.error("Print error.", ex); JOptionPane.showMessageDialog(JRViewerDet1.this, getBundleString("error.printing")); } finally { JRViewerDet1.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); btnPrint.setEnabled(true); }/*from w w w. ja v a2s . c o m*/ } }); thread.start(); }
From source file:neg.JRViewerDet2.java
void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed {//GEN-HEADEREND:event_btnPrintActionPerformed // Add your handling code here: Thread thread = new Thread(new Runnable() { public void run() { try { btnPrint.setEnabled(false); JRViewerDet2.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JasperPrintManager.printReport(jasperPrint, true); } catch (Exception ex) { if (log.isErrorEnabled()) log.error("Print error.", ex); JOptionPane.showMessageDialog(JRViewerDet2.this, getBundleString("error.printing")); } finally { JRViewerDet2.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); btnPrint.setEnabled(true); }/*w ww .j ava 2s . c o m*/ } }); thread.start(); }
From source file:ded.ui.DiagramController.java
/** Write the diagram in PNG format to 'file' with an optional comment. * The comment must only use ASCII characters. */ public void writeToPNG(File file, String comment) throws Exception { // For a large-ish diagram, this operation takes ~200ms. For now, // I will just acknowledge the delay. An idea for the future is // to add a status bar to the UI, then do the export work in a // separate thread, with an indicator in the status bar that will // reflect when the operation completes. I consider it important // for the user to know when it finishes so if it takes a long // time, they don't in the meantime go copy or view the partially // written image. this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try {/*from ww w . jav a2 s .co m*/ // Based on code from: // http://stackoverflow.com/questions/5655908/export-jpanel-graphics-to-png-or-gif-or-jpg // First, render the image to an in-memory image buffer. BufferedImage bi = new BufferedImage(this.getSize().width, this.getSize().height, BufferedImage.TYPE_INT_ARGB); Graphics g = bi.createGraphics(); this.paintWithoutSelectionsShowing(g); g.dispose(); // Now, write that image to a file in PNG format. String warning = ImageFileUtil.writeImageToPNGFile(bi, file, comment); if (warning != null) { SwingUtil.warningMessageBox(this, "File save completed successfully, but while exporting to PNG, " + "there was a warning: " + warning); } } finally { this.setCursor(Cursor.getDefaultCursor()); } }
From source file:cn.pholance.datamanager.common.components.JRViewer.java
void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed {//GEN-HEADEREND:event_btnPrintActionPerformed // Add your handling code here: Thread thread = new Thread(new Runnable() { public void run() { try { btnPrint.setEnabled(false); JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JasperPrintManager.getInstance(jasperReportsContext).print(jasperPrint, true); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("Print error.", ex); }// ww w . j a v a2s .c o m JOptionPane.showMessageDialog(JRViewer.this, getBundleString("error.printing")); } finally { JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); btnPrint.setEnabled(true); } } }); thread.start(); }
From source file:lejos.pc.charting.LogChartFrame.java
private void populateSampleData() { float value = 0, value2 = 0; int x = 0;/*from www.j a v a 2s. c o m*/ DataItem[] di = { new DataItem(), new DataItem(), new DataItem() }; di[0].datatype = DataItem.DT_INTEGER; di[1].datatype = DataItem.DT_FLOAT; di[2].datatype = DataItem.DT_FLOAT; loggerHook.logFieldNamesChanged(new String[] { "System_ms!n!1", "Sine!Y!1", "Random!y!2" }); for (int i = 0; i < 10000; i++) { if (i % 100 == 0) value2 = (float) (Math.random() * 5000 - 2500); if (i % 10 == 0) { di[0].value = new Integer(x); di[1].value = new Float(Math.sin(value)); di[2].value = new Float(value2); loggerHook.logLineAvailable(di); if (i == 4000) loggerHook.logCommentReceived(x, "Event 1: This is an example of what NXTDataLogger.writeComment() does."); if (i == 6510) loggerHook.logCommentReceived(x, "Event 2: This illustrates that multiple comment markers can be added to the chart."); if (i == 9000) loggerHook.logCommentReceived(x, "Look! Did you notice that the domain value is displayed in the tooltip? "); x += 10; value += .1f; } } setChartTitle("Sample Multiple Range Axis Dataset"); loggerHook.dataInputStreamEOF(); System.out.println("Sample dataset generation complete"); this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); // // emulate a CMD_INIT_HANDLER command from the NXT lejos.util.LogMessageManager // byte[] buf = {0,2,-1,-1,1}; // EndianTools.encodeShortBE(1, buf, 2); // tmm.tunneledMessageReceived(buf); // // // emulate a CMD_DELIVER_PACKET command from the NXT lejos.util.LogMessageManager // buf = new byte[10]; // buf[0]= 3; // CMD_DELIVER_PACKET // buf[1]= 2; // TYPE_ROBOT_DRIVE // EndianTools.encodeShortBE(6, buf, 2); // Packet size = 6: 2 bytes , 1 float // buf[4]= 1; // Handler uniqID // buf[5]= 0; // handler command: Set Forward // EndianTools.encodeIntBE(Float.floatToIntBits(500.6675f), buf, 6); // System.out.println("emulate: intbits=" + Float.floatToIntBits(500f)); // tmm.tunneledMessageReceived(buf); }
From source file:org.rdv.ui.MainPanel.java
public void postState(int newState, int oldState) { if (newState == Player.STATE_DISCONNECTED) { frame.setTitle("RDV"); controlAction.setEnabled(false); disconnectAction.setEnabled(false); saveAction.setEnabled(false);/*w w w.j ava 2 s.c om*/ importAction.setEnabled(false); exportAction.setEnabled(false); controlPanel.setEnabled(false); markerSubmitPanel.setEnabled(false); ActionFactory.getInstance().getOfflineAction().setSelected(false); } else if (oldState == Player.STATE_DISCONNECTED) { frame.setTitle(rbnb.getServerName() + " - RDV"); controlAction.setEnabled(true); disconnectAction.setEnabled(true); LocalServer localServer = LocalServer.getInstance(); boolean offline = rbnb.getRBNBHostName().equals(localServer.getHost()) && rbnb.getRBNBPortNumber() == localServer.getPort(); saveAction.setEnabled(!offline); importAction.setEnabled(offline); exportAction.setEnabled(true); controlPanel.setEnabled(true); markerSubmitPanel.setEnabled(true); } if (newState == Player.STATE_LOADING || newState == Player.STATE_PLAYING || newState == Player.STATE_MONITORING) { startThrobber(); } else if (oldState == Player.STATE_LOADING || oldState == Player.STATE_PLAYING || oldState == Player.STATE_MONITORING) { stopThrobber(); } if (newState == Player.STATE_LOADING) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); loadingDialog = new LoadingDialog(frame); new Thread() { public void run() { synchronized (loadingMonitor) { if (loadingDialog == null) { return; } try { loadingMonitor.wait(1000); } catch (InterruptedException e) { } if (loadingDialog != null) { loadingDialog.setVisible(true); loadingDialog.start(); } } } }.start(); } else if (oldState == Player.STATE_LOADING) { setCursor(null); synchronized (loadingMonitor) { loadingMonitor.notify(); if (loadingDialog != null) { loadingDialog.close(); loadingDialog = null; } } } }
From source file:neg.JRViewerComercialProveedor.java
void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed {//GEN-HEADEREND:event_btnPrintActionPerformed // Add your handling code here: Thread thread = new Thread(new Runnable() { public void run() { try { btnPrint.setEnabled(false); JRViewerComercialProveedor.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JasperPrintManager.printReport(jasperPrint, true); } catch (Exception ex) { if (log.isErrorEnabled()) log.error("Print error.", ex); JOptionPane.showMessageDialog(JRViewerComercialProveedor.this, getBundleString("error.printing")); } finally { JRViewerComercialProveedor.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); btnPrint.setEnabled(true); }//from w w w. ja v a 2 s . co m } }); thread.start(); }