Código de Java - MenuCena

sin imagen de perfil
Val: 62
Ha disminuido 1 puesto en Java (en relación al último mes)
Gráfica de Java

MenuCenagráfica de visualizaciones


Java

Actualizado el 25 de Diciembre del 2018 por Jose Miguel (9 códigos) (Publicado el 2 de Octubre del 2018)
3.997 visualizaciones desde el 2 de Octubre del 2018
Esta aplicación realizada en Java es un Menú de Cena que viene a ser un pequeño TPV de los cajeros que hay en Restaurantes,Cafeterías,etc.

Es una aplicación muy intuitiva y fácil de manejar.

Faltaría por desarrollar nuevas versiones

Menu-Cena

Requerimientos

Es necesario instalar Eclipse Neon.2 Release (4.6.2)

Versión 1.0

Publicado el 2 de Octubre del 2018gráfica de visualizaciones de la versión: Versión 1.0
1.365 visualizaciones desde el 2 de Octubre del 2018
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
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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.text.*;
 
public class MenuCena extends JFrame implements ItemListener, ActionListener
{
	String platos[] =   {"Entrantes","Carnes","Pescados","Postres","Bebidas","Cafe-Copa"};
	String variedades[][]={
				{"Jamon","Marisco","Ensalada","QuitaGranos"},
				{"Ternera","Chuleton","Pato a la naranja","Filete de cerdo","OsoBuco","Filete Plancha"},
				{"Merluza en salsa","Bacalao al pil pil","Besugo"},
				{"Tarta al wiski","Helado","Postre de la casa"},
				{"Vino Blanco","Vino Tinto","Agua","Cerveza"},
				{"solo","cortado","con leche","pacharan","whisky","nada"}
			};
	String precio[][]={	{"12","15.5","6.3","20"},
							{"10.0","15.5","9.90","2.5","4.5","4.5"},
							{"9.9","10","14"},
							{"3","3","4"},
							{"7","8","2.5","4"},
							{"1","1.1","1.2","3","4","0"}
					  };
	ButtonGroup gb[]= new ButtonGroup[platos.length];
	JPanel p,p1,p2,p3,p4,p2i[]= new JPanel[gb.length];
	JButton b1,b2,b3,b4;
	JTextArea ta;
	JScrollPane tajsp;
	JScrollPane jsp;
	JRadioButton rb[][];//= new JRadioButton[platos.length][variedades[5].length];
	JCheckBox cb[]= new JCheckBox[platos.length];
	boolean agotado[][];
	BorderLayout bl;
	Font negro,rojo;
 
