Professional Documents
Culture Documents
Holi
Holi
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField tfComida;
private JTextField tfBebida;
private JSpinner spinner;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ab frame = new ab();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public ab() {
setTitle("Restaurante");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 393, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JComboBox<String>
cboComida = new JComboBox<String>();
cboComida.setModel(new DefaultComboBoxModel<String>(new String[] {
"-", "comida1", "comida2", "comida3", "comida4"}));
cboComida.setBounds(89, 36, 100, 20);
contentPane.add(cboComida);
//cantidad = Integer.parseInt(txtCantidad.getText());
opcionC = cboComida.getSelectedIndex();
opcionB = cboBebida.getSelectedIndex();
if (opcionC == 0) {
precioC = 0;
}
if (opcionC == 1) {
precioC = 7.5;
}
if (opcionC == 2) {
precioC = 4.35;
}
if (opcionC == 3) {
precioC = 3.50;
}
if (opcionC == 4) {
precioC = 4.55;
}
if (opcionB == 0) {
precioB = 0;
}
if (opcionB == 1) {
precioB = 4.5;
}
if (opcionB == 2) {
precioB = 4.35;
}
if (opcionB == 3) {
precioB = 3.50;
}
if (opcionB == 4) {
precioB = 4.55;
}
txtRslt.append("\n");
txtRslt.append("oal" + "\n");
txtRslt.append("Importe total por comida: " + icCfin + "\n");
txtRslt.append("Importe total por bebida: " + icBfin + "\n");
txtRslt.append("Total: " + total + "\n");
txtRslt.append("\n");
//textarea = txtResults
}
});
btnBorrar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
txtRslt.setText(null);
}
});
btnBorrar.setBounds(285, 67, 82, 23);
contentPane.add(btnBorrar);
}
}