Sei sulla pagina 1di 19

Introduccin a la Ingeniera de Software

Unidad 2. Componentes Grficos

Universidad Abierta y a Distancia de Mxico

Ingeniera en Desarrollo de Software

Programacin Orientada a Objetos II (POOII)

Actividad 3. Mens y Ventanas

Evidencia de aprendizaje: Eventos de JAVA

Hugo Cesar Flores Ortiz

Facilitador: Christian Leonel Ortiz Islas Snchez

Grupos Separados: DS-DP02-1403C-001

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos

Ahora que aprendiste todas las caractersticas de funcionamiento para los mens y
ventanas, ests listo(a) para realizar las siguientes instrucciones.
Propsito: Construir mens y ventanas grficas, as como identificar su declaracin e
implementar su manipulacin.
Instrucciones:
1. Identifica los diferentes tipos de mens y ventanas grficas vistas en el desarrollo
de la unidad.
2. Identifica su estructura algortmica (pasos) y sintctica (cdigo).
3. Crea un proyecto en NetBeans, que contenga un programa donde apliques todos
los contenedores y controles identificados en los puntos 1 y 2.

Mens y Ventanas
Representacin del cdigo
Bloque azul:
Contiene la declaracin del paquete, el autor, la clase, definicin del autor y las llaves
correspondientes. Inicializo de componentes.
Bloque Oliva:
Se crea la nueva form para la Barra de Menu, inicializando los componentes. Con la
propiedad de maximizar la venta de principal. Inicializa los componentes que se est
creando el mens, subItems, separador, etc.
Bloque amarillo:
Declaracin de todos los componentes grficos que se estarn utilizando en el programa,
estas declaraciones estn fuera de todos los mtodos, lo que significa que estn
declarados a nivel de clase, con la intencin de poder manipular cada uno de los
componentes grficos desde cualquier parte de la clase. Creando el mens y submens
con respetivamente propiedades
Bloque rojo:
Mtodo principal de cada uno de los submens en el cual cada una tiene una accin. En
el mtodo actionPerformed() del java swing, que sirve para decir qu hacer cuando se
pulse un botn o algo.

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos

Bloque Turquesa:
Declaracin de las variables, de los controles utilizados.
Bloque Verde:
Con esta clase se implementara el escuchador ActionListener , que ser con el que se
detectaran las acciones en el Men de cuadros de mensajes.
Segn la opcin seleccionada en el men.
Este mtodo es para la creacin de la ventana de cuadros de dialogo de mensajes.
Primero se crean las variables que funcionaran como elementos del men y el objeto rea
de texto donde ira la descripcin de cada cuadro de dialogo.
Despus se agregan los elementos del men a la ventana con su respectivo escuchador.
Por ltimo se definen las caractersticas de la ventana y se ocupa un escuchador de
ventana para que al cerrar la ventana, esta se cierre y se vuelve a ejecutar el mtodo
Principal();.
Bloque Morado: Servir para crear una ventana donde se realizara un men emergente
de manera representativa. Primero se crea la ventana y se especifican sus
caractersticas dentro de las cuales se agrega un escuchador de ventana para que
al dar clic en el icono de cerrar de la ventana, esta se cierre y se vuelva a ejecutar
el mtodo Principal();.
A continuacin se crea el men emergente y sus submens, los cuales despus se
agregan al men principal.
Por ltimo se agrega al men emergente a la ventana.
Bloque Rosa: Dentro del void main es donde se escriben las lneas que son las que
permiten el funcionamiento del programa, la primera crea un objeto de la clase
VentanasMenu, que es la clase que se describi antes, donde se crea toda la apariencia y
funcionalidad del programa. La segunda lnea invoca el mtodo principal(); del objeto
previamente creado, y realizando esta llamada se crea el programa.
package Menu;
/**
*
* autor : Hugo Cesar Flores Ortiz

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
* Barra de menu
* 22 de noviembre 2014
* Importa las librerias
*/
import java.io.File;
import javax.swing.*;
import javax.swing.JFrame;

