Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3025 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  [SWT] ma toolbar n'a pas d'images

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[SWT] ma toolbar n'a pas d'images

n°1362865
kadreg
profil: Utilisateur
Posté le 09-05-2006 à 22:20:53  profilanswer
 

J'essaye de créer une toolbar en utilisant SWT. Mais j'ai un problème, elle n'apparait pas. J'ai mis son background en bleu (d'ou la ligne bizarre), et miracle, on voit un gros paté bleu de la taille des icones que j'y ai mise  :heink:  
 
Au debuggeur, au chargement de l'image, ça a l'air de passer, mais c'est comme si elle etait de la bonne taille, mais vide. De toutes façon, si je met un fichier qui n'existe pas, j'ai une levée d'exception :)
 

Code :
  1. private void initToolbarContent(ToolBar toolbar) {
  2.  InputStream is = this.getClass().getResourceAsStream("open.png" );
  3.  Image icon = new Image (display, is);
  4.  ToolItem item = new ToolItem (toolbar, SWT.PUSH);
  5.  item.setImage (icon);
  6.  toolbar.pack();
  7.  toolbar.setBackground(display.getSystemColor( SWT.COLOR_BLUE));
  8.  toolbar.setSize(640, 20);
  9. }


 
Voyez vous d'ou cela peutr venir ?


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
mood
Publicité
Posté le 09-05-2006 à 22:20:53  profilanswer
 

n°1362876
kadreg
profil: Utilisateur
Posté le 09-05-2006 à 22:38:16  profilanswer
 

RRRHHHHAAAAAA, le même  code marche dans le cas d'un menu [:sisicaivrai]


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1362882
kadreg
profil: Utilisateur
Posté le 09-05-2006 à 22:45:37  profilanswer
 

hummmm, mon item a pas l'air d'être dans la toolbar en fait ....


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1362896
nraynaud
lol
Posté le 09-05-2006 à 23:17:25  profilanswer
 

RTFM, STFU n00B :fou:

n°1362897
nraynaud
lol
Posté le 09-05-2006 à 23:20:44  profilanswer
 

pis t'iras foutre tes merdes ailleurs que dans la cat java, genre la cat C ça sera bien, à côté de GTK ...

n°1362903
kadreg
profil: Utilisateur
Posté le 09-05-2006 à 23:27:59  profilanswer
 

tu n'aimes pas quand il faut faire des deletes en java ?


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1362906
verdoux
And I'm still waiting
Posté le 09-05-2006 à 23:39:03  profilanswer
 

Faut reconnaître que c'est le gros manque de Java par rapport à C# et C++/CLI :o

n°1362999
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 09:46:53  profilanswer
 

up :o
 
mon listener marche, mais c'est celui sur le deuxième element qui est appelé. La largeur de la zone est exactement d'une icone, quel que soit le nombre de ToolItem que je mets dedans. J'ai viré le bleu et mis ma toolbar en SWT.BORDER, mais c'est toujours pareil.
 
Pour l'instant, ça donne ça :  
 
http://rincevent.dyndns.org/toto/SWT.png
 
et la status bar moche en bas fera l'objet d'un autre topic :o


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1363189
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 12:55:02  profilanswer
 

up http://rincevent.dyndns.org/toto/knuckles.gif


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1363205
the real m​oins moins
Posté le 10-05-2006 à 13:14:21  profilanswer
 

marrant,  j'ai vu un topic swt, et j'me suis dit que j'allais faire une blague en disant que le spécialiste swt, c'était kadreg, et que le posteur pouvait le contacter en mp ...
[:manust]


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
mood
Publicité
Posté le 10-05-2006 à 13:14:21  profilanswer
 

n°1363206
the real m​oins moins
Posté le 10-05-2006 à 13:14:52  profilanswer
 

(tiens au fait si tu veux rire, regarde le code source de la classe Image que tu utilises là)


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
n°1363211
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 13:19:36  profilanswer
 

the real moins moins a écrit :

