コード例 #1
0
ファイル: CutPanelView.java プロジェクト: OceanAtlas/JOA
  // 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));
  }
コード例 #2
0
ファイル: ColorPickerPanel.java プロジェクト: ryokbys/Akira
  /** 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);
  }
コード例 #3
0
  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;
  }
コード例 #4
0
  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();
            }
          }
        });
  }
コード例 #5
0
 public Cursor getCursor() {
   return (isCursorAllowed)
       ? super.getCursor()
       : Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
 }
コード例 #6
0
  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);
  }