Boa Tarde tentei fazer o que voces falara mais sem sucesso, o codigo a cima nao é completo segue o codigo completo para voces entenderem
CLASSE SLVEICULOS ( CODIGO)
import javax.swing.JOptionPane;
public class SLVeiculos {
String novoOuUsado, novo = "n", usado= "u";
double valorVenda,SomaComissaoVeiculo,valorAcessorio,valorFinanciado,porcentagem,comissaoFinanciamento,valorTotal,valorTotal2,valorTotal3;
public double comissaoVeiculo (double valorVenda){
this.valorVenda = 0;
this.valorVenda = valorVenda;
this.SomaComissaoVeiculo =0;
if(novoOuUsado == null){
JOptionPane.showMessageDialog(null,("Selecione um Tipo de Venda!!! "));// mensagem para o usuario
}
if(this.novoOuUsado.equalsIgnoreCase(novo)){
this.SomaComissaoVeiculo = valorVenda * 0.004;
this.valorTotal=0;
this.valorTotal = SomaComissaoVeiculo;
this.valorTotal2=0;
this.valorTotal2 =valorTotal ;
this.valorTotal3+= valorTotal2;
}
if(this.novoOuUsado.equalsIgnoreCase(usado)){
this.SomaComissaoVeiculo = valorVenda * 0.005;
}
/*System.out.println(SomaComissaoVeiculo);*/
return SomaComissaoVeiculo;
}
public double comissaoAcessorio(double valorAcessorio){
this.valorAcessorio =0;
this.valorAcessorio = valorAcessorio * 0.05;
/*System.out.println(this.valorAcessorio);*/
return this.valorAcessorio;
}
public double comissaoFinanciamento(double valorFinanciado){
this.valorFinanciado =0;
this.comissaoFinanciamento =0;
this.valorFinanciado = valorFinanciado;
/*System.out.println("Valor Comissao: " + this.comissaoFinanciamento);*/
return valorFinanciado;
}
public double comissaoFinanciamento2(double porcentagem){
this.porcentagem =0;
this.porcentagem = porcentagem;
this.valorFinanciado =valorFinanciado;
this.comissaoFinanciamento = this.valorFinanciado * this.porcentagem * 0.20;
return comissaoFinanciamento;
}
public String mostra(){
System.out.println("Comissao da Venda do Veiculo: " + this.SomaComissaoVeiculo+" " + "Comissao Venda Acessorios: " + this.valorAcessorio+" " +
"Comissao do Financiamento: " +" " + comissaoFinanciamento);
return "Comissao da Venda do Veiculo: " + this.SomaComissaoVeiculo + " \n" +"-------------------------------------------------------------------------------" +"\n" + "Comissao Venda Acessorios: " + this.valorAcessorio + "\n" +"-------------------------------------------------------------------------------" +"\n" +
"Comissao do Financiamento: " + comissaoFinanciamento +"\n" + "-------------------------------------------------------------------------------" + "\n" +"\n"+"\n" + "teste: " + valorTotal3;
}
public void setNovoOuUsado(String novoOuUsado) {
this.novoOuUsado = novoOuUsado;
}
public void setValorVenda(double valorVenda) {
this.valorVenda = valorVenda;
}
public void setValorAcessorio(double valorAcessorio) {
this.valorAcessorio = valorAcessorio;
}
}
CLASSE ARRAY
public class Array {
SLVeiculos [] sl;
public Array(){
this.sl = new SLVeiculos [50];
}
void adicionaArray(SLVeiculos f ){
for(int x = 0; x < this.sl.length; x++ ){
if(sl[x] == null){
this.sl[x] = f;
break;
}
}
}
public String verificar(){
for(int x = 0; x < this.sl.length; x++){
if(this.sl[x] == null){
System.out.println("Nao possui DADOS !!!");
}
else{
return this.sl[x].mostra();
}
}return null;
}
}
CLASSE INTERFACE
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
public class Interface extends JFrame implements ActionListener {
SLVeiculos sl = new SLVeiculos();
Array a1 = null;
Array sl2 = new Array();
JScrollPane scroll;
JButton botaovendaveiculo;
JButton botaovendaacessorio;
JButton botaovendafinanciamento;
JButton botaoResultado;
JButton botaoSair;
JButton botaoSalvar;
JButton botaoLimpa;
JButton botaoOK;
JRadioButton novo,usado;
ButtonGroup botaogrupo;
JLabel lTexto = new JLabel(new ImageIcon("C:/Users/Juliano2/Desktop/SLVeiculos.jpg"));
JTextField vendaveiculo2 = new JTextField();
JTextField vendaacessorio2 = new JTextField();
JTextField vendafinanciamento2 = new JTextField();
JTextField Resultado2 = new JTextField();
JTextField tipo = new JTextField();
JTextField porcentofinanciamento2 = new JTextField();
JTextArea txt = new JTextArea();
Interface(SLVeiculos slv){
this.sl = slv;
scroll = new JScrollPane(txt);
setTitle("SL Veiculos Comissoes");
setSize(800,820);
setResizable(false);
//Setando as Escritas
JLabel vendaveiculo = new JLabel("Valor Venda Veiculo: ");
JLabel vendaacessorio = new JLabel("Valor Venda Acessorio: ");
JLabel vendafinanciamento = new JLabel("Valor Venda Financiamento: ");
JLabel tipo2 = new JLabel("Tipo de Venda: ");
JLabel porcentofinanciamento = new JLabel("Porcento Financiamento: ");
Resultado2 = new JTextField();
// os Botoes OK
botaovendaveiculo = new JButton("OK");
botaovendaacessorio = new JButton ("OK");
botaovendafinanciamento = new JButton ("OK");
botaoResultado = new JButton ("Resultado ");
botaoSair = new JButton ("Sair");
botaoSalvar = new JButton ("Salvar");
botaoLimpa = new JButton ("Limpar");
botaoOK = new JButton("OK");
novo = new JRadioButton("Novo");
usado = new JRadioButton("Usado");
botaogrupo = new ButtonGroup();
botaogrupo.add(usado);//é preciso colocar separado para funcionar ou seja é necessario colocar em buttongroup
botaogrupo.add(novo);
//setando nullo o Layout
getContentPane().setLayout(null);
//Setando os lugares dos objetos
vendaveiculo.setBounds(20, 60,200, 20);
vendaacessorio.setBounds(20, 100, 150, 50);
vendafinanciamento.setBounds(20, 155, 200, 50);
porcentofinanciamento.setBounds(200, 155, 200, 50);
vendaveiculo2.setBounds(20,80,150,20);
tipo2.setBounds(18,10,200,20);
vendaacessorio2.setBounds(20,135,150,20);
vendafinanciamento2.setBounds(20, 190, 150, 20);
porcentofinanciamento2.setBounds(200, 190, 150, 20);
//txt.setBounds(10, 300, 773, 200);
botaoResultado.setBounds(10, 240, 100, 50);
//botaoSalvar.setBounds(160, 240, 100, 50);
novo.setBounds(110, -5, 60, 50);
usado.setBounds(180, -5, 100,50);
lTexto.setBounds(390, 13, 400, 100);
scroll.setBounds(10, 300, 775, 470);
botaoLimpa.setBounds(160, 240, 100, 50);
botaoOK.setBounds(360, 185, 53, 30);
getContentPane().add(vendaveiculo);
getContentPane().add(vendaveiculo2);
getContentPane().add(tipo);
getContentPane().add(tipo2);
getContentPane().add(vendaacessorio);
getContentPane().add(vendaacessorio2);
getContentPane().add(vendafinanciamento);
getContentPane().add(vendafinanciamento2);
getContentPane().add(porcentofinanciamento);
getContentPane().add(porcentofinanciamento2);
//getContentPane().add(Resultado2);
getContentPane().add(botaoResultado);
//getContentPane().add(botaoSalvar);
getContentPane().add(novo);
getContentPane().add(usado);
getContentPane().add(lTexto);
//getContentPane().add(txt);
getContentPane().add(scroll);
getContentPane().add(botaoLimpa);
getContentPane().add(botaoOK);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);//tornar visivel a barra de rolagem
vendaveiculo2.addActionListener(this);
tipo.addActionListener(this);
vendaacessorio2.addActionListener(this);
vendafinanciamento2.addActionListener(this);
porcentofinanciamento2.addActionListener(this);
//Resultado2.addActionListener(this);
botaoResultado.addActionListener(this);
//botaoSalvar.addActionListener(this);
novo.addActionListener(this);
usado.addActionListener(this);
botaoLimpa.addActionListener(this);
botaoOK.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void actionPerformed (ActionEvent e){
if(e.getSource() == vendaveiculo2 ){
this.sl.comissaoVeiculo(Double.parseDouble(vendaveiculo2.getText())); //Double.parseDouble faz mudar para double o resultado
}
/*if(e.getSource() == Resultado2){
Resultado2.setText(this.sl.mostra());
}*/
if(e.getSource() == botaoResultado){
sl.setValorAcessorio(sl.valorAcessorio);
sl.comissaoFinanciamento(sl.valorFinanciado);
sl.comissaoVeiculo(sl.valorVenda);
sl.comissaoFinanciamento2(sl.porcentagem);
sl2.adicionaArray(sl);
txt.setText((txt.getText().toString()) + sl2.verificar());
}
/*if(e.getSource() == tipo){
this.sl.setNovoOuUsado(tipo.getText());
} se USA PARA DIGITAR O n OU u FOI MUDADO PARA RADIOBOTTOM
*/
if(e.getSource() == vendaacessorio2){
this.sl.comissaoAcessorio(Double.parseDouble(vendaacessorio2.getText()));
}
if(e.getSource() == vendafinanciamento2 ){
this.sl.comissaoFinanciamento(Double.parseDouble(vendafinanciamento2.getText()));
}
if(e.getSource()== porcentofinanciamento2 ){
this.sl.comissaoFinanciamento2(Double.parseDouble(porcentofinanciamento2.getText()));
}
/*if(e.getSource() == botaoSalvar){
sl.setValorAcessorio(sl.valorAcessorio);
sl.comissaoFinanciamento(sl.valorFinanciado);
sl.comissaoVeiculo(sl.valorVenda);
sl.comissaoFinanciamento2(sl.porcentagem);
sl2.adicionaArray(sl);
}
// salvar em um array
*/
if(e.getSource() == novo){
this.sl.setNovoOuUsado(this.sl.novo);
}
if(e.getSource() == usado){
this.sl.setNovoOuUsado(this.sl.usado);
}
if(e.getSource() == botaoLimpa){
this.sl.comissaoFinanciamento =0;
this.sl.porcentagem = 0;
this.sl.novoOuUsado = null;
this.sl.valorFinanciado =0;
this.sl.valorVenda =0;
this.sl.valorAcessorio =0;
}
if(e.getSource() == botaoOK){
this.sl.comissaoVeiculo(Double.parseDouble(vendaveiculo2.getText()));
this.sl.comissaoFinanciamento(Double.parseDouble(vendafinanciamento2.getText()));
this.sl.comissaoFinanciamento2(Double.parseDouble(porcentofinanciamento2.getText()));
this.sl.comissaoAcessorio(Double.parseDouble(vendaacessorio2.getText()));
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
SLVeiculos sl10 = new SLVeiculos();
Interface add = new Interface(sl10);
}
}
obrigado assim mesmo pelas respostas.