jueves, 22 de abril de 2010

Clase prueba objeto imagenes y refuerzo

package capagrafica;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import capacodigo.codigos;

public class formulario {
JFrame miframe;
JPanel mipanel,otropanel;
JTextField texto;
JButton boton;
public JLabel imagen1;



public static void main(String arg[]){

formulario form=new formulario();

}


public formulario(){


miframe= new JFrame("GRITADOR!!!!");
miframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


mipanel=new JPanel(new GridLayout(1,3));
otropanel=new JPanel(new GridLayout(1,1));

texto= new JTextField(10);
boton=new JButton("GRITAR");

ImageIcon Img3 = new ImageIcon("Imagen/ceres.JPG");//SE CREA UNA OBJETO ima DE LA CLASE ImageIcon
imagen1 = new JLabel(Img3);//SE AGREGA EL OBJETO ima AL LABEL imagen

mipanel.add(texto);
mipanel.add(boton);

mipanel.add(imagen1);

boton.addActionListener(new ActionListener(){




public void actionPerformed(ActionEvent e) {
codigos hacer= new codigos();


hacer.mostrar(texto.getText());


}
});



miframe.getContentPane().add(mipanel,BorderLayout.NORTH);
miframe.getContentPane().add(otropanel,BorderLayout.CENTER);



miframe.pack();
miframe.setVisible(true);


}


}

No hay comentarios:

Publicar un comentario