Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/01/2011, 08:01
Avatar de valdo_kof
valdo_kof
 
Fecha de Ingreso: noviembre-2009
Ubicación: San Juan del Rio, Qro
Mensajes: 192
Antigüedad: 14 años, 5 meses
Puntos: 16
Respuesta: hacer paneles y hacerlos imagen

chuidiang gracias por responder

Añadi el codigo q me recomendaste y si me guarda la imagen pero solo es un cuadro totalmente negro no muestra ni el boton, ni el check no se que este haciendo mal si me pueden ayudar gracias de antemano

asi me queda el codigo

Código java:
Ver original
  1. import java.awt.Button;
  2. import java.awt.Checkbox;
  3. import java.awt.Graphics;
  4. import java.awt.Graphics2D;
  5. import java.awt.Panel;
  6. import java.awt.TextField;
  7. import java.awt.geom.AffineTransform;
  8. import java.awt.image.BufferedImage;
  9. import java.io.File;
  10. import java.io.IOException;
  11. import javax.imageio.ImageIO;
  12.  
  13. public class Main {
  14.     private static TextField texto;
  15.     private static Button boton;
  16.     private static Checkbox check;
  17.  
  18.     public static void main(String[] args) throws IOException {
  19.               // Crear panel
  20. Panel bottomPanel = new Panel();
  21. bottomPanel.setSize(200, 200);
  22. // Crear artefactos
  23. texto= new TextField("TextField");
  24. boton= new Button("Button");
  25. check= new Checkbox("Checkbox");
  26.  
  27. // Agregarlos al panel
  28. bottomPanel.add(texto);
  29. bottomPanel.add(boton);
  30. bottomPanel.add(check);
  31. BufferedImage imagen = new BufferedImage(bottomPanel.getWidth(),   bottomPanel.getHeight(), BufferedImage.TYPE_INT_RGB);
  32. // le dices al panel que se dibuje sobre la imagen
  33. bottomPanel.paint(imagen.getGraphics());
  34. // y salvas la imagen
  35. ImageIO.write(imagen, "jpg", new File("c:/panel.jpg"));
  36.     }
  37. }