(tiens au fait si tu veux rire, regarde le code source de la classe Image que tu utilises là)


 
Les inbrication interne de niveau 12 :love:
Les switch dans des switch :love:
 


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1363215
the real m​oins moins
Posté le 10-05-2006 à 13:22:20  profilanswer
 

y'a encore le code qui manipule des bytes avec des masques et autres joyeusetés complètement imbitables, dans les constructeurs, et qui à l'air dupliqué, sans être tout à fait le meme d'un constructeur à l'autre? :love:


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
n°1363233
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 13:34:00  profilanswer
 

:love: ouuuiiiii
 

Code :
  1. /**
  2. * Constructs a new instance of this class based on the
  3. * provided image, with an appearance that varies depending
  4. * on the value of the flag. The possible flag values are:
  5. * <dl>
  6. * <dt><b>IMAGE_COPY</b></dt>
  7. * <dd>the result is an identical copy of srcImage</dd>
  8. * <dt><b>IMAGE_DISABLE</b></dt>
  9. * <dd>the result is a copy of srcImage which has a <em>disabled</em> look</dd>
  10. * <dt><b>IMAGE_GRAY</b></dt>
  11. * <dd>the result is a copy of srcImage which has a <em>gray scale</em> look</dd>
  12. * </dl>
  13. *
  14. * @param device the device on which to create the image
  15. * @param srcImage the image to use as the source
  16. * @param flag the style, either <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code>
  17. *
  18. * @exception IllegalArgumentException <ul>
  19. *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
  20. *    <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
  21. *    <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
  22. *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
  23. * </ul>
  24. * @exception SWTException <ul>
  25. *    <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or
  26. *          is otherwise in an invalid state</li>
  27. *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the Image is not supported</li>
  28. * </ul>
  29. * @exception SWTError <ul>
  30. *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
  31. * </ul>
  32. */
  33. public Image(Device device, Image srcImage, int flag) {
  34. if (device == null) device = Device.getDevice();
  35. if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
  36. this.device = device;
  37. if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
  38. if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
  39. switch (flag) {
  40.  case SWT.IMAGE_COPY: {
  41.   Rectangle r = srcImage.getBounds();
  42.   this.type = srcImage.type;
  43.   switch (type) {
  44.    case SWT.BITMAP:
  45.     /* Get the HDC for the device */
  46.     int hDC = device.internal_new_GC(null);
  47.     /* Copy the bitmap */
  48.     int hdcSource = OS.CreateCompatibleDC(hDC);
  49.     int hdcDest = OS.CreateCompatibleDC(hDC);
  50.     int hOldSrc = OS.SelectObject(hdcSource, srcImage.handle);
  51.     handle = OS.CreateCompatibleBitmap(hdcSource, r.width, r.height);
  52.     if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  53.     int hOldDest = OS.SelectObject(hdcDest, handle);
  54.     OS.BitBlt(hdcDest, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
  55.     OS.SelectObject(hdcSource, hOldSrc);
  56.     OS.SelectObject(hdcDest, hOldDest);
  57.     OS.DeleteDC(hdcSource);
  58.     OS.DeleteDC(hdcDest);
  59.     /* Release the HDC for the device */
  60.     device.internal_dispose_GC(hDC, null);
  61.     transparentPixel = srcImage.transparentPixel;
  62.     alpha = srcImage.alpha;
  63.     if (srcImage.alphaData != null) {
  64.      alphaData = new byte[srcImage.alphaData.length];
  65.      System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length);
  66.     }
  67.     break;
  68.    case SWT.ICON:
  69.     if (OS.IsWinCE) {
  70.      init(device, srcImage.data);
  71.     } else {
  72.      handle = OS.CopyImage(srcImage.handle, OS.IMAGE_ICON, r.width, r.height, 0);
  73.      if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  74.     }
  75.     break;
  76.    default:
  77.     SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
  78.   }
  79.   if (device.tracking) device.new_Object(this);
  80.   return;
  81.  }
  82.  case SWT.IMAGE_DISABLE: {
  83.   Rectangle r = srcImage.getBounds();
  84.   this.type = srcImage.type;
  85.   byte[] rgbBwBitmapInfo = {
  86.    40,0,0,0, /* biSize */
  87.    (byte)(r.width & 0xFF), /* biWidth */
  88.    (byte)((r.width & 0xFF00) >> 8),
  89.    (byte)((r.width & 0xFF0000) >> 16),
  90.    (byte)((r.width & 0xFF000000) >> 24),
  91.    (byte)(r.height & 0xFF), /* biHeight */
  92.    (byte)((r.height & 0xFF00) >> 8),
  93.    (byte)((r.height & 0xFF0000) >> 16),
  94.    (byte)((r.height & 0xFF000000) >> 24),
  95.    1,0, /* biPlanes */
  96.    1,0, /* biBitCount */
  97.    0,0,0,0, /* biCompression */
  98.    0,0,0,0, /* biSizeImage */
  99.    0,0,0,0, /* biXPelsPerMeter */
  100.    0,0,0,0, /* biYPelsPerMeter */
  101.    0,0,0,0, /* biClrUsed */
  102.    0,0,0,0, /* biClrImportant */
  103.    0,0,0,0, /* First color: black */
  104.    (byte)0xFF,(byte)0xFF,(byte)0xFF,0 /* Second color: white */
  105.   };
  106.   /* Get the HDC for the device */
  107.   int hDC = device.internal_new_GC(null);
  108.   /* Source DC */
  109.   int hdcSource = OS.CreateCompatibleDC(hDC);
  110.   if (hdcSource == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  111.   /* Monochrome (Intermediate) DC */
  112.   int bwDC = OS.CreateCompatibleDC(hdcSource);
  113.   if (bwDC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  114.   /* Destination DC */
  115.   int hdcBmp = OS.CreateCompatibleDC(hDC);
  116.   if (hdcBmp == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  117.   /* Monochrome (Intermediate) DIB section */
  118.   int[] pbitsBW = new int[1];
  119.   int hbmBW = OS.CreateDIBSection(bwDC, rgbBwBitmapInfo, OS.DIB_RGB_COLORS, pbitsBW, 0, 0);
  120.   if (hbmBW == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  121.   switch (type) {
  122.    case SWT.BITMAP:
  123.     /* Attach the bitmap to the source DC */
  124.     int hOldSrc = OS.SelectObject(hdcSource, srcImage.handle);
  125.     /* Create the destination bitmap */
  126.     handle = OS.CreateCompatibleBitmap(hDC, r.width, r.height);
  127.     if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  128.     /* Attach the DIB section and the new bitmap to the DCs */
  129.     int hOldBw = OS.SelectObject(bwDC, hbmBW);
  130.     int hOldBmp = OS.SelectObject(hdcBmp, handle);
  131.     /* BitBlt the bitmap into the monochrome DIB section */
  132.     OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
  133.     /* Paint the destination rectangle in gray */
  134.     RECT rect = new RECT();
  135.     rect.left = 0;
  136.     rect.top = 0;
  137.     rect.right = r.width;
  138.     rect.bottom = r.height;
  139.     OS.FillRect(hdcBmp, rect, OS.GetSysColorBrush(OS.COLOR_3DFACE));
  140.     /*
  141.      * BitBlt the black bits in the monochrome bitmap into
  142.      * COLOR_3DHILIGHT bits in the destination DC.
  143.      * The magic ROP comes from Charles Petzold's book
  144.      */
  145.     int hb = OS.CreateSolidBrush(OS.GetSysColor(OS.COLOR_3DHILIGHT));
  146.     int oldBrush = OS.SelectObject(hdcBmp, hb);
  147.     OS.BitBlt(hdcBmp, 1, 1, r.width, r.height, bwDC, 0, 0, 0xB8074A);
  148.     /*
  149.      * BitBlt the black bits in the monochrome bitmap into  
  150.      * COLOR_3DSHADOW bits in the destination DC.
  151.      */
  152.     hb = OS.CreateSolidBrush(OS.GetSysColor(OS.COLOR_3DSHADOW));
  153.     OS.DeleteObject(OS.SelectObject(hdcBmp, hb));
  154.     OS.BitBlt(hdcBmp, 0, 0, r.width, r.height, bwDC, 0, 0, 0xB8074A);
  155.     OS.DeleteObject(OS.SelectObject(hdcBmp, oldBrush));
  156.     /* Free resources */
  157.     OS.SelectObject(hdcSource, hOldSrc);
  158.     OS.SelectObject(hdcBmp, hOldBmp);
  159.     OS.SelectObject(bwDC, hOldBw);
  160.     OS.DeleteDC(hdcSource);
  161.     OS.DeleteDC(bwDC);
  162.     OS.DeleteDC(hdcBmp);
  163.     OS.DeleteObject(hbmBW);
  164.     /* Release the HDC for the device */
  165.     device.internal_dispose_GC(hDC, null);
  166.     break;
  167.    case SWT.ICON:
  168.     /* Get icon information */
  169.     ICONINFO iconInfo = new ICONINFO();
  170.     if (OS.IsWinCE) {
  171.      GetIconInfo(srcImage, iconInfo);
  172.     } else {
  173.      if (!OS.GetIconInfo(srcImage.handle, iconInfo))
  174.       SWT.error(SWT.ERROR_INVALID_IMAGE);
  175.     }
  176.     int hdcMask = OS.CreateCompatibleDC(hDC);
  177.     /* Create the destination bitmaps */
  178.     if (iconInfo.hbmColor == 0)
  179.      hOldSrc = OS.SelectObject(hdcSource, iconInfo.hbmMask);
  180.     else
  181.      hOldSrc = OS.SelectObject(hdcSource, iconInfo.hbmColor);
  182.     int newHbmp = OS.CreateCompatibleBitmap(hdcSource, r.width, r.height);
  183.     if (newHbmp == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  184.     int newHmask = OS.CreateBitmap(r.width, r.height, 1, 1, null);
  185.     if (newHmask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  186.     /* BitBlt the source mask into the destination mask */
  187.     int hOldMask = OS.SelectObject(hdcMask, newHmask);
  188.     if (iconInfo.hbmColor != 0)
  189.      OS.SelectObject(hdcSource, iconInfo.hbmMask);
  190.     OS.SelectObject(hdcSource, iconInfo.hbmMask);
  191.     OS.BitBlt(hdcMask, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
  192.     /* Attach the monochrome DIB section and the destination bitmap to the DCs */
  193.     hOldBw = OS.SelectObject(bwDC, hbmBW);
  194.     /* BitBlt the bitmap into the monochrome DIB section */
  195.     if (iconInfo.hbmColor == 0) {
  196.      OS.SelectObject(hdcSource, iconInfo.hbmMask);
  197.      OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcSource, 0, r.height, OS.SRCCOPY);
  198.     } else {
  199.      OS.SelectObject(hdcSource, iconInfo.hbmColor);
  200.      OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
  201.     }
  202.     /* Paint the destination rectangle in grey */
  203.     rect = new RECT();
  204.     rect.left = 0;
  205.     rect.top = 0;
  206.     rect.right = r.width;
  207.     rect.bottom = r.height;
  208.     hOldBmp = OS.SelectObject(hdcBmp, newHbmp);
  209.     OS.FillRect(hdcBmp, rect, OS.GetSysColorBrush(OS.COLOR_3DFACE));
  210.     /*
  211.      * BitBlt the black bits in the monochrome bitmap into
  212.      * COLOR_3DHILIGHT bits in the destination DC.
  213.      * The magic ROP comes from Charles Petzold's book
  214.      */
  215.     hb = OS.CreateSolidBrush(OS.GetSysColor(OS.COLOR_3DSHADOW));
  216.     oldBrush = OS.SelectObject(hdcBmp, hb);
  217.     OS.BitBlt(hdcBmp, 0, 0, r.width, r.height, bwDC, 0, 0, 0xB8074A);
  218.     /* Invert mask into hdcBw */
  219.     OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcMask, 0, 0, OS.NOTSRCCOPY);
  220.     /* Select black brush into destination */
  221.     hb = OS.CreateSolidBrush(0);
  222.     OS.DeleteObject(OS.SelectObject(hdcBmp, hb));
  223.     /*
  224.      * Copy black bits from monochrome bitmap into black bits in the
  225.      * destination DC.
  226.      */
  227.     OS.BitBlt(hdcBmp, 0, 0, r.width, r.height, bwDC, 0, 0, 0xB8074A);
  228.     OS.DeleteObject(OS.SelectObject(hdcBmp, oldBrush));
  229.     /* Free resources */
  230.     OS.SelectObject(hdcSource, hOldSrc);
  231.     OS.DeleteDC(hdcSource);
  232.     OS.SelectObject(bwDC, hOldBw);
  233.     OS.DeleteDC(bwDC);
  234.     OS.SelectObject(hdcBmp, hOldBmp);
  235.     OS.DeleteDC(hdcBmp);
  236.     OS.SelectObject(hdcMask, hOldMask);
  237.     OS.DeleteDC(hdcMask);
  238.     OS.DeleteObject(hbmBW);
  239.     /* Release the HDC for the device */
  240.     device.internal_dispose_GC(hDC, null);
  241.     /* Create the new iconinfo */
  242.     ICONINFO newIconInfo = new ICONINFO();
  243.     newIconInfo.fIcon = iconInfo.fIcon;
  244.     newIconInfo.hbmMask = newHmask;
  245.     newIconInfo.hbmColor = newHbmp;
  246.     /* Create the new icon */
  247.     handle = OS.CreateIconIndirect(newIconInfo);
  248.     if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  249.     /* Free bitmaps */
  250.     OS.DeleteObject(newHbmp);
  251.     OS.DeleteObject(newHmask);
  252.     if (iconInfo.hbmColor != 0)
  253.      OS.DeleteObject(iconInfo.hbmColor);
  254.     OS.DeleteObject(iconInfo.hbmMask);
  255.     break;
  256.    default:
  257.     SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
  258.   }
  259.   if (device.tracking) device.new_Object(this);
  260.   return;
  261.  }
  262.  case SWT.IMAGE_GRAY: {
  263.   Rectangle r = srcImage.getBounds();
  264.   ImageData data = srcImage.getImageData();
  265.   PaletteData palette = data.palette;
  266.   ImageData newData = data;
  267.   if (!palette.isDirect) {
  268.    /* Convert the palette entries to gray. */
  269.    RGB [] rgbs = palette.getRGBs();
  270.    for (int i=0; i<rgbs.length; i++) {
  271.     if (data.transparentPixel != i) {
  272.      RGB color = rgbs [i];
  273.      int red = color.red;
  274.      int green = color.green;
  275.      int blue = color.blue;
  276.      int intensity = (red+red+green+green+green+green+green+blue) >> 3;
  277.      color.red = color.green = color.blue = intensity;
  278.     }
  279.    }
  280.    newData.palette = new PaletteData(rgbs);
  281.   } else {
  282.    /* Create a 8 bit depth image data with a gray palette. */
  283.    RGB[] rgbs = new RGB[256];
  284.    for (int i=0; i<rgbs.length; i++) {
  285.     rgbs[i] = new RGB(i, i, i);
  286.    }
  287.    newData = new ImageData(r.width, r.height, 8, new PaletteData(rgbs));
  288.    newData.maskData = data.maskData;
  289.    newData.maskPad = data.maskPad;
  290.    if (data.transparentPixel != -1) newData.transparentPixel = 254;
  291.    /* Convert the pixels. */
  292.    int[] scanline = new int[r.width];
  293.    int redMask = palette.redMask;
  294.    int greenMask = palette.greenMask;
  295.    int blueMask = palette.blueMask;
  296.    int redShift = palette.redShift;
  297.    int greenShift = palette.greenShift;
  298.    int blueShift = palette.blueShift;
  299.    for (int y=0; y<r.height; y++) {
  300.     int offset = y * newData.bytesPerLine;
  301.     data.getPixels(0, y, r.width, scanline, 0);
  302.     for (int x=0; x<r.width; x++) {
  303.      int pixel = scanline[x];
  304.      if (pixel != data.transparentPixel) {
  305.       int red = pixel & redMask;
  306.       red = (redShift < 0) ? red >>> -redShift : red << redShift;
  307.       int green = pixel & greenMask;
  308.       green = (greenShift < 0) ? green >>> -greenShift : green << greenShift;
  309.       int blue = pixel & blueMask;
  310.       blue = (blueShift < 0) ? blue >>> -blueShift : blue << blueShift;
  311.       int intensity = (red+red+green+green+green+green+green+blue) >> 3;
  312.       if (newData.transparentPixel == intensity) intensity = 255;
  313.       newData.data[offset] = (byte)intensity;
  314.      } else {
  315.       newData.data[offset] = (byte)254;
  316.      }
  317.      offset++;
  318.     }
  319.    }
  320.   }
  321.   init (device, newData);
  322.   if (device.tracking) device.new_Object(this);
  323.   return;
  324.  }
  325.  default:
  326.   SWT.error(SWT.ERROR_INVALID_ARGUMENT);
  327. }
  328. }


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1363278
the real m​oins moins
Posté le 10-05-2006 à 14:00:35  profilanswer
 

magnifique.


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
n°1363284
frabill
Posté le 10-05-2006 à 14:03:19  profilanswer
 

C'est peut-être une idée à la ***, mais il me semble que l'image ne s'affiche pas du tout si le bouton est d'une taille inférieure ou égale à celle de l'image...
Tu as essayé avec une grande dimension pour le bouton et une petite image ?

n°1363293
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 14:05:43  profilanswer
 

tiens ça peut le faire :)
 
 
 
J'ai lancé un troll SWT au bureau entre les architectes \o/ merci mwin mwin
 
edit: mais non ! après avoir mis tous mes items, je fais un toolbar.pack(); [:pingouino]


Message édité par kadreg le 10-05-2006 à 14:10:44

---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1363302
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 10-05-2006 à 14:11:35  profilanswer
 

c'est encore un topic web qui fout la merde ? :o


---------------
J'ai un string dans l'array (Paris Hilton)
n°1363315
the real m​oins moins
Posté le 10-05-2006 à 14:18:43  profilanswer
 

Harkonnen a écrit :

c'est encore un topic web qui fout la merde ? :o


[:pingouino]


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
n°1363867
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 23:07:04  profilanswer
 

Je vais d"ebugger dans ToolBar.compute size, appelée par mon pack, et la taille calculée est correcte [:pingouino]


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1363881
gm_superst​ar
Appelez-moi Super
Posté le 10-05-2006 à 23:40:23  profilanswer
 

Je connais pas SWT, mais en vrac :
 
 - avec une CoolBar ça passe ?
 - t'as regardé comment font des applis qui utilisent SWT ?
 - icônes foireuses ?


---------------
Incongru : une FAQ abandonnée sur les Standards du Web - FAQ périmée de blabla@Prog
n°1363883
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 23:48:16  profilanswer
 

http://www.java2s.com/ExampleCode/ [...] arDemo.htm
 
setBounds ?


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1363884
kadreg
profil: Utilisateur
Posté le 10-05-2006 à 23:52:00  profilanswer
 

ah non, c'est pareil avec le setBounds. Mais l'exemple là marche [:sisicaivrai]


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1364708
kadreg
profil: Utilisateur
Posté le 11-05-2006 à 23:17:51  profilanswer
 

Code :
  1. public class ToolbarClass {
  2.   public static void main(String[] args) {
  3.     Display display = new Display();
  4.     final Shell shell = new Shell(display);
  5.     shell.setText("Toolbar Example" );
  6.     ToolBar toolbar = new ToolBar(shell, SWT.NONE| SWT.BORDER );
  7. InputStream is = new ToolbarClass().getClass().getResourceAsStream("org/kadreg/essaiSWT/save.png" );
  8. Image icon = new Image (display, is);
  9.     ToolItem toolItem1 = new ToolItem(toolbar, SWT.PUSH);
  10.     toolItem1.setText("Save" );
  11.     toolItem1.setImage(icon);
  12.     ToolItem toolItem2 = new ToolItem(toolbar, SWT.PUSH);
  13.     toolItem2.setText("Save As" );
  14.     ToolItem toolItem3 = new ToolItem(toolbar, SWT.PUSH);
  15.     toolItem3.setText("Print" );
  16.     ToolItem toolItem4 = new ToolItem(toolbar, SWT.PUSH);
  17.     toolItem4.setText("Run" );
  18.     ToolItem toolItem5 = new ToolItem(toolbar, SWT.PUSH);
  19.     toolItem5.setText("Help" );
  20.    
  21.     toolbar.pack ();
  22.     shell.setSize(300, 200);
  23.     final Text text = new Text(shell, SWT.BORDER);
  24.     text.setBounds(55, 80, 200, 25);
  25.     Listener toolbarListener = new Listener() {
  26.       public void handleEvent(Event event) {
  27.         ToolItem toolItem = (ToolItem) event.widget;
  28.         String caption = toolItem.getText();
  29.         text.setText("You clicked " + caption);
  30.       }
  31.     };
  32.     toolItem1.addListener(SWT.Selection, toolbarListener);
  33.     toolItem2.addListener(SWT.Selection, toolbarListener);
  34.     toolItem3.addListener(SWT.Selection, toolbarListener);
  35.     toolItem4.addListener(SWT.Selection, toolbarListener);
  36.     toolItem5.addListener(SWT.Selection, toolbarListener);
  37.     shell.open();
  38.     while (!shell.isDisposed()) {
  39.       if (!display.readAndDispatch())
  40.         display.sleep();
  41.     }
  42.     display.dispose();
  43.   }
  44. }


 
Bon, ça ça marche :??: Mais c'est quoi mon problème ?


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1364713
kadreg
profil: Utilisateur
Posté le 11-05-2006 à 23:24:48  profilanswer
 

trouvé :  
 
faire un shell.pack avant de tenter l'affichage :o
 

Spoiler :

quelle merde


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°1364746
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 12-05-2006 à 07:32:08  profilanswer
 

c'est vraiment la fête les toolkits chez Java [:necris]


---------------
J'ai un string dans l'array (Paris Hilton)
n°1364752
verdoux
And I'm still waiting
Posté le 12-05-2006 à 08:15:06  profilanswer
 

C'est Kadreg qui lit pas le manuel :o

n°1364766
kadreg
profil: Utilisateur
Posté le 12-05-2006 à 09:06:42  profilanswer
 

verdoux a écrit :

C'est Kadreg qui lit pas le manuel :o


 
je suis sur que je fais 212 fois trop de pack () et 28 fois trop de dispose :o


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
mood
Publicité
Posté le   profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  [SWT] ma toolbar n'a pas d'images

 

Sujets relatifs
[RESOLU ]affichage des imagesimages php + code html
Images avec Fox GuiUpload de lots d'images.
Retrouver les extensions d'images grâce au type mimeProbléme insertion d'images
Galerie d'images PHP/Flash[Aide] Code source toolbar ....
images et blogMasquer l'origine de mes images
Plus de sujets relatifs à : [SWT] ma toolbar n'a pas d'images


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR