



Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!




Realizar un código que muestre una interfaz grafica con la distribucion de Border Layout en el JFrame y también en el Panel central. Coloque imágenes en las áreas norte, sur, este y oeste del Jframe. En el panel Central que también tiene la distribución de Border, colocar etiquetas con los nombres de sus áreas correspondientes. P.e. en el borde ubicado al norte colocar la etiqueta "NORT".
clase package paka; import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.util.Locale; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Igu { private JFrame ventana; private JPanel panelN, panelS, panelE, panelO, panelC; private JLabel lbl_norte, lbl_sur, lbl_este, lbl_oeste; private JLabel etiqN, etiqS, etiqE, etiqO; private ImageIcon fondoN, fondoS, fondoE, fondoO; private Icon iconN, iconS, iconE, iconO;
iconO = new ImageIcon(fondoO.getImage().getScaledInstance(200, 100, 0)); etiqO.setIcon(iconO); this.atributos(); this.armado(); this.escuchas(); this.lanzar_IGU(); } //Atributos de los componentes public void atributos(){ ventana.setSize(800, 400); ventana.setResizable(true); ventana.setLayout(new BorderLayout(5, 5)); panelN.setBackground(Color.green); panelS.setBackground(Color.red); panelE.setBackground(Color.red); panelO.setBackground(Color.green); panelC.setBackground(Color.yellow); panelC.setLayout(new BorderLayout(5, 5)); lbl_norte.setForeground(Color.DARK_GRAY); lbl_sur.setForeground(Color.darkGray); lbl_este.setForeground(Color.darkGray); lbl_oeste.setForeground(Color.darkGray); } //Armar la interfaz public void armado(){ ventana.add(panelN, BorderLayout.NORTH);
ventana.add(panelS, BorderLayout.SOUTH); ventana.add(panelE, BorderLayout.EAST); ventana.add(panelO, BorderLayout.WEST); ventana.add(panelC, BorderLayout.CENTER); panelN.add(etiqN); panelS.add(etiqS); panelE.add(etiqE); panelO.add(etiqO); panelC.add(lbl_norte, BorderLayout.NORTH); panelC.add(lbl_sur, BorderLayout.SOUTH); panelC.add(lbl_este, BorderLayout.EAST); panelC.add(lbl_oeste, BorderLayout.WEST); } //Asignar los escuchas public void escuchas(){ //vacio } //Lanzar la interfaz public void lanzar_IGU(){ ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ventana.setLocationRelativeTo(null); ventana.setVisible(true); } }