Java - No se ve button, labels ni textfield. ¿donde esta el error?

 
Vista:
sin imagen de perfil

No se ve button, labels ni textfield. ¿donde esta el error?

Publicado por PabloVCqq (4 intervenciones) el 27/02/2014 00:06:20
Aqui esta el enunciado del problema y lo que debo desarrollar.
CAPTURA https://imageshack.com/i/m9pkloj
La dificultad es como dice el titulo, no encuentro el error en la seccion de entorno grafico. No se ve DNI_caj y DNI_Farm, tampoco el boton LIMPIAR. Por favor necesito una mano en esto y debo terminar lo antes posible. Puede ser una tonteria pero ustedes tienen saben mas del tema. Agradeceria mucho la ayuda. Adjunto el programa:
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
public class farmacity2 implements ItemListener {
 
JPanel cards; //a panel that uses CardLayout
final static String SOLAPA1 = "DueniosEmpleados";
 
 
public JTextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15 ,t16;
public JLabel etiqueta1, etiqueta2, etiqueta3, etiqueta4, etiqueta5, etiqueta6, etiqueta7, etiqueta8, etiqueta9;
public JLabel etiqueta10,etiqueta11,etiqueta12,etiqueta13,etique ta14,etiqueta15,etiqueta16,etiqueta17,etiqueta18,e tiqueta19,etiqueta20, etiqueta21;
public JButton boton0,boton1,boton2,boton3, boton4, boton5;
private String nomb, nomb_caj, nomb_farmac, descrip_prod, fecha;
private int dni, dni_c, dni_f, porc, codprod, cant;
private double sueldo_caj, sueldo_farm, precio, Sueldos_farm=0, Sueldos_cajeros=0 ;
private double ganancia_duenio, gananciaTotal=0, ganancia, sueldos, desc;
private Hashtable duenios ;
private Hashtable cajeros ;
private Hashtable farmaceuticos ;
private Hashtable productos;
private JTextArea area1;
 
 
public farmacity2(){
duenios = new Hashtable();
cajeros = new Hashtable();
farmaceuticos = new Hashtable();
productos = new Hashtable();
}
public void addComponentToPane(Container pane) {
JPanel comboBoxPane = new JPanel() ; //use FlowLayout
String comboBoxItems[] = { SOLAPA1, SOLAPA2, SOLAPA3 };
JComboBox cb = new JComboBox(comboBoxItems);
cb.setEditable(false);
cb.addItemListener(this);
cb.addActionListener(cb);
comboBoxPane.add(cb);
 
//Create the Panels
Panel PanelGeneral = new Panel(new GridLayout(4,1)) ;
 
Panel EntradadeDatos = new Panel (new GridLayout(9,1)); //3 , 1
Panel PanelNombreDuenio= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelDNI= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelPorc= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelNombreCajero= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelDNICaj= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelSueldoCajero= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelNombreFarmac= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelDNIFarmac= new Panel(new FlowLayout(FlowLayout.LEFT));
Panel PanelSueldoFarmac= new Panel(new FlowLayout(FlowLayout.LEFT));
 
JPanel card1 = new JPanel();
t1 = new JTextField("",30);
t2 = new JTextField("",15);
t3 = new JTextField("",4);
t4 = new JTextField("",30);
t5 = new JTextField("",15);
t6 = new JTextField("",6);
t7 = new JTextField("",30);
t8 = new JTextField("",15);
t9 = new JTextField("",6);
etiqueta1 = new JLabel("Nombre(Dueño):",Label.LEFT);
etiqueta2 = new JLabel("DNI(Dueño):",Label.LEFT);
etiqueta3 = new JLabel("Porc(Dueño):",Label.LEFT);
etiqueta4 = new JLabel("Nombre(Cajero):",Label.LEFT);
etiqueta5 = new JLabel("DNI(Cajero):",Label.LEFT);
etiqueta6 = new JLabel("Sueldo:",Label.LEFT);
etiqueta7 = new JLabel("Nombre(Farmac):",Label.LEFT);
etiqueta8 = new JLabel("DNI(Farmac):",Label.LEFT);
etiqueta9 = new JLabel("Sueldo(Farmac):",Label.LEFT);
EntradadeDatos.add(PanelNombreDuenio);
EntradadeDatos.add(PanelDNI);
EntradadeDatos.add(PanelPorc);
 
EntradadeDatos.add(PanelNombreCajero);
EntradadeDatos.add(PanelDNICaj);
EntradadeDatos.add(PanelSueldoCajero);
 
EntradadeDatos.add(PanelNombreFarmac);
EntradadeDatos.add(PanelDNIFarmac);
EntradadeDatos.add(PanelSueldoFarmac);
 
PanelNombreDuenio.add(etiqueta1);
PanelNombreDuenio.add(t1);
PanelDNI.add(etiqueta2);
PanelDNI.add(t2);
PanelPorc.add(etiqueta3);
PanelPorc.add(t3);
PanelNombreCajero.add(etiqueta4);
PanelNombreCajero.add(t4);
PanelDNICaj.add(etiqueta5); //*
PanelDNICaj.add(t5);
PanelSueldoCajero.add(etiqueta6);
PanelSueldoCajero.add(t6);
PanelNombreFarmac.add(etiqueta7);
PanelNombreFarmac.add(t7);
PanelDNIFarmac.add(etiqueta8); //*
PanelDNIFarmac.add(t8);
PanelSueldoFarmac.add(etiqueta9);
PanelSueldoFarmac.add(t9);
card1.add(EntradadeDatos);
PanelGeneral.add(EntradadeDatos);
card1.add(PanelGeneral);
JButton boton1 = new JButton("CARGAR DATOS");
card1.add(boton1); 

boton1.addItemListener(this); 
JButton boton0 = new JButton("LIMPIAR");
card1.add(boton0);

boton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evento) {
farmacity2 farmacia = new farmacity2();
dueño d1 = new dueño();
cajero c1 = new cajero();
farmaceutico farm1 = new farmaceutico();
producto prod1 = new producto();
venta v1 = new venta();
persona p1 = new persona();

farmacia.setFarmaceutico(farm1);
farmacia.setCajero(c1);
farmacia.setDuenio(d1);

nomb=t1.getText();
d1.setNombre(nomb);
dni=Integer.parseInt(t2.getText());
d1.setDNI(dni);
porc=Integer.parseInt(t3.getText());
d1.setPorcentaje(porc);
farmacia.AddDueños(d1); //agrega nuevo duenio 
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");

nomb_caj=t4.getText();
c1.setNombre(nomb_caj); 
dni_c=Integer.parseInt(t5.getText());
c1.setDNI(dni_c);
sueldo_caj=Double.parseDouble(t6.getText());
c1.setVentas(v1);// relacion entre cajero y una venta
c1.setSueldo(sueldo_caj);
farmacia.AddCajero(c1); //agrega nuevo cajero 
t4.setText(" ");
t5.setText(" ");
t6.setText(" ");

nomb_farmac=t7.getText();
farm1.setNombre(nomb_farmac);
dni_f=Integer.parseInt(t8.getText());
farm1.setDNI(dni_f);
sueldo_farm=Double.parseDouble(t9.getText());
farm1.setVentas(v1);// relacion entre farmaceutico y una venta
farm1.setSueldo(sueldo_farm);
farmacia.AddFarmaceutico(farm1);//agrega nuevo farmaceutico
t7.setText(" ");
t8.setText(" ");
t9.setText(" "); 
}});