public class BarradeMenu extends javax.swing.JFrame {

/**
* crea la nueva form para BarradeMenu
*/
public BarradeMenu() {
initComponents();
//MAximizar el formulario en ambos sentidos
this.setExtendedState(this.MAXIMIZED_BOTH);
}

/**
* Este mtodo es llamado desde dentro del constructor para inicializar el formulario..
* Inicializa los componentes
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPopupMenu2 = new javax.swing.JPopupMenu();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
jSeparator3 = new javax.swing.JPopupMenu.Separator();
jMenuItem9 = new javax.swing.JMenuItem();
jSeparator4 = new javax.swing.JPopupMenu.Separator();
jMenu4 = new javax.swing.JMenu();

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMIGuardar = new javax.swing.JMenuItem();
jMIGuardarComo = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
jMenu3 = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMIEmergente = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
jMenuItem5 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem10 = new javax.swing.JMenuItem();
jMenu5 = new javax.swing.JMenu();
jMIError = new javax.swing.JMenuItem();
MIInformacion = new javax.swing.JMenuItem();
MIConfirmacion = new javax.swing.JMenuItem();
MITripleOpcion = new javax.swing.JMenuItem();
MILecturaDato = new javax.swing.JMenuItem();
jMISeleccion = new javax.swing.JMenuItem();
jMenuItem8.setText("Minisculas");
jPopupMenu2.add(jMenuItem8);
jMenuItem7.setText("jMenuItem7");
jPopupMenu2.add(jMenuItem7);
jPopupMenu2.add(jSeparator3);
jMenuItem9.setText("jMenuItem9");
jPopupMenu2.add(jMenuItem9);
jPopupMenu2.add(jSeparator4);
jMenu4.setText("jMenu4");
jCheckBoxMenuItem1.setSelected(true);

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");
jMenu4.add(jCheckBoxMenuItem1);
jCheckBoxMenuItem2.setSelected(true);
jCheckBoxMenuItem2.setText("jCheckBoxMenuItem2");
jMenu4.add(jCheckBoxMenuItem2);
jPopupMenu2.add(jMenu4);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Menu y Ventanas");
jMenu1.setBackground(new java.awt.Color(0, 51, 255));
jMenu1.setText("Archivo");
jMIGuardar.setText("Guardar");
jMIGuardar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMIGuardarActionPerformed(evt);
}
});
jMenu1.add(jMIGuardar);
jMIGuardarComo.setText("Guardar como...");
jMIGuardarComo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMIGuardarComoActionPerformed(evt);
}
});
jMenu1.add(jMIGuardarComo);
jMenu1.add(jSeparator1);
jMenu3.setText("Tipo Letra");
jMenuItem3.setText("Tahoma");
jMenu3.add(jMenuItem3);
jMenuItem4.setText("Arial");
jMenu3.add(jMenuItem4);
jMenu1.add(jMenu3);
jMIEmergente.setText("Menu Emergente");
jMIEmergente.addActionListener(new java.awt.event.ActionListener() {

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMIEmergenteActionPerformed(evt);
}
});
jMenu1.add(jMIEmergente);
jMenu1.add(jSeparator2);
jMenuItem5.setText("Cerrar");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem5);
jMenuBar1.add(jMenu1);
jMenu2.setBackground(new java.awt.Color(0, 0, 204));
jMenu2.setText("Editar");
jMenuItem6.setText("Mostrar");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem6);
jMenuItem10.setText("Capturar Datos");
jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem10ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem10);
jMenuBar1.add(jMenu2);
jMenu5.setText("Ventanas Dialogo");
jMIError.setText("Mensaje de Error");

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
jMIError.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMIErrorActionPerformed(evt);
}
});
jMenu5.add(jMIError);
MIInformacion.setText("Mensaje de Informacin");
MIInformacion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MIInformacionActionPerformed(evt);
}
});
jMenu5.add(MIInformacion);
MIConfirmacion.setText("Mensaje de Confirmacin");
MIConfirmacion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MIConfirmacionActionPerformed(evt);
}
});
jMenu5.add(MIConfirmacion);

MITripleOpcion.setText("Mensaje Triple Opcion");


MITripleOpcion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MITripleOpcionActionPerformed(evt);
}
});
jMenu5.add(MITripleOpcion);
MILecturaDato.setText("Lectura de Dato");
MILecturaDato.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MILecturaDatoActionPerformed(evt);
}

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
});
jMenu5.add(MILecturaDato);
jMISeleccion.setText("Mensaje Seleccin");
jMISeleccion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMISeleccionActionPerformed(evt);
}
});
jMenu5.add(jMISeleccion);
jMenuBar1.add(jMenu5);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 518, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 363, Short.MAX_VALUE)
);
pack();
}// </editor-fold>

private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {


// Salir del siste,ma
System.exit(0);
}

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {


// Invoca una ventana de dialogo de Bienvenido
JOptionPane.showMessageDialog(null,"Bienvenido");
}

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos

private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {


// Invoca un JDialog de captura de dialogo y se le aSigna sus propiedades
JDCapturarDatos cd=new JDCapturarDatos(this, rootPaneCheckingEnabled);
cd.setLocation(500, 250);
cd.setLocationRelativeTo(null);
cd.setVisible(true);
cd.setSize(300, 300);
}

private void jMIErrorActionPerformed(java.awt.event.ActionEvent evt) {


// Mensaje de error
JOptionPane.showOptionDialog(this, "Este es el Texto del Cuerpo", "Este es el Ttulo",
JOptionPane.ERROR_MESSAGE, JOptionPane.ERROR_MESSAGE, null, new Object[]{" Cancelar "},"Cancelar");
}

private void MILecturaDatoActionPerformed(java.awt.event.ActionEvent evt) {


// Lectura de datos
String miValorIngresado=JOptionPane.showInputDialog("Ingrese un valor");
JOptionPane.showMessageDialog(this, miValorIngresado);
}

private void MIConfirmacionActionPerformed(java.awt.event.ActionEvent evt) {


// Mensaje de Confirmacion
if(JOptionPane.showOptionDialog(this,
"Este
es
el
Texto
del
Cuerpo",
"Este
es
el
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[]{" SI "," NO "},"NO")==0)

Ttulo",

{
JOptionPane.showMessageDialog(this, "La respuesta fue - SI");
}
else
{
JOptionPane.showMessageDialog(this, "La respuesta fue - NO");
}

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

10

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
}

private void MITripleOpcionActionPerformed(java.awt.event.ActionEvent evt) {


// Opcin
switch(JOptionPane.showOptionDialog(this, "Este es el Texto del Cuerpo", "Este es el Ttulo",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[]{" SI "," NO "," Cancelar
"},"0"))
{
case 0:
JOptionPane.showMessageDialog(this, "SI");
break;
case 1:
JOptionPane.showMessageDialog(this, "NO");
break;
case 2:
JOptionPane.showMessageDialog(this, "Cancelar");
break;

default:
JOptionPane.showMessageDialog(this, "No se eligi ninguna opcin");
break;
}
}

private void MIInformacionActionPerformed(java.awt.event.ActionEvent evt) {


// Mensaje de INformacion
JOptionPane.showOptionDialog(this, "Este es el Texto del Cuerpo", "Este es el Ttulo",
JOptionPane.INFORMATION_MESSAGE,
JOptionPane.INFORMATION_MESSAGE, null, new Object[]{" OK "},"OK");
}

private void jMISeleccionActionPerformed(java.awt.event.ActionEvent evt) {


String[] carreras = {
"Ingeniera en sistemas computacionales",

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

11

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
"Ingeniera industrial",
"Ingeniera en mecatrnica",
"Ingeniera en informatica",
"Ingeniera petroqumica"
};
String resp = (String)
JOptionPane.showInputDialog(null, "Seleccione una carrera a cursar", "Carrera",
JOptionPane.DEFAULT_OPTION, null, carreras, carreras[0]);
System.out.println("El usuario ha elegido "+resp);
JOptionPane.showMessageDialog(this, "El usuario ha elegido "+resp);
}

private void jMIGuardarActionPerformed(java.awt.event.ActionEvent evt) {


//Invoca la ventana de guardar
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Guardar");
int userSelection = fileChooser.showSaveDialog(parentFrame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = fileChooser.getSelectedFile();
System.out.println("Save as file: " + fileToSave.getAbsolutePath());
}
}

private void jMIGuardarComoActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:JFrame parentFrame = new JFrame();
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Guardar");
int userSelection = fileChooser.showSaveDialog(parentFrame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = fileChooser.getSelectedFile();
System.out.println("Save as file: " + fileToSave.getAbsolutePath());

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

12

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
}
}
private void jMIEmergenteActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Emergente me=new Emergente(this, rootPaneCheckingEnabled);
me.setLocation(500, 250);
me.setLocationRelativeTo(null);
me.setVisible(true);
me.setSize(300, 300);
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(BarradeMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(BarradeMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(BarradeMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(BarradeMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

13

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
public void run() {
new BarradeMenu().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JMenuItem MIConfirmacion;
private javax.swing.JMenuItem MIInformacion;
private javax.swing.JMenuItem MILecturaDato;
private javax.swing.JMenuItem MITripleOpcion;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;
private javax.swing.JMenuItem jMIEmergente;
private javax.swing.JMenuItem jMIError;
private javax.swing.JMenuItem jMIGuardar;
private javax.swing.JMenuItem jMIGuardarComo;
private javax.swing.JMenuItem jMISeleccion;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPopupMenu jPopupMenu2;

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

14

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JPopupMenu.Separator jSeparator3;
private javax.swing.JPopupMenu.Separator jSeparator4;
// End of variables declaration
}

package Menu;
import java.awt.Font;

/**
*Hugo Cesar Flores Ortiz
* Ventana emergente
* 22 de noviembre
*/
public class Emergente extends javax.swing.JDialog {

/**
* Creates new form Emergente
*/
public Emergente(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

15

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos

memer = new javax.swing.JPopupMenu();


Arial = new javax.swing.JMenuItem();
Tahoma = new javax.swing.JMenuItem();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();

Arial.setText("Arial");
Arial.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ArialActionPerformed(evt);
}
});
memer.add(Arial);

