private void disableUnderline() { setCursor(Cursor.getDefaultCursor()); myUnderline = false; setIcon(myInactiveIcon); setStatusBarText(null); setActive(false); }
@Override public void deactivate(DrawingEditor editor) { super.deactivate(editor); getView().setCursor(Cursor.getDefaultCursor()); getView().setActiveHandle(null); clearHoverHandles(); dragLocation = null; }
public void mouseMoved(MouseEvent e) { JTable table = (JTable) e.getSource(); Object tag = getTagAt(e); if (tag == myTag) { table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { table.setCursor(Cursor.getDefaultCursor()); } }
@Override @SuppressWarnings("unchecked") public void installUI(JComponent c) { super.installUI(c); JXLayer<JComponent> l = (JXLayer<JComponent>) c; l.getGlassPane().setLayout(new GridBagLayout()); l.getGlassPane().add(unlockButton); unlockButton.setCursor(Cursor.getDefaultCursor()); }
/** * Handles mouse moved events. * * @param e the mouse event */ public void mouseMoved(MouseEvent e) { TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) return; if (e.getX() > tree.getPathBounds(path).x + hotspot - 3 || e.getX() < tree.getPathBounds(path).x + 2) tree.setCursor(Cursor.getDefaultCursor()); else { tree.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } }
private void onOK() { if (nameTextField.getText().length() < 3 || nameTextField.getText().length() > 24 || !nameTextField.getText().matches("[a-z0-9]+")) { JOptionPane.showMessageDialog( this, "Invalid storage account name. The name should be between 3 and 24 characters long and \n" + "can contain only lowercase letters and numbers.", "Error creating the storage account", JOptionPane.ERROR_MESSAGE); return; } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); createProgressBar.setVisible(true); try { String name = nameTextField.getText(); String region = (regionOrAffinityGroupComboBox.getSelectedItem() instanceof Location) ? regionOrAffinityGroupComboBox.getSelectedItem().toString() : ""; String affinityGroup = (regionOrAffinityGroupComboBox.getSelectedItem() instanceof AffinityGroup) ? regionOrAffinityGroupComboBox.getSelectedItem().toString() : ""; String replication = replicationComboBox.getSelectedItem().toString(); storageAccount = new StorageAccount( name, replication, region, affinityGroup, "", subscription.getId().toString()); AzureSDKManagerImpl.getManager().createStorageAccount(storageAccount); AzureSDKManagerImpl.getManager().refreshStorageAccountInformation(storageAccount); onCreate.run(); } catch (AzureCmdException e) { storageAccount = null; UIHelper.showException( "An error occurred while trying to create the specified storage account.", e, "Error Creating Storage Account", false, true); } setCursor(Cursor.getDefaultCursor()); this.setVisible(false); dispose(); }
/** * Invoked when an action occurs. * * @param e ActionEvent * @todo Implement this java.awt.event.ActionListener method */ public void actionPerformed(ActionEvent e) { try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (e.getSource() == addButton) { processAddEvent(); } else if (e.getSource() == editButton) { processEditEvent(); } else if (e.getSource() == delButton) { processDeleteEvent(); } processTaskTable(); } finally { setCursor(Cursor.getDefaultCursor()); } }
public static void setDefaultCursor(JComponent content) { final Window wnd = SwingUtilities.getWindowAncestor(content); if (wnd != null) { wnd.setCursor(Cursor.getDefaultCursor()); } }
@Override public void mouseExited(MouseEvent e) { setCursor(Cursor.getDefaultCursor()); }
@Override public void paint(Graphics g) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); super.paint(g); setCursor(Cursor.getDefaultCursor()); }
public WebColorChooserField(final Color color) { super(); // Pipette color picker updatePipette(); // Trailing color choose button colorButton = new WebButton(ImageUtils.createColorChooserIcon(color)); colorButton.setFocusable(false); colorButton.setShadeWidth(0); colorButton.setMoveIconOnPress(false); colorButton.setRolloverDecoratedOnly(true); colorButton.setCursor(Cursor.getDefaultCursor()); colorButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { showColorChooserPopup(); } }); setTrailingComponent(colorButton); // Actions addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { updateColorFromField(); } }); addMouseListener( new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (isEnabled() && SwingUtilities.isRightMouseButton(e)) { showColorChooserPopup(); } } }); addFocusListener( new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { updateColorFromField(); } }); addKeyListener( new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { if (isEnabled()) { if (Hotkey.ESCAPE.isTriggered(e)) { updateViewFromColor(); } else if (Hotkey.DOWN.isTriggered(e)) { showColorChooserPopup(); } } } }); // Initial data setFieldType(ColorChooserFieldType.rgb); setColor(color); // Initial styling settings updateMargin(); setHorizontalAlignment(CENTER); }
private void installPipette() { if (pipettePicker == null) { // Pipette picker icon pipettePicker = new WebImage(pipetteIcon); // pipettePicker.setMargin ( 0, 2, 0, 2 ); // Pipette picker actions try { robot = new Robot(); } catch (final AWTException e) { e.printStackTrace(); } if (robot != null) { final MouseAdapter mouseAdapter = new MouseAdapter() { private boolean shouldUpdateColor; private WebDialog window; private WebPanel screen; private WebLabel info; private boolean updating = false; private BufferedImage screenshot; private Color color; @Override public void mousePressed(final MouseEvent e) { if (pipetteEnabled && SwingUtils.isLeftMouseButton(e)) { // Resetting color update mark shouldUpdateColor = true; // Creating preview window createPreviewWindow(); updateWindowLocation(); // Displaying preview window window.pack(); window.setVisible(true); // Transferring focus to preview panel screen.requestFocus(); // Updating preview screenshot updateScreenshot(); } } @Override public void mouseDragged(final MouseEvent e) { if (pipetteEnabled && SwingUtils.isLeftMouseButton(e) && window != null) { // Updating preview window location updateWindowLocation(); // Updating preview screenshot updateScreenshot(); } } @Override public void mouseReleased(final MouseEvent e) { if (pipetteEnabled && SwingUtils.isLeftMouseButton(e) && window != null) { // Closing preview window window.dispose(); } } private void updateScreenshot() { // Simply ignore update if an old one is still running if (!updating) { // Updating image in a separate thread to avoid UI freezing updating = true; new Thread( new Runnable() { @Override public void run() { if (screen != null) { final Point p = MouseInfo.getPointerInfo().getLocation(); screenshot = robot.createScreenCapture( new Rectangle( p.x - pipettePixels / 2, p.y - pipettePixels / 2, pipettePixels, pipettePixels)); color = new Color( screenshot.getRGB(pipettePixels / 2, pipettePixels / 2)); if (screen != null) { screen.repaint(); info.setText(getColorText(color)); } else { screenshot.flush(); screenshot = null; color = null; } } updating = false; } }) .start(); } } private void createPreviewWindow() { window = new WebDialog(pipettePicker); window.setLayout(new BorderLayout()); window.setUndecorated(true); window.setAlwaysOnTop(true); window.addWindowListener( new WindowAdapter() { @Override public void windowClosed(final WindowEvent e) { if (screenshot != null) { if (shouldUpdateColor) { setColor(color); } screenshot.flush(); screenshot = null; } HotkeyManager.unregisterHotkeys(screen); window = null; screen = null; } }); final AbstractPainter<WebPanel> screenPainter = new AbstractPainter<WebPanel>() { /** {@inheritDoc} */ @Override public void paint( final Graphics2D g2d, final Rectangle bounds, final WebPanel c) { if (window.isShowing() && robot != null) { // Screen g2d.drawImage( screenshot, bounds.x + 2, bounds.y + 2, bounds.width - 4, bounds.height - 4, null); // Border g2d.setPaint(Color.BLACK); g2d.drawRect(0, 0, bounds.width - 1, bounds.height - 1); g2d.setPaint(Color.WHITE); g2d.drawRect(1, 1, bounds.width - 3, bounds.height - 3); // Cursor final int mx = bounds.x + bounds.width / 2; final int my = bounds.y + bounds.height / 2; g2d.setPaint(Color.WHITE); g2d.drawLine(mx - 1, my - 7, mx - 1, my + 7); g2d.drawLine(mx + 1, my - 7, mx + 1, my + 7); g2d.drawLine(mx - 7, my - 1, mx + 7, my - 1); g2d.drawLine(mx - 7, my + 1, mx + 7, my + 1); g2d.setPaint(Color.BLACK); g2d.drawLine(mx, my - 7, mx, my + 7); g2d.drawLine(mx - 7, my, mx + 7, my); } } }; screen = new WebPanel(screenPainter); screen.setFocusable(true); screen.setPreferredSize( new Dimension(pipettePixels * pixelSize + 4, pipettePixels * pixelSize + 4)); window.add(screen, BorderLayout.CENTER); info = new WebLabel(WebLabel.LEADING); info.setMargin(4); info.setIcon( new Icon() { @Override public void paintIcon( final Component c, final Graphics g, final int x, final int y) { if (color != null) { final Graphics2D g2d = (Graphics2D) g; g2d.setPaint(Color.BLACK); g2d.drawRect(x, y, 15, 15); g2d.setPaint(Color.WHITE); g2d.drawRect(x + 1, y + 1, 13, 13); g2d.setPaint(color); g2d.fillRect(x + 2, y + 2, 12, 12); } } @Override public int getIconWidth() { return 16; } @Override public int getIconHeight() { return 16; } }); info.setPainter( new AbstractPainter<WebLabel>() { /** {@inheritDoc} */ @Override public Insets getMargin(final WebLabel c) { return new Insets(0, 2, 2, 2); } /** {@inheritDoc} */ @Override public void paint( final Graphics2D g2d, final Rectangle bounds, final WebLabel c) { g2d.setPaint(Color.BLACK); g2d.drawRect(bounds.x, bounds.y - 1, bounds.width - 1, bounds.height); } }); window.add(info, BorderLayout.SOUTH); HotkeyManager.registerHotkey( screen, Hotkey.ESCAPE, new HotkeyRunnable() { @Override public void run(final KeyEvent e) { if (window != null) { shouldUpdateColor = false; window.dispose(); } } }); } private void updateWindowLocation() { final Point p = MouseInfo.getPointerInfo().getLocation(); final Rectangle b = window .getGraphicsConfiguration() .getDevice() .getDefaultConfiguration() .getBounds(); final int ww = window.getWidth(); final int wh = window.getHeight(); final int x = p.x + 20 + ww < b.x + b.width ? p.x + 20 : p.x - 20 - ww; final int y = p.y + 20 + wh < b.y + b.height ? p.y + 20 : p.y - 20 - wh; window.setLocation(x, y); } }; pipettePicker.addMouseListener(mouseAdapter); pipettePicker.addMouseMotionListener(mouseAdapter); pipettePicker.setCursor(Cursor.getDefaultCursor()); } } // Adding field leading component setLeadingComponent(pipettePicker); }
public void setArmed(boolean armed) { this.armed = armed; if (this.armed) ((Component) this.wwd).setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); else ((Component) this.wwd).setCursor(Cursor.getDefaultCursor()); }
public void mouseExited(MouseEvent e) { if (e.getSource() == bottomText) { bottomText.setCursor(Cursor.getDefaultCursor()); } }
protected void enterLogin() { char[] password = m_passwordField.getPassword(); String strUser = (String) m_cmbUser.getSelectedItem(); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean blogin = WUserUtil.isOperatorNameok(strUser, false); if (blogin) { blogin = vnmrjPassword(strUser, password); if (!blogin) blogin = unixPassword(strUser, password); } if (blogin) { m_lblLogin.setForeground(Color.black); m_lblLogin.setText("Login Successful"); m_lblLogin.setVisible(true); // Get the Email column string for access to the operator data String emStr = vnmr.util.Util.getLabel("_admin_Email"); String stremail = WUserUtil.getOperatordata(strUser, emStr); // Get the Panel Level column string for access to the operator data String plStr = vnmr.util.Util.getLabel("_admin_Panel_Level"); String strPanel = WUserUtil.getOperatordata(strUser, plStr); if (stremail == null || stremail.equals("null")) stremail = ""; try { Integer.parseInt(strPanel); } catch (Exception e) { strPanel = WGlobal.PANELLEVEL; } m_trayTimer.stop(); Messages.postDebug(" Login: "******"appdir('reset','") .append(strUser) .append("','") .append(stremail) .append("',") .append(strPanel) .append(")") .toString()); exp.sendToVnmr("vnmrjcmd('util', 'bgReady')\n"); } setVisible(false); // Save the current position and size of this panel in case it // was changed Dimension size = getSize(); width = size.width; height = size.height; position = getLocation(); writePersistence(); // Call the macro to update this operator's // ExperimentSelector_operatorName.xml file // from the protocols themselves. This macro will // cause an update of the ES when it is finished // Util.getAppIF().sendToVnmr("updateExpSelector"); // I am not sure why we need to force updates since updateExpSelector // should have caused an update by writing to ES_op.xml file. // However, it works better if we do the force update. // ExpSelector.setForceUpdate(true); } else { m_lblLogin.setForeground(DisplayOptions.getColor("Error")); // m_lblLogin.setText("<HTML>Incorrect username/password <p> Please try again </HTML>"); m_lblLogin.setVisible(true); } setCursor(Cursor.getDefaultCursor()); }
public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src == binfo) { JOptionPane.showMessageDialog( frame, "Programme crée par Sarathai\n" + "Licence creative commons\n" + "\n" + "Pour envoyer des fichiers sur le serveur, cliquer d'abord sur le bouton ajouter,\n" + "puis sélectionnez le dossier ou fichier à ajouter. Répétez cette opération autant de foi que nécessaire.\n" + "Puis cliquez sur le bouton envoyer en ayant d'abord rempli les champs de l'adresse ip et du port.\n" + "\n" + "Pour recevoir des fichiers sauvegardés sur le serveur, cliquez sur le bouton recevoir,\n" + "puis sélectionnez le ou les fichier(s) voulu(s) dans la liste de gauche, et enfin recliquez\n" + "sur le bouton recevoir pour importer les fichiers.\n" + "\n" + "Pour toutes les infos, bien lire le texte qui s'affiche dans le champ de texte en bas.", "Informations", JOptionPane.INFORMATION_MESSAGE); } else if (src == ajouter) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(chooser.getAcceptAllFileFilter()); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int i = chooser.showOpenDialog(Fenetre.frame); if (i == JFileChooser.APPROVE_OPTION) { frame.setCursor(waitCursor); File file = chooser.getSelectedFile(); if (file.isDirectory()) { name = file.getAbsolutePath().toString() + sep; selection.addElement(name); new WhatIDo("Ajouté à la séléction", name); } else { name = file.getAbsolutePath().toString(); selection.addElement(name); new WhatIDo("Ajouté à la séléction", name); } liste.updateUI(); enlever.setEnabled(true); frame.setCursor(Cursor.getDefaultCursor()); } } else if (src == enlever) { try { int j = liste.getSelectedIndex(); new WhatIDo("Supprimé de la séléction", selection.elementAt(j).toString()); selection.removeElementAt(j); } catch (ArrayIndexOutOfBoundsException e1) { new WhatIDo("Supprimé de la séléction", selection.elementAt(0).toString()); selection.removeElementAt(0); } if (selection.size() == 0) { selection.clear(); liste.clearSelection(); enlever.setEnabled(false); } liste.updateUI(); } else if (src == bquitter) { System.exit(0); } else if (src == bnouveau) { selection.clear(); liste.clearSelection(); liste.updateUI(); new WhatIDo("Nouvelle sauvegarde"); } else if (src == benvoyer) { if (!selection.isEmpty()) { new Envoyer(selection); } else { new WhatIDo("Veuillez ajouter des fichiers ou dossiers"); } } else if (src == brecevoir) { if (!liste.isSelectionEmpty()) { Vector<String> vec = new Vector<String>(); for (int i : liste.getSelectedIndices()) { vec.addElement(selection.elementAt(i)); } new Recevoir(vec); } else { new Recevoir(); } } }
/** * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ. */ public ImageJ(java.applet.Applet applet, int mode) { super("ImageJ"); embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW); this.applet = applet; String err1 = Prefs.load(this, applet); if (IJ.isLinux()) { backgroundColor = new Color(240, 240, 240); setBackground(backgroundColor); } Menus m = new Menus(this, applet); String err2 = m.addMenuBar(); m.installPopupMenu(this); setLayout(new GridLayout(2, 1)); // Tool bar toolbar = new Toolbar(); toolbar.addKeyListener(this); add(toolbar); // Status bar statusBar = new Panel(); statusBar.setLayout(new BorderLayout()); statusBar.setForeground(Color.black); statusBar.setBackground(backgroundColor); statusLine = new Label(); statusLine.setFont(SansSerif12); statusLine.addKeyListener(this); statusLine.addMouseListener(this); statusBar.add("Center", statusLine); progressBar = new ProgressBar(120, 20); progressBar.addKeyListener(this); progressBar.addMouseListener(this); statusBar.add("East", progressBar); statusBar.setSize(toolbar.getPreferredSize()); add(statusBar); IJ.init(this, applet); addKeyListener(this); addWindowListener(this); setFocusTraversalKeysEnabled(false); Point loc = getPreferredLocation(); Dimension tbSize = toolbar.getPreferredSize(); int ijWidth = tbSize.width + 10; int ijHeight = 100; setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug if (mode != NO_SHOW) { if (IJ.isWindows()) try { setIcon(); } catch (Exception e) { } setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work setLocation(loc.x, loc.y); pack(); setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux show(); } if (err1 != null) IJ.error(err1); if (err2 != null) { IJ.error(err2); IJ.runPlugIn("ij.plugin.ClassChecker", ""); } m.installStartupMacroSet(); if (IJ.isMacintosh() && applet == null) { Object qh = null; qh = IJ.runPlugIn("MacAdapter", ""); if (qh == null) IJ.runPlugIn("QuitHandler", ""); } if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", ""); String str = m.getMacroCount() == 1 ? " macro" : " macros"; IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str); // if (applet==null && !embedded && Prefs.runSocketListener) // new SocketListener(); configureProxy(); if (applet == null) loadCursors(); }
@Override public Cursor getCursor(int lineNum) { return myRevisions.containsKey(lineNum) ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) : Cursor.getDefaultCursor(); }
/** * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ. */ public ImageJ(java.applet.Applet applet, int mode) { super("ImageJ"); if ((mode & DEBUG) != 0) IJ.setDebugMode(true); mode = mode & 255; if (IJ.debugMode) IJ.log("ImageJ starting in debug mode: " + mode); embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW); this.applet = applet; String err1 = Prefs.load(this, applet); setBackground(backgroundColor); Menus m = new Menus(this, applet); String err2 = m.addMenuBar(); m.installPopupMenu(this); setLayout(new BorderLayout()); // Tool bar toolbar = new Toolbar(); toolbar.addKeyListener(this); add("Center", toolbar); // Status bar statusBar = new Panel(); statusBar.setLayout(new BorderLayout()); statusBar.setForeground(Color.black); statusBar.setBackground(backgroundColor); statusLine = new JLabel(); statusLine.setFont(new Font("SansSerif", Font.PLAIN, 13)); statusLine.addKeyListener(this); statusLine.addMouseListener(this); statusBar.add("Center", statusLine); progressBar = new ProgressBar(120, 20); progressBar.addKeyListener(this); progressBar.addMouseListener(this); statusBar.add("East", progressBar); add("South", statusBar); IJ.init(this, applet); addKeyListener(this); addWindowListener(this); setFocusTraversalKeysEnabled(false); m.installStartupMacroSet(); // add custom tools runStartupMacro(); Point loc = getPreferredLocation(); Dimension tbSize = toolbar.getPreferredSize(); setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug if (mode != NO_SHOW) { if (IJ.isWindows()) try { setIcon(); } catch (Exception e) { } setLocation(loc.x, loc.y); setResizable(!IJ.isMacOSX()); pack(); setVisible(true); } if (err1 != null) IJ.error(err1); if (err2 != null) { IJ.error(err2); IJ.runPlugIn("ij.plugin.ClassChecker", ""); } if (IJ.isMacintosh() && applet == null) { Object qh = null; qh = IJ.runPlugIn("MacAdapter", ""); if (qh == null) IJ.runPlugIn("QuitHandler", ""); } if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", ""); String str = m.getMacroCount() == 1 ? " macro" : " macros"; IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str); configureProxy(); if (applet == null) loadCursors(); }
private void restoreCursor() { myAlarm.cancelAllRequests(); setCursor(Cursor.getDefaultCursor()); }
protected void setComponentCursor(Cursor cursor) { ((Component) this.measureTool.getWwd()) .setCursor(cursor != null ? cursor : Cursor.getDefaultCursor()); }
/** * ************************************************************************ List Selection * Listener * * @param e event */ public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; // log.config( "VMatch.valueChanged"); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getDefaultCursor()); } // valueChanged