	public MenuCena()
	{	int i,j;
		Insets insets= new Insets(65,50,65,50);
		p =new JPanel(new GridLayout(4,1));
		p2=new JPanel(new GridLayout(1,gb.length));
		p1=new JPanel(new GridLayout(1,1));
		for(i=0;i<gb.length;i++)
		{
			p2i[i]=new JPanel(new GridLayout(variedades.length,1));
			p2i[i].setBorder(BorderFactory.createTitledBorder(
					BorderFactory.createEtchedBorder(),platos[i]));
		}
		p3=new JPanel(new GridLayout(1,1));
		p4=new JPanel(new BorderLayout());//new GridLayout(1,1));
 
		// panel 1		
		for(i=0;i<cb.length; i++)
		{
			cb[i]= new JCheckBox(platos[i]);
			cb[i].addItemListener(this);
			cb[i].setBackground(Color.green);
			p1.add(cb[i]);
		}
 
		// panel 2		
		rb= new JRadioButton[platos.length][];
		agotado = new boolean[platos.length][];
		for(i=0;i<platos.length;i++)
		{	rb[i]= new JRadioButton[variedades[i].length];
			agotado[i]= new boolean[variedades[i].length];
		}
		for(i=0;i<gb.length; i++)
		{
			gb[i]= new ButtonGroup();
			for (j=0; j<variedades[i].length; j++)
			{
				rb[i][j]= new JRadioButton(variedades[i][j],false);
				agotado[i][j]= false;
				rb[i][j].addItemListener(this);
				rb[i][j].setEnabled(false);
				gb[i].add(rb[i][j]);
				p2i[i].add(rb[i][j]);
				rb[i][j].setBackground(Color.cyan);
				rb[i][j].setToolTipText(variedades[i][j]+"-->"+precio[i][j]);
			}
			rb[i][0].setSelected(true);
			p2.add(p2i[i]);
		}
 
		// Panel 3  area de texto.
		ta = new JTextArea(" CAFETERIA CANDY ELIJA un menu.",15,40);
		ta.setBackground(Color.green);
		ta.setBorder(BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED ),"MENU ELEGIDO"));//createEtchedBorder(),"MENU ELEGIDO"));
		ta.setEditable(false);
		tajsp = new JScrollPane(ta);
	//	try{		
		tajsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		tajsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	//	}catch(IllegalArgumentException iae){ta.append("Argumento ilegal");}
 
		//panel 4 Botones
		b1 = new JButton("SELECCIONAR ");
		b2 = new JButton("DETO NO KEDA");
		b3 = new JButton("    REPONER    ");
		b4 = new JButton("    SALIR   ");
		b3.setBackground(Color.red);
		b1.setBackground(Color.green);
		b2.setBackground(Color.white);
 
		b1. setMargin(insets);
		b2. setMargin(insets);
		b3. setMargin(insets);
		b1.addActionListener(this);
		b2.addActionListener(this);
		b3.addActionListener(this);
		b4.addActionListener(new ActionListener(){public void actionPerformed( ActionEvent aw)
				{System.exit(-2);	}});
 
		p4.add(b3,BorderLayout.WEST);
		p4.add(b1,BorderLayout.CENTER);
		p4.add(b2,BorderLayout.EAST);
		p4.add(b4,BorderLayout.SOUTH);
 
		p3.add(tajsp);// area de texto con deslizadores.
		p.add(p1);		p.add(p2);		p.add(p3);		p.add(p4);
		this.getContentPane().add(p);
	}
 
	public void itemStateChanged(ItemEvent ie)
	{
		Object o;
		o=ie.getSource();
		if (o instanceof JCheckBox)
		{
			for(int i=0;i<platos.length;i++)
			{
				if((JCheckBox)ie.getItemSelectable()==cb[i])
					if(((JCheckBox)o).isSelected())
						activarBotonera(i,variedades[i].length, true);
					else
						activarBotonera(i,variedades[i].length,false);
			}
		}
	}
 
	private void activarBotonera(int k,int n,boolean sw)
	{
		for(int i=0; i<n;i++)
			if(sw && !agotado[k][i])	rb[k][i].setEnabled(true);
			else	rb[k][i].setEnabled(false);
	}
 
	public void actionPerformed(ActionEvent ae)
	{
		NumberFormat formato ;
		double tot,x;
		int i,j;
		formato =  NumberFormat.getNumberInstance();
		formato.setMaximumFractionDigits(2);
		formato.setMinimumFractionDigits(2);
		formato.setMinimumIntegerDigits(3);
		if(ae.getSource() instanceof JButton)
		{
			if(((JButton)ae.getSource())==b1)	// SELECCIONAR
			{	// borrar pantalla previa
				ta.setText("");
				tot=0;
				for(i=0;i<platos.length;i++)
				{
					if(cb[i].isSelected())
						for(j=0; j<variedades[i].length;j++)
							if(!agotado[i][j] && rb[i][j].isSelected())
							{	x=Double.parseDouble(precio[i][j]);
								ta.append("precio   :    "+formato.format(x)+" ¦  "+cb[i].getText() + ": " + rb[i][j].getText()+"\n");
								tot += x;
							}
				}
				double iva = tot*.7;
				ta.append("TOTAL =    "+ formato.format(tot)+"\nIVA (7%) = "+ formato.format(tot*.07));//iva));
				ta.setForeground(Color.red);
				ta.append( "\nFACTURA="+formato.format(tot*1.07));
				repaint();
				ta.setForeground(Color.BLUE);
			}
			else if(((JButton)ae.getSource())==b2) // AGOTADO 
			{
				for(i=0;i<platos.length;i++)
					if(cb[i].isSelected())
						for(j=0; j<variedades[i].length;j++)
							if( rb[i][j].isSelected())
							{	agotado[i][j] =true;
								rb[i][j].setEnabled(false);
							}
			}
			else  if(((JButton)ae.getSource())==b3) // REPONER
			{
				for(i=0;i<platos.length;i++)
					if(cb[i].isSelected())
						for(j=0; j<variedades[i].length;j++)
						{
							// reponer todos.
							//if(!rb[i][j].isEnabled() && agotado[i][j])  // no se pueden seleccionar si desactivados
							{
								agotado[i][j] =false;
								rb[i][j].setEnabled(true);
							}
						}
			}
		}
	}
	public static void main(String[]args)
	{
		MenuCena mn= new MenuCena();
		mn.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent we)
			{	System.exit(1);	}});
		mn.setSize(600,800);
		mn.setResizable(false);
		mn.setVisible(true);
	}
}



Comentarios sobre la versión: Versión 1.0 (0)


No hay comentarios
 

Comentar la versión: Versión 1.0

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

2.0
estrellaestrellaestrellaestrellaestrella(1)

Publicado el 25 de Diciembre del 2018gráfica de visualizaciones de la versión: 2.0
2.633 visualizaciones desde el 25 de Diciembre del 2018
http://lwp-l.com/s4854