DAR CLIC
EJERCICIO 1
package PAQUETE_INTERFAZ_02;
/**
*
* @author Administrador
*/
import javax.swing.*;
public class EJERCICIO_01 extends JFrame
{
public JMenu MENU_ARCHIVO,MENU_JAVA;
public JMenuItem ITEM_ABRIR,ITEM_GUARDAR,ITEM_CERRAR,ITEM_JAVADHC;
public JMenuBar MENU_BAR;
public EJERCICIO_01()
{
super("MI MENU CON JFRAME...");
this.setSize(600,400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.ITEM_ABRIR = new JMenuItem("ABRIR");
this.ITEM_GUARDAR = new JMenuItem("GUARDAR");
this.ITEM_CERRAR = new JMenuItem("CERRAR");
this.ITEM_JAVADHC = new JMenuItem("JAVADHC");
this.MENU_ARCHIVO = new JMenu("ARCHIVO");
this.MENU_ARCHIVO.add(this.ITEM_ABRIR);
this.MENU_ARCHIVO.add(this.ITEM_GUARDAR);
this.MENU_ARCHIVO.addSeparator();
this.MENU_ARCHIVO.add(this.ITEM_CERRAR);
this.MENU_JAVA = new JMenu("JAVA");
this.MENU_JAVA.add(this.ITEM_JAVADHC);
this.MENU_BAR = new JMenuBar();
this.MENU_BAR.add(this.MENU_ARCHIVO);
this.MENU_BAR.add(this.MENU_JAVA);
this.setJMenuBar(this.MENU_BAR);
}
public static void main(String[] ARGS)
{
//-- HACEMOS QUE SE INICIALIZE NUESTRA VENTANA JFRAME
EJERCICIO_01 MI_INTERFAZ = new EJERCICIO_01();
//-- HACEMOS QUE NUESTRA VENTANA SE VISIBLE
MI_INTERFAZ.setVisible(true);
}
}
_________________________________________________________________
_________________________________________________________________
package PAQUETE_INTERFAZ_02;
/**
*
* @author Administrador
*/
import javax.swing.*;
import java.awt.*;
public class EJERCICIO_02 extends JFrame
{
public JButton BTN_MUSICA,BTN_VIDEO,BTN_INTERNET,BTN_JAVADHC,BTN_INFO;
public JToolBar CAJA_HERRAMIENTA_01,CAJA_HERRAMIENTA_02;
public ImageIcon IMG_MUSICA,IMG_VIDEO,IMG_INTERNET,IMG_JAVADHC,IMG_INFO;
public EJERCICIO_02()
{
super("MI MENU CON JFRAME...");
this.setSize(600,400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.IMG_VIDEO = new ImageIcon("IMAGENES/VIDEO.PNG");
this.IMG_MUSICA = new ImageIcon("IMAGENES/MUSICA.PNG");
this.IMG_INTERNET = new ImageIcon("IMAGENES/INTERNET.PNG");
this.IMG_JAVADHC = new ImageIcon("IMAGENES/JAVADHC.PNG");
this.IMG_INFO = new ImageIcon("IMAGENES/INFO.PNG");
this.BTN_VIDEO = new JButton("VIDEO",this.IMG_VIDEO);
this.BTN_MUSICA = new JButton("MUSICA",this.IMG_MUSICA);
this.BTN_INTERNET = new JButton("INTERNET",this.IMG_INTERNET);
this.BTN_JAVADHC = new JButton("JAVADHC",this.IMG_JAVADHC);
this.BTN_INFO = new JButton("http://javadhc.blogspot.com/",this.IMG_INFO);
this.CAJA_HERRAMIENTA_01 = new JToolBar();
this.CAJA_HERRAMIENTA_01.add(this.BTN_VIDEO);
this.CAJA_HERRAMIENTA_01.add(this.BTN_MUSICA);
this.CAJA_HERRAMIENTA_01.add(this.BTN_INTERNET);
this.CAJA_HERRAMIENTA_02 = new JToolBar();
this.CAJA_HERRAMIENTA_02.add(this.BTN_JAVADHC);
this.CAJA_HERRAMIENTA_02.add(this.BTN_INFO);
BorderLayout DISTRIBUIDOR = new BorderLayout();
this.setLayout(DISTRIBUIDOR);
this.add(this.CAJA_HERRAMIENTA_01,BorderLayout.NORTH);
this.add(this.CAJA_HERRAMIENTA_02,BorderLayout.SOUTH);
}
public static void main(String[] ARGUMENTOS)
{
EJERCICIO_02 MI_INTERFAZ = new EJERCICIO_02();
MI_INTERFAZ.setVisible(true);
}
}
_________________________________________________________________
_________________________________________________________________
EJERCICIO 3
package PAQUETE_INTERFAZ_02;
/**
*
* @author Administrador
*/
import javax.swing.*;
import java.awt.*;
public class EJERCICIO_03 extends JFrame
{
public MI_PANEL PANEL_01, PANEL_02;
public JScrollPane DESLIZADOR;
public EJERCICIO_03()
{
super("CAJAS DE TEXTO CON DESLIZADOR... JAVADHC");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String NOMBRE_CAJA_01, NOMBRE_CAJA_02;
do
{
JOptionPane.showMessageDialog(null,"SE VOLVERA A PREGUNTAR SI LOS NOMBRES ESTAN EN BLANCO");
NOMBRE_CAJA_01 = JOptionPane.showInputDialog(null,"INDIQUE EL NOMBRE DE LA CAJA DE TEXTO 01","NOMBRE DE CAJA",JOptionPane.INFORMATION_MESSAGE);
NOMBRE_CAJA_02 = JOptionPane.showInputDialog(null,"INDIQUE EL NOMBRE DE LA CAJA DE TEXTO 02","NOMBRE DE CAJA",JOptionPane.INFORMATION_MESSAGE);
}
while(NOMBRE_CAJA_01.isEmpty() || NOMBRE_CAJA_02.isEmpty());
FlowLayout DISTRIBUIDOR = new FlowLayout();
this.setLayout(DISTRIBUIDOR);
PANEL_01 = new MI_PANEL(NOMBRE_CAJA_01);
PANEL_02 = new MI_PANEL(NOMBRE_CAJA_02);
this.add(PANEL_01);
this.add(PANEL_02);
}
public static void main(String[] ARGUMENTOS)
{
EJERCICIO_03 MI_INTERFAZ = new EJERCICIO_03();
MI_INTERFAZ.pack();
MI_INTERFAZ.setVisible(true);
}
}
class MI_PANEL extends JPanel
{
public JScrollPane DESLIZADOR;
public JTextArea COMENTARIOS;
public JTextField NOMBRE_CAJA;
public MI_PANEL(String NOMBRE)
{
super();
this.NOMBRE_CAJA = new JTextField();
this.NOMBRE_CAJA.setText("CAJA " + NOMBRE);
this.NOMBRE_CAJA.setEditable(false);
this.add(this.NOMBRE_CAJA);
this.COMENTARIOS = new JTextArea(10,20);
this.COMENTARIOS.setText("ESCRIBA AQUI SUS COMENTARIOS DE SU CAJA " + NOMBRE);
this.DESLIZADOR = new JScrollPane(this.COMENTARIOS);
this.add(this.DESLIZADOR);
}
}
_________________________________________________________________
_________________________________________________________________
EJERCICIO 4
package PAQUETE_INTERFAZ_02;
/**
*
* @author Administrador
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class EJERCICIO_04 extends JFrame implements ActionListener
{
public JLabel LETRA_NUMERO_01,LETRA_NUMERO_02,LETRA_RESULTADO;
public JTextField NUMERO_01,NUMERO_02,RESULTADO;
public JButton SUMAR;
public EJERCICIO_04()
{
super("SUMA DE NUMEROS... JAVADHC");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(210,160);
this.LETRA_NUMERO_01 = new JLabel("NUMERO 01");
this.LETRA_NUMERO_02 = new JLabel("NUMERO 02");
this.LETRA_RESULTADO = new JLabel("RESULTADO");
this.NUMERO_01 = new JTextField(10);
this.NUMERO_02 = new JTextField(10);
this.RESULTADO = new JTextField(10);
this.RESULTADO.setEditable(false);
this.SUMAR = new JButton("PULSE PARA SUMAR");
this.SUMAR.addActionListener(this);
FlowLayout DISTRIBUIDOR = new FlowLayout();
this.setLayout(DISTRIBUIDOR);
this.add(this.LETRA_NUMERO_01);
this.add(this.NUMERO_01);
this.add(this.LETRA_NUMERO_02);
this.add(this.NUMERO_02);
this.add(this.SUMAR);
this.add(this.LETRA_RESULTADO);
this.add(this.RESULTADO);
}
public void actionPerformed(ActionEvent EVENTO)
{
float AUX_NUMERO_01,AUX_NUMERO_02,AUX_RESULTADO;
try
{
AUX_NUMERO_01 = Float.parseFloat(this.NUMERO_01.getText());
AUX_NUMERO_02 = Float.parseFloat(this.NUMERO_02.getText());
AUX_RESULTADO = AUX_NUMERO_01 + AUX_NUMERO_02;
this.RESULTADO.setText(String.valueOf(AUX_RESULTADO));
}
catch(Exception E)
{
this.RESULTADO.setText("ERROR AL SUMAR");
}
}
public static void main(String[] ARGUMENTOS)
{
EJERCICIO_04 MI_INTERFAZ = new EJERCICIO_04();
MI_INTERFAZ.setResizable(false);
MI_INTERFAZ.setVisible(true);
}
}
_________________________________________________________________
_________________________________________________________________
package PAQUETE_INTERFAZ_02;
/**
*
* @author Administrador
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class EJERCICIO_05 extends JFrame implements ActionListener
{
JRadioButton SUMAR,RESTAR,MULTIPLICAR,DIVIDIR;
ButtonGroup OPERACIONES;
JButton EJECUTAR_OPERACION;
JLabel LETRA_NUMERO_01,LETRA_NUMERO_02,LETRA_RESULTADO;
JTextField NUMERO_01,NUMERO_02,RESULTADO;
public EJERCICIO_05()
{
super("SUMA CON 4 OPERACIONES");
this.setSize(210,210);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.LETRA_NUMERO_01 = new JLabel("NUMERO 01");
this.LETRA_NUMERO_02 = new JLabel("NUMERO 02");
this.LETRA_RESULTADO = new JLabel("RESULTADO");
this.NUMERO_01 = new JTextField(10);
this.NUMERO_02 = new JTextField(10);
this.RESULTADO = new JTextField(10);
this.EJECUTAR_OPERACION = new JButton("EJECUTAR OPERACION");
this.EJECUTAR_OPERACION.addActionListener(this);
this.SUMAR = new JRadioButton("SUMAR",true);
this.RESTAR = new JRadioButton("RESTAR",false);
this.MULTIPLICAR = new JRadioButton("MULTIPLICAR",false);
this.DIVIDIR = new JRadioButton("DIVIDIR",false);
this.OPERACIONES = new ButtonGroup();
this.OPERACIONES.add(this.SUMAR);
this.OPERACIONES.add(this.RESTAR);
this.OPERACIONES.add(this.MULTIPLICAR);
this.OPERACIONES.add(this.DIVIDIR);
FlowLayout DISTRIBUIDOR = new FlowLayout();
this.setLayout(DISTRIBUIDOR);
this.add(this.LETRA_NUMERO_01);
this.add(this.NUMERO_01);
this.add(this.LETRA_NUMERO_02);
this.add(this.NUMERO_02);
this.add(this.SUMAR);
this.add(this.RESTAR);
this.add(this.MULTIPLICAR);
this.add(this.DIVIDIR);
this.add(this.EJECUTAR_OPERACION);
this.add(this.LETRA_RESULTADO);
this.add(this.RESULTADO);
}
public void actionPerformed(ActionEvent EVENTO)
{
float AUX_NUMERO_01,AUX_NUMERO_02,AUX_RESULTADO;
try
{
AUX_RESULTADO = 0;
AUX_NUMERO_01 = Float.parseFloat(this.NUMERO_01.getText());
AUX_NUMERO_02 = Float.parseFloat(this.NUMERO_02.getText());
if(this.SUMAR.isSelected())
{
AUX_RESULTADO = AUX_NUMERO_01 + AUX_NUMERO_02;
}
else if(this.RESTAR.isSelected())
{
AUX_RESULTADO = AUX_NUMERO_01 - AUX_NUMERO_02;
}
else if(this.MULTIPLICAR.isSelected())
{
AUX_RESULTADO = AUX_NUMERO_01 * AUX_NUMERO_02;
}
else if(this.DIVIDIR.isSelected())
{
AUX_RESULTADO = AUX_NUMERO_01 / AUX_NUMERO_02;
}
this.RESULTADO.setText(String.valueOf(AUX_RESULTADO));
}
catch(Exception E)
{
this.RESULTADO.setText("ERROR AL EJECUTAR");
}
}
public static void main(String[] ARGUMENTOS)
{
EJERCICIO_05 MI_INTERFAZ = new EJERCICIO_05();
MI_INTERFAZ.setResizable(false);
MI_INTERFAZ.setVisible(true);
}
}
_________________________________________________________________
_________________________________________________________________
package PAQUETE_INTERFAZ_02;
/**
*
* @author Administrador
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class EJERCICIO_06 extends JFrame implements ActionListener
{
public JButton VERDE,AMARILLO,ROJO;
public JPanel COLOR_PANEL;
public EJERCICIO_06()
{
super("COLORES... JAVADHC");
this.setSize(400,400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.VERDE = new JButton("VERDE");
this.VERDE.setBackground(Color.GREEN);
this.VERDE.addActionListener(this);
this.AMARILLO = new JButton("AMARILLO");
this.AMARILLO.setBackground(Color.YELLOW);
this.AMARILLO.addActionListener(this);
this.ROJO = new JButton("ROJO");
this.ROJO.setBackground(Color.RED);
this.ROJO.addActionListener(this);
this.COLOR_PANEL = new JPanel();
this.COLOR_PANEL.setPreferredSize(new Dimension(300,300));
this.COLOR_PANEL.setBackground(Color.BLACK);
FlowLayout DISTRIBUIDOR_FRAME = new FlowLayout();
this.setLayout(DISTRIBUIDOR_FRAME);
this.add(this.VERDE);
this.add(this.AMARILLO);
this.add(this.ROJO);
this.add(this.COLOR_PANEL);
}
public void actionPerformed(ActionEvent EVENTO)
{
Object BOTON_SELECCIONADO = EVENTO.getSource();
if(BOTON_SELECCIONADO == this.VERDE)
{
this.COLOR_PANEL.setBackground(Color.GREEN);
}
else if(BOTON_SELECCIONADO == this.AMARILLO)
{
this.COLOR_PANEL.setBackground(Color.YELLOW);
}
else if(BOTON_SELECCIONADO == this.ROJO)
{
this.COLOR_PANEL.setBackground(Color.RED);
}
}
public static void main(String[] ARGUMENTOS)
{
EJERCICIO_06 MI_INTERFAZ = new EJERCICIO_06();
MI_INTERFAZ.setResizable(false);
MI_INTERFAZ.setVisible(true);
}
}
No hay comentarios:
Publicar un comentario