Foros del Web » Programación para mayores de 30 ;) » Java »

Uso de Variables

Estas en el tema de Uso de Variables en el foro de Java en Foros del Web. tengo el siguiente codigo, Código PHP: package isreiva ; import java . awt . Dimension ; import java . awt . Rectangle ; import java . awt . event ...
  #1 (permalink)  
Antiguo 17/10/2011, 19:55
 
Fecha de Ingreso: mayo-2010
Mensajes: 212
Antigüedad: 14 años
Puntos: 3
Uso de Variables

tengo el siguiente codigo,
Código PHP:
package isreiva;

import java.awt.Dimension;

import java.awt.Rectangle;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.util.Scanner;

public class 
Calculo extends JFrame {
    private 
JButton jButton1 = new JButton();
    private 
JLabel jLabel1 = new JLabel();
    private 
JTextField jTextField1 = new JTextField();
    private 
JLabel jLabel2 = new JLabel();

    public 
Calculo() {
        try {
            
jbInit();
        } catch (
Exception e) {
            
e.printStackTrace();
        }
    }

    private 
void jbInit() throws Exception {
        
        
this.getContentPane().setLayoutnull );
        
this.setSize( new Dimension(400300) );
        
jButton1.setText("Calcular");
        
jButton1.setBounds(new Rectangle(26519011040));
        
jButton1.addActionListener(new ActionListener() {
                public 
void actionPerformed(ActionEvent e) {
                    
jButton1_actionPerformed(e);
                }
            });
        
jLabel1.setText("Escriba sus honorarios en el campo: ");
        
jLabel1.setBounds(new Rectangle(652018040));
        
jTextField1.setBounds(new Rectangle(1006511530));
        
jLabel2.setText("");
        
jLabel2.setBounds(new Rectangle(12511510535));
        
this.getContentPane().add(jLabel2null);
        
this.getContentPane().add(jTextField1null);
        
this.getContentPane().add(jLabel1null);
        
this.getContentPane().add(jButton1null);
    }

    private 
void jButton1_actionPerformed(ActionEvent e) {
        
double Honorarios,Subtotal,IVA,ISR,RIVA,Total;
        
jTextField1.write(Honorarios);// aqui tengo un problema de tipo de dato incompatible
 
        
IVA Honorarios*.16;
        
Subtotal Honorarios IVA;
        
ISR Honorarios .1;
        
RIVA IVA * (2/3);
        
Total Subtotal - (ISR+RIVA);
    } 
Uso Write o getContentPane? lo que quiero es hacer un calculo de impuestos
__________________
Por favor dejenme Karmas
  #2 (permalink)  
Antiguo 18/10/2011, 01:35
 
Fecha de Ingreso: abril-2011
Mensajes: 1.342
Antigüedad: 13 años
Puntos: 344
Respuesta: Uso de Variables

Al método write se le tiene que pasar un objeto de la clase Writer o derivadas.

Lo mejor es usar el método setText de la clase JTextField, conviertiendo el double en String antes.

Código Java:
Ver original
  1. jTextField1.setText(Double.toString(Honorarios));

Saludos

Etiquetas: variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:05.