Vous êtes sur la page 1sur 12

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

/**

* @author VLKym

*/

public class cehck extends javax.swing.JFrame {

/**

* Creates new form cehck

*/

public cehck() {

initComponents();

/**
* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

chocolate = new javax.swing.JRadioButton();

lucuma = new javax.swing.JRadioButton();

chocochip = new javax.swing.JRadioButton();

copa = new javax.swing.JCheckBox();

barquillo = new javax.swing.JCheckBox();

vaso = new javax.swing.JCheckBox();

jLabel2 = new javax.swing.JLabel();

jLabel4 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();

limpiar = new javax.swing.JButton();

calcular = new javax.swing.JButton();

salir = new javax.swing.JButton();

jComboBox1 = new javax.swing.JComboBox<>();

jLabel8 = new javax.swing.JLabel();

Subtotal = new javax.swing.JTextField();

Igv = new javax.swing.JTextField();

Total = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setBackground(new java.awt.Color(153, 204, 255));

jLabel1.setFont(new java.awt.Font("Bauhaus 93", 0, 36)); // NOI18N


jLabel1.setText("Venta de Helado");

chocolate.setText("Chocolate s./ 1.00");

chocolate.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

chocolateActionPerformed(evt);

});

lucuma.setText("Lucuma s./ 1.50");

lucuma.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

lucumaActionPerformed(evt);

});

chocochip.setText("Chocochip s./ 2.00");

chocochip.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

chocochipActionPerformed(evt);

});

copa.setText("Copa s./ 1.00");

barquillo.setText("Barquillo s./ 1.50");

vaso.setText("Vaso s./ 2.00");

jLabel2.setText("Subtotal");
jLabel4.setText("IGV");

jLabel6.setText("Total");

limpiar.setText("Limpiar");

limpiar.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

limpiarActionPerformed(evt);

});

calcular.setText("Calcular");

calcular.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

calcularActionPerformed(evt);

});

salir.setText("Salir");

salir.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

salirActionPerformed(evt);

});

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Cant.


01", "Cant. 02", "Cant. 04", "Cant. 06", "Cant. 08", "Cant. 10" }));

jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

jLabel8.setText("Cantidad");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(chocolate)

.addComponent(lucuma)

.addComponent(chocochip)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)

.addComponent(limpiar, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

.addComponent(salir, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

.addComponent(calcular, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(vaso)

.addComponent(copa)

.addComponent(barquillo)

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(Subtotal))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel4)

.addGap(33, 33, 33)

.addComponent(Igv))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel6)

.addGap(26, 26, 26)

.addComponent(Total))))

.addGroup(layout.createSequentialGroup()

.addGap(0, 48, Short.MAX_VALUE)

.addComponent(jLabel1)

.addGap(6, 6, 6)))

.addGap(74, 74, 74))

.addGroup(layout.createSequentialGroup()

.addGap(111, 111, 111)

.addComponent(jLabel8)

.addGap(18, 18, 18)

.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel8))

.addGap(31, 31, 31)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(chocolate)

.addComponent(copa))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(lucuma)

.addComponent(barquillo))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(chocochip)

.addComponent(vaso))

.addGap(26, 26, 26)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2)

.addComponent(limpiar)

.addComponent(Subtotal, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel4)

.addComponent(calcular)

.addComponent(Igv, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel6)

.addComponent(salir)
.addComponent(Total, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(31, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

private void salirActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

System.exit(0);

private void limpiarActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

chocolate.setSelected(false);

chocochip.setSelected(false);

lucuma.setSelected(false);

copa.setSelected(false);

barquillo.setSelected(false);

vaso.setSelected(false);

Subtotal.setText(" ");

Igv.setText(" ");

Total.setText(" ");

private void chocolateActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:


if (chocolate.isSelected());

chocochip.setSelected(false);

lucuma.setSelected(false);

private void lucumaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (lucuma.isSelected());

chocochip.setSelected(false);

chocolate.setSelected(false);

private void chocochipActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (chocochip.isSelected());

chocolate.setSelected(false);

lucuma.setSelected(false);

private void calcularActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

double total;

double subtotal=0;

final double IGVRATE = 0.18;

double igv;

if (chocolate.isSelected()){

subtotal = subtotal + 1.00;

}else if(lucuma.isSelected()){

subtotal = subtotal + 1.50;


}else if (chocochip.isSelected()){

subtotal = subtotal + 2.00;

if (copa.isSelected()){

subtotal = subtotal + 1.00;

}else if(barquillo.isSelected()){

subtotal = subtotal + 1.50;

}else if (vaso.isSelected()){

subtotal = subtotal + 2.00;

Subtotal.setText(Double.toString(subtotal));

subtotal = Double.parseDouble(Subtotal.getText());

igv = subtotal * IGVRATE;

total = igv + subtotal;

Igv.setText(Double.toString(igv));

Total.setText(Double.toString(total));

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(cehck.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(cehck.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(cehck.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(cehck.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new cehck().setVisible(true);

}
});

// Variables declaration - do not modify

private javax.swing.JTextField Igv;

private javax.swing.JTextField Subtotal;

private javax.swing.JTextField Total;

private javax.swing.JCheckBox barquillo;

private javax.swing.JButton calcular;

private javax.swing.JRadioButton chocochip;

private javax.swing.JRadioButton chocolate;

private javax.swing.JCheckBox copa;

private javax.swing.JComboBox<String> jComboBox1;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel8;

private javax.swing.JButton limpiar;

private javax.swing.JRadioButton lucuma;

private javax.swing.JButton salir;

private javax.swing.JCheckBox vaso;

// End of variables declaration

Vous aimerez peut-être aussi