Tahoma.setText("Tahoma");
Tahoma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TahomaActionPerformed(evt);
}
});
memer.add(Tahoma);

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jTextArea1.setText("Este es una prueba de menu emergente");
jTextArea1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTextArea1MouseClicked(evt);
}
});

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

16

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
jScrollPane1.setViewportView(jTextArea1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
.addContainerGap())
);

pack();
}// </editor-fold>

private void ArialActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
Font f;
f = new Font("Arial", Font.ITALIC, 16);
jTextArea1.setFont(f);

private void jTextArea1MouseClicked(java.awt.event.MouseEvent evt) {


// TODO add your handling code here:
memer.show(this, evt.getX(),evt.getY());

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

17

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
}

private void TahomaActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
Font f;
f = new Font("Tahoma", Font.BOLD, 16);
jTextArea1.setFont(f);
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Emergente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Emergente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Emergente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Emergente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

18

Introduccin a la Ingeniera de Software


Unidad 2. Componentes Grficos
}
//</editor-fold>

/* Create and display the dialog */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Emergente dialog = new Emergente(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem Arial;
private javax.swing.JMenuItem Tahoma;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JPopupMenu memer;
// End of variables declaration
}

Ciencias Exactas, Ingenieras y Tecnologa | Ingeniera en Desarrollo de Software

19

Potrebbero piacerti anche