// Cursors: arrow, cross, section, zoomIn, zoomOut; public void setCPCursor(Point p, boolean shiftDown) { if (isInDragArea(p)) { if (toolMode == Constants.ZOOM_MODE) { if (shiftDown) setCursor(zoomOut); else setCursor(zoomIn); } else if (toolMode == Constants.SELECT_MODE) { setCursor(cross); } else if (toolMode == Constants.SECTION_MODE) { setCursor(section); } else { setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } // display the cursor loc in real values displayCursorValues(p); } else if (isInDragArea(p) && Constants.ISMAC) { setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } else setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
/** Creates a new <code>ColorPickerPanel</code> */ public ColorPickerPanel() { setMaximumSize( new Dimension( MAX_SIZE + imagePadding.left + imagePadding.right, MAX_SIZE + imagePadding.top + imagePadding.bottom)); setPreferredSize(new Dimension((int) (MAX_SIZE * .75), (int) (MAX_SIZE * .75))); setRGB(0, 0, 0); addMouseListener(mouseListener); addMouseMotionListener(mouseListener); setFocusable(true); addKeyListener(keyListener); addFocusListener(focusListener); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); addComponentListener(componentListener); }
private JLabel makeLabelIcon() { ImageIcon i = new ImageIcon(getClass().getResource("duke.gif")); Dimension d = new Dimension(i.getIconWidth(), i.getIconHeight()); final BufferedImage image = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB); Graphics g = image.createGraphics(); i.paintIcon(null, g, 0, 0); g.dispose(); final JLabel icon = new JLabel(i) { @Override public boolean contains(int x, int y) { return super.contains(x, y) && ((image.getRGB(x, y) >> 24) & 0xff) != 0; } }; icon.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); MouseAdapter l = new MouseAdapter() { private final transient Point start = new Point(); private Point loc; @Override public void mousePressed(MouseEvent me) { start.setLocation(me.getPoint()); } @Override public void mouseDragged(MouseEvent me) { loc = icon.getLocation(loc); int x = loc.x - start.x + me.getX(); int y = loc.y - start.y + me.getY(); icon.setLocation(x, y); } }; icon.addMouseListener(l); icon.addMouseMotionListener(l); icon.setBounds(new Rectangle(22, 22, d.width, d.height)); return icon; }
private void init(IScreen scr, EventObserver ob) { addObserver(ob); if (RunTime.get().isOSX10()) { scrOCP = scr; } else { if (Screen.getNumberScreens() > 1) { scrOCP = new ScreenUnion(); } else { scrOCP = Screen.getPrimaryScreen(); } } canceled = false; setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); rectSelection = new Rectangle(); addMouseListener( new MouseAdapter() { @Override public void mouseMoved(java.awt.event.MouseEvent e) { if (promptMsg == null) { return; } promptMsg = null; repaint(); } @Override public void mousePressed(java.awt.event.MouseEvent e) { if (scr_img == null) { return; } if (promptMsg != null) { promptMsg = null; didPurgeMessage = true; } destx = srcx = e.getX(); desty = srcy = e.getY(); srcScreenId = scrOCP.getIdFromPoint(srcx, srcy); srcScreenLocation = new Location(srcx + scrOCP.getX(), srcy + scrOCP.getY()); Debug.log( 4, "CapturePrompt: started at (%d,%d) as %s on %d", srcx, srcy, srcScreenLocation.toStringShort(), srcScreenId); repaint(); } @Override public void mouseReleased(java.awt.event.MouseEvent e) { if (scr_img == null) { return; } if (!dragging && didPurgeMessage) { didPurgeMessage = false; return; } if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) { canceled = true; Debug.log(3, "CapturePrompt: aborted using right mouse button"); } else { destScreenLocation = new Location(destx + scrOCP.getX(), desty + scrOCP.getY()); Debug.log( 4, "CapturePrompt: finished at (%d,%d) as %s on %d", destx, desty, destScreenLocation.toStringShort(), srcScreenId); } setVisible(false); notifyObserver(); } }); addMouseMotionListener( new MouseMotionAdapter() { @Override public void mouseDragged(java.awt.event.MouseEvent e) { if (scr_img == null) { return; } dragging = true; destx = e.getX(); desty = e.getY(); repaint(); } }); addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { if (promptMsg != null) { promptMsg = null; repaint(); return; } canceled = true; Debug.log(3, "CapturePrompt: aborted using key ESC"); setVisible(false); notifyObserver(); } } }); }
/** * 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(); }
/** * 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(); }
public Cursor getCursor() { return (isCursorAllowed) ? super.getCursor() : Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); }
public LoginPanel(Image img, ActionListener listener) { super(null); this.listener = listener; if (img == null) { InputStream inData = getClass().getResourceAsStream("/resources/background.gif"); BufferedImage back = null; if (inData != null) try { back = ImageIO.read(inData); } catch (IOException e) { loger.finest("LoginPanel class can't get the background image"); } this.background = back; } setLayout(null); JPanel logingPanel = new JPanel(); loginTitle = new JLabel("Autentificare"); logingPanel.setSize(250, 150); logingPanel.setBorder(new javax.swing.border.LineBorder(Color.black, 2)); logingPanel.setLayout(null); loginTitle.setBounds(3, 0, logingPanel.getWidth(), 20); logingPanel.add(loginTitle); JLabel loginUser = new JLabel("Utilizator"); loginUser.setBounds( 80 - loginUser.getPreferredSize().width, 40, loginUser.getPreferredSize().width, loginUser.getPreferredSize().height); logingPanel.add(loginUser); user = new JTextField(10); user.setBounds(85, 40, user.getPreferredSize().width, user.getPreferredSize().height); // user.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(user); JLabel loginPass = new JLabel("Parola"); loginPass.setBounds( 80 - loginPass.getPreferredSize().width, 80, loginPass.getPreferredSize().width, loginPass.getPreferredSize().height); logingPanel.add(loginPass); // JTextField pass = new JTextField(10); pass = new JPasswordField(10); pass.setBounds(85, 80, pass.getPreferredSize().width, pass.getPreferredSize().height); pass.addKeyListener(this); // pass.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(pass); JButton loginButton = new JButton("Start"); loginButton.setActionCommand("LOGIN"); loginButton.setBounds( 60, 110, loginButton.getPreferredSize().width, loginButton.getPreferredSize().height); // loginButton.setOpaque(false); loginButton.setFocusPainted(false); // loginButton.setContentAreaFilled(false); // loginButton.setBorderPainted(false); loginButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); loginButton.addActionListener(listener); logingPanel.add(loginButton); add(logingPanel); }