boton0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evento) {
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");
t5.setText(" ");
t6.setText(" ");
t7.setText(" ");
t8.setText(" ");
t9.setText(" ");
t10.setText(" ");
t11.setText(" ");
t12.setText(" ");
t13.setText(" ");
t14.setText(" ");
t15.setText(" ");
t16.setText(" "); 
}});

public void itemStateChanged(ItemEvent evt) {

CardLayout cl = (CardLayout)(cards.getLayout());
cl.show(cards, (String)evt.getItem());
} 

private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("CardLayoutDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
//frame.setSize(600,600); 
//Create and set up the content pane.
farmacity2 farmacia = new farmacity2();
farmacia.addComponentToPane(frame.getContentPane() );
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) { /* Use an appropriate Look and Feel */
try{//UIManager.setLookAndFeel("com.sun.java.swing.plaf. windows.WindowsLookAndFeel");
UIManager.setLookAndFeel("javax.swing.plaf.metal.M etalLookAndFeel");
} catch (UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
} catch (IllegalAccessException ex) {
ex.printStackTrace();
} catch (InstantiationException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} /* Turn off metal's use of bold fonts */
UIManager.put("swing.boldMetal", Boolean.FALSE);
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
} 
public void setFarmaceutico(farmaceutico f){
farmaceutico farm1 = f;
}
public farmaceutico getFarmaceutico(farmaceutico f){
farmaceutico farm1 = null; 
return farm1; 
}
public void setCajero(cajero c){
cajero c1 = c;
}
public cajero getCajero(cajero c){
cajero c1 = null; 
return c1; 
}
public void setDuenio(dueño d){
dueño d1 = d;
}
public dueño getDuenio(dueño c){
dueño d1 = null; 
return d1; 
} 

}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Jhonnathan Emilio Cardona Saineda

No se ve button, labels ni textfield. ¿donde esta el error?

Publicado por Jhonnathan Emilio Cardona Saineda (328 intervenciones) el 27/02/2014 17:47:32
HOla
Es duro saber porque te faltan clases por mostrar, por ejemplo la siguiente que al parecer es parte de GUI
1
2
3
4
farmacity2 farmacia = new farmacity2();
farmacia.addComponentToPane(frame.getContentPane() );
frame.pack();
frame.setVisible(true);
saludos,
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

No se ve button, labels ni textfield. ¿donde esta el error?

Publicado por PabloVCqq (4 intervenciones) el 27/02/2014 22:50:45
ACA ESTAN LAS CLASES:


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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import java.util.Hashtable;
public class farmaceutico extends persona{
 
