Código de Java - Cuadro de dialogo Acerca de...

Versión 1
estrellaestrellaestrellaestrellaestrella(6)

Publicado el 4 de Marzo del 2002gráfica de visualizaciones de la versión: Versión 1
45.066 visualizaciones desde el 4 de Marzo del 2002
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* LA SIGUIENTE APLICACION EN JAVA, MUESTRA UNA VENTANA CON JAVA - SWING,
   TIENE UN MENU Y MUESTRA COMO IMPLEMENTAR UNA CLASE PROPIA QUE
   HEREDE DE LA CLASE JDialog (TAMBIEN DE JAVA - SWING) PARA CREAR UN
   DIALOGO ACERCA DE...
*/
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
//PRIMERO CREAMOS UNA CLASE QUE HERE DE LA CLASE JDialog
class Dialogo extends JDialog{
	//AHORA CREAMOS LOS COMPONENTES QUE NECESITAMOS
	JLabel programa = new JLabel("Mi Programa en JAVA", JLabel.CENTER);
	JLabel autor = new JLabel("DESARROLLADO POR: Jose Miguel Galea Yrausquin", JLabel.CENTER);
	JLabel derechos = new JLabel("2002, Derechos Reservados", JLabel.CENTER);
 
	JButton aceptar = new JButton("Aceptar");
 
	//AHORA HACEMOS LOS PANELES QUE NECESITAMOS PARA ACOMODAR NUESTROS COMPONENTES
	JPanel principal = new JPanel(new BorderLayout());
	JPanel info = new JPanel(new GridLayout(3, 1));
	JPanel boton = new JPanel(new FlowLayout());
 
 
	//CONSTRUCTOR DE LA CLASE
	public Dialogo(){
		super(new Frame(), "Acerca de...", true);
 
		//AGREGAMOS AL PANEL info, LAS TRES ETIQUETAS QUE CREAMOS
		info.add(programa);
		info.add(autor);
		info.add(derechos);
 
		//AGREGAMOS AL PANEL boton, EL BOTON QUE CREAMOS
		boton.add(aceptar);
 
		//AHORA AGREGAMOS AL PANEL principal, LOS PANELES info, boton
		//QUE A SU VEZ CONTIENEN A TODOS LOS COMPONENTES
		principal.add("Center", info);
		principal.add("South", boton);
 
		//AGREGAMOS EL PANEL PRINCIPAL AL CUADRO DE DIALOGO
		getContentPane().add(principal);
 
		//ACOMODAMOS EL TAMA¥O DEL DIALOGO DE ACUERDO AL NUMERO DE COMPONENTES QUE TIENE
		pack();
 
		//INDICAMOS QUE NO PUEDAN CAMBIAR EL TAMA¥O DEL DIALOGO CON EL MOUSE
		setResizable(false);
 
		//CENTRAMOS EL DIALOGO EN LA PANTALLA
		Dimension pantalla, cuadro;
		pantalla = Toolkit.getDefaultToolkit().getScreenSize();
		cuadro = this.getSize();
 
		this.setLocation(((pantalla.width - cuadro.width)/2), (pantalla.height - cuadro.height)/2);
 
 
		//LE AGREGAMOS EL EVENTO AL BOTON
		aceptar.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent evt){
				dispose();
			}
		});
 
	}//FIN DEL CONSTRUCTOR DE LA CLASE Dialogo
 
}//FIN DE LA CLASE Dialogo
 
 
 
 
 
public class Ventana extends JFrame{
	//CREAMOS LA BARRA QUE CONTENDRA EL MENU
	JMenuBar barra = new JMenuBar();
 
	//CREAMOS EL MENU Y SUS OPCIONES
	JMenu programa = new JMenu("Programa");
	JMenuItem acerca = new JMenuItem("Acerca de...");
	JMenuItem salir = new JMenuItem("Salir");
 
	Ventana(){
		//LE COLOCAMOS UN NOMBRE A LA VENTANA
		super("Ventana en JAVA - SWING");
 
		//AGREGAMOS LA BARRA DE MENUS, JUNTO CON SUS MENUS Y OPCIONES
		setJMenuBar(barra);
		barra.add(programa);
 
		programa.add(acerca);
		programa.addSeparator();
		programa.add(salir);
 
		//ESTABLECEMOS EL ACCESO DIRECTO (Mediante ALT + (tecla)) PARA EL MENU Programa
		programa.setMnemonic('P'); //ALT + P
 
		//ESTABLECEMOS EL TAMA¥O DE LA VENTANA
		this.setSize(500, 500);
 
		setResizable(false);
 
		//AHORA CENTRAMOS LA VENTANA EN LA PANTALLA
		Dimension pantalla, cuadro;
		pantalla = Toolkit.getDefaultToolkit().getScreenSize();
		cuadro = this.getSize();
		this.setLocation(((pantalla.width - cuadro.width)/2), (pantalla.height - cuadro.height)/2);
 
		//LE COLOCAMOS TOOLTIPS A LAS OPCIONES DEL MENU
		acerca.setToolTipText("Muestra un Dialogo Acerca de...");
		salir.setToolTipText("Sale del Programa");
 
		//AHORA LE AGREGAMOS LOS EVENTOS A LAS OPCIONES DEL MENU
 
		//PRIMERO A LA OPCION QUE MUESTRA EL CUADRO DE DIALOGO Acerca de...
		acerca.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent evt){
				//INSTANCIAMOS LA CLASE QUE CREAMOS LLAMADA Dialogo
				Dialogo d = new Dialogo();
				//MOSTRAMOS ESE DIALOGO
				d.show();
			}
		});
 
		//AHORA EL EVENTO DE LA OPCION Salir
		salir.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent evt){
			System.exit(0);
			}
		});
 
	}//FIN DEL CONSTRUCTOR DE LA CLASE Ventana
 
	//PROCEDIMIENTO PRINCIPAL
	public static void main(String g[]){
	Ventana p = new Ventana();
		p.show();
 
		//EL SIGUIENTE CODIGO PERMITE CERRAR LA VENTANA
		p.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent evt){
				System.exit(0);
			}
		});
	}//FIN DEL PROCEDIMIENTO PRINCIPAL
 
}//FIN DE LA CLASE Ventana



Comentarios sobre la versión: Versión 1 (6)

29 de Octubre del 2002
estrellaestrellaestrellaestrellaestrella
El código está bien planteado, me sirvió de mucho.
Responder
6 de Mayo del 2003
estrellaestrellaestrellaestrellaestrella
Q codigo Tan ridiculo... para hacer eso no se necesita ni conceptos de desarrollo... publiquemos cosas q valgan la pena... q al menos pongan a pensar a alguien...
Responder
22 de Febrero del 2004
estrellaestrellaestrellaestrellaestrella
No todos somos expertos.
Para los que empezamos de cero viene muy bien.
Responder
6 de Julio del 2005
estrellaestrellaestrellaestrellaestrella
Estoy comenzando...me han servido tus ejemplos...
Responder
26 de Mayo del 2006
estrellaestrellaestrellaestrellaestrella
que tal, estoy iniciandome en el mundo de programacion, estoy en el 3er semestre y me estan pidiendo realuizar un editor grafico de figuras geometricas para niños de educacion basica, no tengo la menor idea de como programarlo. seria tan amable de poder prestarme su ayuda para realizar tal programa. es urgaente voy a raspar por favor.
Responder
22 de Junio del 2007
estrellaestrellaestrellaestrellaestrella
Gracias por la explicación, ya he cogido ideas de tu código!!!
Responder

Comentar la versión: Versión 1

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s138