Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/09/2013, 00:33
Julio213
 
Fecha de Ingreso: septiembre-2013
Mensajes: 2
Antigüedad: 10 años, 7 meses
Puntos: 0
Pregunta Ayudaa!! hacer un paint en java

Hola soy nuevo en Java, estoy haciendo una aplicacion parecida al paint y quiero que al hacer click en un boton se muestre un panel en el cual se habilite mi opcion para empezar a dibujar. Por favor es ayuda urgente!

Código Java:
Ver original
  1. public class ventana extends JFrame {
  2.     private JPanel panelbotones, panelcolores,paneldibujo;
  3.     private JButton blinea, bcuadrado, bcirculo, btriangulo;
  4.     private JButton bcnegro, bcazul, bcrojo;
  5.     private Container contenedor;
  6.     private JLabel herram, color;
  7. public ventana() {
  8.         super("Simulador de Paint");
  9.         setResizable(false);
  10.         contenedor = getContentPane();
  11.         setDefaultCloseOperation(EXIT_ON_CLOSE);
  12.  blinea.addActionListener(new ActionListener(){
  13.             public void actionPerformed(ActionEvent ae) {
  14.              AQUI QUISIERA QUE SE ADICIONE EL CANVAS A MI Jpanel por ejemplo
  15.            // paneldibujo.add(new canvas());
  16.             }
ESTA ES UNA CLASE CANVAS PARA HACER CIRCUNFERENCIAS PERO NO SE SI UNA CLASE ASI SE PUEDE AÑADIR AL EVENTO DEL BOTON DE ARRIBA!!
Código Java:
Ver original
  1. public class canvas extends Canvas implements MouseListener { int x = 50, y = 50, radioX = 30, radioY = 30;
  2.        canvas() {
  3.             this.setBackground(Color.white);
  4.             this.addMouseListener(this);
  5.             this.setFont(new Font("Forte", Font.BOLD, 24));
  6.             this.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
  7.         }
  8.         public void paint(Graphics g) {
  9.             super.paint(g);
  10.             g.setColor(Color.red);
  11.             g.drawString("Dibuja Circunferencias", 50, 20);
  12.             g.setColor(Color.blue);
  13.             g.drawLine(50, 40, 340, 40);
  14.             g.setColor(Color.green);
  15.             g.drawOval(x, y, radioX, radioY);
  16.         }
  17.         public void mousePressed(MouseEvent e) {
  18.             x = e.getX();
  19.             y = e.getY();
  20.         }
  21.         public void mouseReleased(MouseEvent e) {
  22.             radioX = (e.getX() - x);
  23.             radioY = (e.getY() - y);
  24.             this.repaint();
  25.         }
  26.         public void mouseEntered(MouseEvent e) {
  27.         }
  28.         public void mouseExited(MouseEvent e) {
  29.         }
  30.         public void mouseClicked(MouseEvent e) {
  31.         }
  32.     }