Java - AYUDA CON JAVA (EN ECLIPSE) PORFAVOOORR!

 
Vista:
sin imagen de perfil

AYUDA CON JAVA (EN ECLIPSE) PORFAVOOORR!

Publicado por Bastián (2 intervenciones) el 03/11/2015 21:40:46
Hola amigo, me encuentro en una problemática..

por favor que alguien me ayude, tengo examen mañana!

Necesito hacer esto:

Realice un formulario para la compra de menús. Existen 3 menús, cada uno con diferentes valores; menú 1 tiene un valor de $1.000, menú 2 tiene un valor de $2.000 y menú 2 tiene un valor de $3.000. Asigne estos valores a variables.
El cliente puede cancelar con tarjeta o en efectivo, si cancela en efectivo tiene un descuento de un 10%.
El funcionamiento es el siguiente; se debe seleccionar uno o varios menús, en el JTextArea aparecerá el subtotal mientras se van seleccionando los menús.
Si cancela en efectivo deberá digitar en el JTextField "Paga Con" con cuánto dinero cancelará.
Luego click en el JCheckBox "Efectivo" y deberá aparecer el valor final a cancelar y de cuánto fue el vuelto.
Si cancela con tarjeta no posee descuento.

ADJUNTO DOCUMENTO CON EL PROBLEMA MÁS GRÁFICO

LLevo esto y no me deja compilar:

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
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
 
 
public class menu extends JFrame implements ActionListener, ListSelectionListener{
 
	private JButton boton;
	private JList lista; //
	private JLabel etiqueta1; //
	private JLabel etiqueta2; //
	private JLabel etiqueta3;
	private JTextField txtNro1;
	private JTextField txtNro2;
	private JTextField txtNro3;
	private JCheckBox cbox1;
	private JCheckBox cbox2;
	private JTextArea tarea;
	private JLabel plata;
	private JLabel pagacon;
	private JLabel vuelto;
 
	private int pmenu1=1000;
	private int pmenu2=2000;
	private int pmenu3=3000;
	private Container c;
 
	public menu(){
		setTitle("Menú Restaurant");
		setSize(700,500);
		initcomponentes();}
 
 
 
		private void valueChanged1(ListSelectionEvent e) {
			valueChanged1(null);
			if(e.getValueIsAdjusting());
	}
 
 
 
 
	private void initcomponentes() {
		getContentPane().setLayout(null);
 
		cbox1 = new JCheckBox();
		getContentPane().add(cbox1);
		cbox1.setBounds(110, 20, 20, 20);
 
		cbox2 = new JCheckBox();
		getContentPane().add(cbox2);
		cbox2.setBounds(10, 20, 20, 20);
 
		etiqueta1 = new JLabel("Efectivo");
		getContentPane().add(etiqueta1);
		etiqueta1.setBounds(50, 20, 100, 20);
 
		etiqueta2 = new JLabel("Tarjeta");
		getContentPane().add(etiqueta2);
		etiqueta2.setBounds(150, 20, 100, 20);
 
		String[] datos= {"   MENU 1", "   MENU 2", "   MENU 3"};
		lista = new JList(datos);
	//	c.add(lista);
 
 
		getContentPane().add(lista);
		lista.setBounds(20, 100, 100, 100);
 
		tarea = new JTextArea();
		getContentPane().add(tarea);
		tarea.setBounds(150, 100, 100, 100);
 
		plata = new JLabel(" $ ");
		getContentPane().add(plata);
		plata.setBounds(300, 105, 50, 50);
 
		txtNro1 = new JTextField();
		getContentPane().add(txtNro1);
		txtNro1.setBounds(320, 120, 100, 20);
 
		pagacon = new JLabel(" Paga con $ ");
		getContentPane().add(pagacon);
		pagacon.setBounds(450, 100, 150, 50);
 
		txtNro2 = new JTextField();
		getContentPane().add(txtNro2);
		txtNro2.setBounds(530, 115, 100, 20);
 
		vuelto = new JLabel(" Vuelto       $ ");
		getContentPane().add(vuelto);
		vuelto.setBounds(450, 150, 150, 50);
 
		txtNro3 = new JTextField();
		getContentPane().add(txtNro3);
		txtNro3.setBounds(530, 165, 100, 20);
 
		boton = new JButton();
		boton.setText("Ir al otro JFrame");
		getContentPane().add(boton);
		boton.setBounds(500, 250, 150, 30);
 
		boton.addActionListener(this);
		lista.addListSelectionListener(this);
	}
 
 
 
	public static void main(String[] args) {
		new menu().setVisible(true);
 
	}
 
 
 
	@Override
	public void actionPerformed(ActionEvent arg0) {
		double neto = 0, preciofinal= 0;
		String opt=opciones.getSelectedItem().toString();
		if (){
 
		}
	}
 
 
	@Override
	public void valueChanged(ListSelectionEvent e) {
		if(e.getValueIsAdjusting()){
		}
		else
			if(e.getSource()==lista){
				if(lista.getSelectedIndex()==0){
 
				}
			}
 
	}
 
}

123123123123123
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

AYUDA CON JAVA (EN ECLIPSE) PORFAVOOORR!

Publicado por Renzo (232 intervenciones) el 03/11/2015 21:55:25
Hola, no te compila por esto:

1.
String opt=opciones.getSelectedItem().toString();

"opciones" no esta definida. Supongo que quieres acceder a la lista, si es así debería poner lista.getSel.....


2.

if (){

}

No puede dejar vacia la condición del IF.

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

AYUDA CON JAVA (EN ECLIPSE) PORFAVOOORR!

Publicado por Bastián (2 intervenciones) el 03/11/2015 21:59:50
Renzo te agradezco la buena voluntad de responder.

Si entiendo que hay problemas ahí, por eso los tengo como comentario //

No se que hacer, que harías tú?
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

AYUDA CON JAVA (EN ECLIPSE) PORFAVOOORR!

Publicado por Renzo (232 intervenciones) el 03/11/2015 22:21:17
Hola
si desea obtener el valor elegido de la lista usa esto:


String opt = lista.getModel().getElementAt(lista.getSelectedIndex())


En el if no que deseas comparar. No he leido todo el programa, no se que deseas hacer.

Saludos

Renzo

www.imagineanddo.com
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