Ingeniería enAnimación Digital
yEfectos Visuales
Asignatura:ProgramaciónOrientadaaObjetos
Profesor:ISC.LizbethHernándezOlán
Unidad3 Herencia Fecha: 3/05/2017
Practica 2 Programasconimagen Página1de 1
No.Control 16081869 NombredelAlumno YaelMárquezMartinez.
1.EnuciadodelProblema.
Programaqueimprimaenpantallaunaimagen
2.CódigoFuente
//*practica2//
//YaelMárquezMartinez.//
//Num.Control:16081869//
importjava.awt.BorderLayout;
importjavax.swing.ImageIcon;
importjavax.swing.JLabel;
importjavax.swing.JFrame;
publicclassDemoLabel
{
publicstaticvoidmain(Stringargs[])
{
//Creaunaetiquetacontextosolamente
JLabeletiquetaNorte=newJLabel("Norte");
//creauniconoapartirdeunaimagen,parapodercolocarlaenunobjetoJLabel
ImageIconetiquetaIcono=newImageIcon("bugs.jpg");
//creaunaetiquetaconuniconoenvezdetexto
JLabeletiquetaCentro=newJLabel(etiquetaIcono);
//creaotraetiquetaconunicono
JLabeletiquetaSur=newJLabel(etiquetaIcono);
//establecelaetiquetaparamostrartexto(asícomounicono)
etiquetaSur.setText("Sur");
//creaunmarcoparacontenerlasetiquetas
JFrameaplicacion=newJFrame();
aplicacion.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//agregalasetiquetasalmarco;elsegundoargumentoespecifica
//enquépartedelmarcosevaaagregarlaetiqueta
aplicacion.add(etiquetaNorte,BorderLayout.NORTH);
aplicacion.add(etiquetaCentro,BorderLayout.CENTER);
aplicacion.add(etiquetaSur,BorderLayout.SOUTH);
aplicacion.setSize(300,300);//estableceeltamañodelmarco
aplicacion.setVisible(true);//muestraelmarco
}//findemain
}
3.Impresiondepantalla,sóloelresultadoobtenido(noimpresionesdecódigo)
P2

P2

  • 1.
    Ingeniería enAnimación Digital yEfectosVisuales Asignatura:ProgramaciónOrientadaaObjetos Profesor:ISC.LizbethHernándezOlán Unidad3 Herencia Fecha: 3/05/2017 Practica 2 Programasconimagen Página1de 1 No.Control 16081869 NombredelAlumno YaelMárquezMartinez. 1.EnuciadodelProblema. Programaqueimprimaenpantallaunaimagen 2.CódigoFuente //*practica2// //YaelMárquezMartinez.// //Num.Control:16081869// importjava.awt.BorderLayout; importjavax.swing.ImageIcon; importjavax.swing.JLabel; importjavax.swing.JFrame; publicclassDemoLabel { publicstaticvoidmain(Stringargs[]) { //Creaunaetiquetacontextosolamente JLabeletiquetaNorte=newJLabel("Norte"); //creauniconoapartirdeunaimagen,parapodercolocarlaenunobjetoJLabel ImageIconetiquetaIcono=newImageIcon("bugs.jpg"); //creaunaetiquetaconuniconoenvezdetexto JLabeletiquetaCentro=newJLabel(etiquetaIcono); //creaotraetiquetaconunicono JLabeletiquetaSur=newJLabel(etiquetaIcono); //establecelaetiquetaparamostrartexto(asícomounicono) etiquetaSur.setText("Sur"); //creaunmarcoparacontenerlasetiquetas JFrameaplicacion=newJFrame(); aplicacion.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //agregalasetiquetasalmarco;elsegundoargumentoespecifica //enquépartedelmarcosevaaagregarlaetiqueta aplicacion.add(etiquetaNorte,BorderLayout.NORTH); aplicacion.add(etiquetaCentro,BorderLayout.CENTER); aplicacion.add(etiquetaSur,BorderLayout.SOUTH); aplicacion.setSize(300,300);//estableceeltamañodelmarco aplicacion.setVisible(true);//muestraelmarco }//findemain
  • 2.