コード例 #1
0
 public static void setCursor(int id) {
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   String location = signlink.findcachedir() + "/Sprites/";
   Cursor cursor =
       toolkit.createCustomCursor(
           toolkit.getImage(location + "CURSOR " + id + ".PNG"),
           new Point(0, 0),
           location + "CURSOR " + id + ".PNG");
   frame.setCursor(cursor);
 }
コード例 #2
0
 public static void setCursor(client client, int id) {
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   Cursor cursor =
       toolkit.createCustomCursor(
           toolkit.getImage("C:/.hack3rClient/Sprites/Cursors/Cursor " + id + ".PNG"),
           new Point(0, 0),
           "C:/.hack3rClient/Sprites/Cursors/Cursor " + id + ".PNG");
   // Cursor cursor = toolkit.createCustomCursor(toolkit.getImage("Cursors/Cursor "+id+".PNG"), new
   // Point(0,0), ".Cursor/Cursor "+id+".PNG");
   frame.setCursor(cursor);
   //	client.gameFrame.setCursor(cursor);
 }
コード例 #3
0
 public CustomCursor() {
   JFrame frame = new JFrame();
   int[][] cursorImageArray =
       new int[][] {
         {1, 0, 0, 0, 0, 0, 0, 0, 0},
         {1, 1, 0, 0, 0, 0, 0, 0, 0},
         {1, 1, 1, 0, 0, 0, 0, 0, 0},
         {1, 1, 1, 1, 0, 0, 0, 0, 0},
         {1, 1, 1, 1, 1, 0, 0, 0, 0},
         {1, 1, 1, 1, 1, 1, 0, 0, 0},
         {1, 1, 1, 1, 1, 1, 1, 0, 0},
         {1, 1, 1, 1, 1, 1, 1, 1, 0},
         {1, 1, 1, 1, 1, 1, 1, 1, 1},
         {1, 1, 1, 0, 1, 1, 0, 0, 0},
         {1, 1, 0, 0, 1, 1, 0, 0, 0},
         {1, 0, 0, 0, 0, 1, 1, 0, 0},
         {0, 0, 0, 0, 0, 1, 1, 0, 0},
         {0, 0, 0, 0, 0, 0, 1, 1, 0},
         {0, 0, 0, 0, 0, 0, 1, 1, 0},
         {0, 0, 0, 0, 0, 0, 0, 1, 1},
         {0, 0, 0, 0, 0, 0, 0, 1, 1}
       };
   // BufferedImage cursorImageSmall = new BufferedImage(cursorImageArray[0].length,
   // cursorImageArray.length, BufferedImage.TYPE_INT_ARGB);
   System.out.println("" + cursorImageArray[0].length + ", " + cursorImageArray.length);
   System.out.println(
       ""
           + Toolkit.getDefaultToolkit()
               .getBestCursorSize(cursorImageArray[0].length, cursorImageArray.length));
   Dimension bestCursorSize =
       Toolkit.getDefaultToolkit()
           .getBestCursorSize(cursorImageArray[0].length, cursorImageArray.length);
   BufferedImage cursorImage =
       new BufferedImage(bestCursorSize.width, bestCursorSize.height, BufferedImage.TYPE_INT_ARGB);
   Graphics2D graphics2D = (Graphics2D) cursorImage.getGraphics();
   Color transparentColor = new Color(198, 198, 198, 0);
   Color opaqueColor = new Color(255, 0, 0, 255);
   for (int y = 0; y < cursorImageArray.length; y++) {
     for (int x = 0; x < cursorImageArray[0].length; x++) {
       if (cursorImageArray[y][x] == 0) {
         System.out.println("found transparent pixel!");
         // Do nothing, because the background is already transparent
         // You could do this, if you wanted to make a pixel transparent:
         // graphics2D.setComposite(AlphaComposite.Src);
         // graphics2D.setColor(transparentColor);
         // graphics2D.drawRect(x, y, 1, 1);
       } else {
         System.out.println("found opaque pixel!");
         graphics2D.setColor(opaqueColor);
         graphics2D.drawRect(x, y, 1, 1);
       }
     }
   }
   frame.setCursor(
       Toolkit.getDefaultToolkit().createCustomCursor(cursorImage, new Point(0, 0), "MyCursor"));
   JPanel panel = new MyPanel();
   frame.setContentPane(panel);
   frame.setSize(400, 300);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
 }
コード例 #4
0
  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();
      }
    }
  }