	private static double sueldo;
	private String matricula;
	private Hashtable ventas ;
	private venta venta1;//probar si funciona
 
	public farmaceutico(){
		ventas = new Hashtable();
	}
 
	public static double getSueldo() {
		return sueldo;
	}
	public void setSueldo(double s){
		sueldo=s;
	}
 
	public String getMatricula() {
		return matricula;
	}
	public void setMatricula(String m){
		matricula=m;
	}
	//METODOS PARA AGREGAR Y SACAR UNA VENTA - CON INTERFAZ GRAFICA
	public void AddVenta(venta v){
		ventas.put(v.getNro_Fact(), v);
	}
	public venta GetVenta(int numero){
		return (venta) ventas.get(numero);
	}
	//METODOS PARA AGREGAR Y SACAR UNA VENTA - SIN INTERFAZ GRAFICA
	public void setVentas(venta v){
		venta1 =v;
	}
	public venta getVentas(venta v){
		return venta1;
	}
}
 
===================
import java.util.Hashtable;
 
 
public class cajero extends persona{
 
	private static double sueldo;
    private Hashtable ventas ;
    private venta venta1;//probar si funciona
 
	public cajero(){
		ventas = new Hashtable();
	}
	public static double getSueldo() {
		return sueldo;
	}
	public void setSueldo(double s){
		sueldo=s;
	}
	public void setVentas(venta v){
		venta1 =v;
	}
	public venta getVentas(venta v){
		return venta1;
	}
}
===================
public class dueño extends persona{
 
	private double porcentaje;
 
 
	public double getPorcentaje() {
		return porcentaje;
	}
	public void setPorcentaje(double n){
		porcentaje=n;
	}
 
}
===================
import java.util.Hashtable;
import java.util.Enumeration;
 
 
public class persona {
 
	private int dni;
	private String Nombre;
	private String Apellido;
 
	public int getDNI() {
		return dni;
	}
	public void setDNI(int nro){
		dni=nro;
	}
	public String getNombre () {
		return Nombre;
	}
	public void setNombre(String n){
		Nombre=n;
	}
	public String getApellido() {
		return Apellido;
	}
	public void setApellido(String ap){
		Apellido=ap;
	}
}
===================
import java.util.Hashtable;
public class producto {
 
	private int codigo;
	private String nombre_medicamento;
	private double precio;
	private Hashtable ventas ;
	private venta venta1;//probar 
 
	public producto(){
		ventas = new Hashtable();
	}
 
	public int getCodigo() {
		return codigo;
	}
	public void setCodigo(int n){
		codigo=n;
	}
	public String getNombre_Medicamento() {
		return nombre_medicamento;
	}
	public void setNombre_Medicamento(String nomb){
		nombre_medicamento=nomb;
	}
	public double getPrecio() {
		return precio;
	}
	public void setPrecio(double costo){
		precio=costo;
	}
	//METODOS PARA AGREGAR Y SACAR UNA VENTA - CON INTERFAZ GRAFICA
	public void AddVenta(venta v){
			ventas.put(v.getNro_Fact(), v);
	}
	public venta GetVenta(int numero){
			return (venta) ventas.get(numero);
	}
	//METODOS PARA AGREGAR Y SACAR UNA VENTA - SIN INTERFAZ GRAFICA
		public void setVentas(venta v){
			venta1 =v;
	}
	public venta getVentas(venta v){
			return venta1;
	}
}
===============
import java.util.Hashtable;
public class venta {
 
	private int nro_fact;
	private String fecha;
	private int cantidad;
	//producto prod1;
 
	public int getNro_Fact() {
		return nro_fact;
	}
	public void setNro_Fact(int f){
		nro_fact=f;
	}
 
	public String getFecha() {
		return fecha;
	}
	public void setFecha(String f){
		fecha=f;
	}
	public int getCantidad(){
		return cantidad;
	}
	public void setCantidad(int c){
		cantidad=c;
	}
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

No se ve button, labels ni textfield. ¿donde esta el error?

Publicado por pablovqq (4 intervenciones) el 27/02/2014 23:45:28
AQUI ADJUNTO TODOS LOS ARCHIVOS. EL CODIGO COMPLETO. USO ECLIPSE.

SI, usé GUI. ¿faltan clases de eso?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

No se ve button, labels ni textfield. ¿donde esta el error?

Publicado por PabloVCqq (4 intervenciones) el 28/02/2014 01:43:46
me comentan que debo instalar un plugin jigloo para eclipse, para detectar errores en GUI. Copié los archivos del plugin a la carpeta de Eclipse SDK y no aparece nada. Leí es que tiene problemas con Emclipse version 3. ( ver FAQ - http://www.cloudgarden.com/jigloo/faq.html#help3 )

Actualmente uso Eclipse SDK 3.7 (indigo) y no encuentro para esa versión, solo encontre entre 3.0 a 3.5.

Tambien tengo Eclipse Juno.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar