InicioInfoagunos comandos para java lenguaje de programacion

agunos comandos para java lenguaje de programacion

Info12/6/2010
bueno este es mi primer post espero k alguien lo vea y aunk sea le interce ps
estos algunnos pequeños programas k diseñe en java esta en una hoja aplet


este pernite el ingeso de algunos datos y saldran lo pedido

package hdp;

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

import javax.swing.*;

public class hoja1 extends JApplet implements ActionListener {
JComboBox JCb1,JCb2;
JLabel JLn,JLn1,JLn2;
JTextField JT1;
JTextArea JTa;
JScrollPane JSp;
JButton jb1,jb2,jb3;
int cn=1,s=0;
public void init()
{getContentPane().setLayout(null);
JLn=new JLabel("Procedencia";
JLn.setBounds(10,10,150,20);
add(JLn);

JCb1=new JComboBox();
JCb1.setBounds(10,40,90,20);
JCb1.addItem("Nacional";
JCb1.addItem("Importado";
JCb1.addActionListener(this);
add(JCb1);

JLn1=new JLabel("Productos";
JLn1.setBounds(130,10,100,20);
add(JLn1);

JCb2=new JComboBox();
JCb2.setEditable(false);
JCb2.setBounds(120,15,110,50);
JCb2.addItem("Antibioticos";
JCb2.addItem("Analgesicos";
JCb2.addItem("Antipireticos";
JCb2.setBorder(BorderFactory.createTitledBorder("producto");
JCb2.addActionListener(this);
add(JCb2);

JLn2=new JLabel("Unidades";
JLn2.setBounds(250,10,100,20);
add(JLn2);

JT1=new JTextField();
JT1.setEditable(false);
JT1.setBounds(250,40,100,40);
JT1.addActionListener(this);
add(JT1);

JTa=new JTextArea();
JTa.setEditable(false);

JSp=new JScrollPane(JTa);
JSp.setBounds(10,100,340,160);
add(JSp);

jb1=new JButton("nuevo";
jb1.setBounds(10,270,100,20);
jb1.addActionListener(this);
add(jb1);

jb2=new JButton("Stop";
jb2.setBounds(250,270,100,20);
jb2.addActionListener(this);
add(jb2);

jb3=new JButton("Registrar";
jb3.setBounds(130,270,100,20);
jb3.addActionListener(this);
add(jb3);


setSize(360,300);
setVisible(true);
}
public void nuevo()
{
if(cn<=10
)
{
JT1.setEditable(true);
JT1.setText("";
JT1.requestFocus();
cn++;
JT1.setBorder(BorderFactory.createTitledBorder("numero"+cn));
}
if(cn==10)
{
JOptionPane.showMessageDialog(this,"puede salir";
jb1.setEnabled(true);
}
}
public void procedencia()
{
String na=null;
int p;
p=JCb1.getSelectedIndex();
switch(p)
{
case 0: na="nacional";break;
case 1: na="Importado";break;
}
JTa.append("n procedenciatprodutotcantidad";
JTa.append("n"+na);
JCb1.setEditable(false);
JCb2.setEditable(true);
}
public void producto()
{

}


public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(jb1))
nuevo();
if (e.getSource().equals(JCb1))
procedencia();
}

}

este es otro ya



package botones;

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

import javax.swing.*;

public class hoja1 extends JApplet implements ActionListener
{
JPanel JP1;
JRadioButton JRd,JRcre;
JTextField JT1,JT2,JT3,JT4,JT5;
JButton JBc;
JLabel JLti;
ButtonGroup BGr;

public void init()
{
getContentPane().setLayout(null);

JLti=new JLabel("I M P O R T A D O R A R Y O M A";
JLti.setBounds(50,10,250,20);
add(JLti);

JP1=new JPanel();
JP1.setLayout(null);
JP1.setBorder(BorderFactory.createTitledBorder("TIPO DE PAGO");
JP1.setBounds(10,40,100,70);
add(JP1);

JRd=new JRadioButton("Debito";
JRd.addActionListener(this);
JRd.setBounds(10,20,80,20);
JP1.add(JRd);

JRcre=new JRadioButton("Credito";
JRcre.addActionListener(this);
JRcre.setBounds(10,40,80,20);
JP1.add(JRcre);

BGr=new ButtonGroup();
BGr.add(JRd);
BGr.add(JRcre);

JT1= new JTextField();
JT1.addActionListener(this);
JT1.setEditable(false);
JT1.setBorder(BorderFactory.createTitledBorder("MONTO DE COMPRA");
JT1.setBounds(10,120,140,50);
add(JT1);

JT2= new JTextField();
JT2.setBorder(BorderFactory.createTitledBorder("MONTO A PAGAR ");
JT2.setEditable(false);
JT2.setBounds(10,180,140,50);
add(JT2);

JT3= new JTextField();
JT3.addActionListener(this);
JT3.setEditable(false);
JT3.setBorder(BorderFactory.createTitledBorder("VALOR INICIAL");
JT3.setBounds(160,40,140,50);
add(JT3);

JT4= new JTextField();
JT4.setBorder(BorderFactory.createTitledBorder("VALOR FINAL");
JT4.setEditable(false);
JT4.setBounds(160,120,140,50);
add(JT4);

JT5= new JTextField();
JT5.setBorder(BorderFactory.createTitledBorder("INCREMENTO");
JT5.setEditable(false);
JT5.setBounds(160,180,140,50);
add(JT5);

JBc=new JButton("CALCULAR";
JBc.addActionListener(this);
JBc.setBounds(80,240,150,20);
add(JBc);
setSize(320,300);
setVisible(true);
}


public void actionPerformed(ActionEvent e)
{
if (JRd.isSelected())
{
JT3.setEditable(true);
JT3.requestFocus();

}
if (e.getSource().equals(JT3))
{

JT1.setEditable(true);
JT1.requestFocus();
JT3.setEditable(false);
}
if (e.getSource().equals(JT1)&& JRd.isSelected())

{
double vi,mc;
JT3.setEditable(false);
vi=Double.parseDouble(JT3.getText());
mc=Double.parseDouble(JT1.getText());
if (mc<=vi)
{
JOptionPane.showMessageDialog(this, "presione el boton calcular";
}
else
{
JOptionPane.showMessageDialog(this, "operacion invalida su monto activo es:"+vi);
JT1.setText("";
JT1.requestFocus();
}
}
if (e.getSource().equals(JBc)&& JRd.isSelected())
{
JT3.setEditable(false);
double vi,mc,vf,mp;
vi=Double.parseDouble(JT3.getText());
mc=Double.parseDouble(JT1.getText());
vf=vi-mc;
mp=mc;
if(mc<=vi)
{
JT4.setText("S/."+vf);
JT2.setText("S/."+mp);

}

}

if(JRcre.isSelected())
{
JT1.setEditable(true);
JT1.requestFocus();
}
if(e.getSource().equals(JBc)&& JRcre.isSelected())
{
double mc,in,mp;
mc=Double.parseDouble(JT1.getText());
in=mc*0.12;
mp=mc+in;
JT5.setText("S/."+in);
JT2.setText("S/."+mp);
}



}


}


este es otro


package botones;

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

import javax.swing.*;

public class hoja1 extends JApplet implements ActionListener
{
JPanel JPn,JPm,JPx;
JTextField JT1,JT2;
JRadioButton JR1,JR2,jr3,jr4,jr5,jr6;
ButtonGroup Bgr1,bgr2,Bgr3;
JButton jb;

public void init()
{
getContentPane().setLayout(null);

JPn=new JPanel();
JPn.setLayout(null);
JPn.setBorder(BorderFactory.createTitledBorder("menu principal");
JPn.setBounds(10,10,320,80);
add(JPn);

JR1=new JRadioButton("boleta";
JR1.addActionListener(this);
JR1.setBounds(20,50,100,20);
JPn.add(JR1);

JR2=new JRadioButton("factura";
JR2.addActionListener(this);
JR2.setBounds(120,50,100,20);
JPn.add(JR2);

jr3=new JRadioButton("Salir";
jr3.addActionListener(this);
jr3.setBounds(230,50,80,20);
JPn.add(jr3);

Bgr1=new ButtonGroup();
Bgr1.add(JR1);
Bgr1.add(JR2);
Bgr1.add(jr3);

JPm=new JPanel();
JPm.setLayout(null);
JPm.setBorder(BorderFactory.createTitledBorder("boleta");
JPm.setBounds(10,100,320,200);
JPm.setVisible(false);
add(JPm);


JT1=new JTextField();
JT1.setBounds(10,30,100,40);
JT1.setBorder(BorderFactory.createTitledBorder("cantidad");
JPm.add(JT1);

JT2=new JTextField();
JT2.setBounds(10,150,260,40);
JT2.setBorder(BorderFactory.createTitledBorder("sub total");
JPm.add(JT2);

jb=new JButton("procesar";
jb.addActionListener(this);
jb.setBounds(10,100,100,20);
JPm.add(jb);


JPx=new JPanel();
JPx.setLayout(null);
JPx.setBorder(BorderFactory.createTitledBorder("producto");
JPx.setBounds(160,30,120,115);
JPm.add(JPx);

jr4=new JRadioButton("arroz";
jr4.addActionListener(this);
jr4.setBounds(10,20,100,20);
JPx.add(jr4);

jr5=new JRadioButton("azucar";
jr5.addActionListener(this);
jr5.setBounds(10,45,100,20);
JPx.add(jr5);

jr6=new JRadioButton("aceite";
jr6.addActionListener(this);
jr6.setBounds(10,70,100,20);
JPx.add(jr6);



Bgr3=new ButtonGroup();
Bgr3.add(jr4);
Bgr3.add(jr5);
Bgr3.add(jr6);

setSize(350,350);
setVisible(true);


}

public void actionPerformed(ActionEvent e)

{
if(JR1.isSelected())
{
JPm.setVisible(true);

}

}

}
y este es el ultimo por k creo k ya los aburri


package conjuntodebotones;

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

import javax.swing.*;

public class hoja1 extends JApplet implements ActionListener
{
JComboBox JB;
JTextField JP,JC;
JButton JS,JF,JN,JSA;
JTextArea JA;
JScrollPane JSC;

int can,cf=1;
double pre=0,stotal=0;
String np=null;

public void init()
{
getContentPane().setLayout(null);
JB=new JComboBox();
JB.setBorder(BorderFactory.createTitledBorder("PRODUCTO");
JB.setBounds(20,20,100,50);
JB.addItem("ARROZ";
JB.addItem("AZUCAR";
JB.addItem("ACEITE";
JB.addActionListener(this);
add(JB);

JP=new JTextField();
JP.setBorder(BorderFactory.createTitledBorder("PRECIO");
JP.setBounds(130,20,100,50);
add(JP);

JC=new JTextField();
JC.setBorder(BorderFactory.createTitledBorder("CANTIDAD");
JC.addActionListener(this);
JC.setBounds(240,20,100,50);
add(JC);

JS=new JButton("SIGUIENTE";
JS.addActionListener(this);
JS.setBounds(20,90,100,20);
add(JS);

JF=new JButton("FACTURA";
JF.addActionListener(this);
JF.setBounds(130,90,100,20);
add(JF);

JN=new JButton("NUEVO";
JN.addActionListener(this);
JN.setBounds(240,90,100,20);
add(JN);

JA=new JTextArea();
JA.setEditable(false);

JSC=new JScrollPane(JA);
JSC.setBounds(20,130,320,100);
add(JSC);

JSA=new JButton("SALIR";
JSA.addActionListener(this);
JSA.setBounds(130,250,100,20);
add(JSA);

setSize(360,280);
setVisible(true);
}
public void producto()
{
int pro=JB.getSelectedIndex();
switch(pro)
{
case 0: np="ARROZ";pre=3.20;break;
case 1: np="ACEITE";pre=3.80;break;
case 2: np="AZUCAR";pre=6.50;break;
}

JP.setText("S/"+pre);
JC.requestFocus();
JC.setEditable(true);
}
public void cantidad()
{
String cn=JC.getText();
int LO=cn.length();

if(LO>0)
{
int x,i,co=0;

for(i=0;i<LO;i++)
{
x=cn.charAt(i);
if(x>=48&&x<=57)
{
co++;
}
}
if(LO==co)
{
registrar();
}
else
{
JOptionPane.showMessageDialog(this, "SOLO NUMEROS";
JC.setText("";
JC.requestFocus();
}
}
else
{
JOptionPane.showMessageDialog(this, "SOLO NUMEROS";
JC.setText("";
JC.requestFocus();
}
}

public void registrar()
{
if(cf<=5)
{
if(cf==1)
{
JA.append("nPRODUCTOtPRECIOtCANTIDADtTOTALES";
}
int c=Integer.parseInt(JC.getText());
double total=pre*c;

stotal+=total;

JA.append("n"+np+"t"+pre+"t"+c+"t"+total);
cf++;
}
if(cf==6)
{
JOptionPane.showMessageDialog(this, "TERMINAR REGISTRO";
}
}
public void siguiente()
{
JP.setText("";
JC.setText("";
JOptionPane.showMessageDialog(this,"ELIGE OTRO PRODUCTO";
}
public void factura()
{
double sub,igv;
igv=stotal*0.19;
sub=stotal-igv;

JA.append("nttSUBTOTALtS/"+sub);
JA.append("nttIGVtS/"+igv);
JA.append("nttTOTALtS/"+stotal);
}

public void nuevo()
{
JP.setText("";
JP.requestFocus();
JP.setText("";
}
public void salir()
{
System.exit(0);
}
public void actionPerformed(ActionEvent e) {


if(e.getSource().equals(JB))
producto();

if(e.getSource().equals(JC))
cantidad();

if(e.getSource().equals(JS))
siguiente();

if(e.getSource().equals(JF))
factura();

if(e.getSource().equals(JN))
nuevo();

if(e.getSource().equals(JSA))
salir();
}

}




para que nose4e compliken pongaan los comandos en una hoja en blanco de java eso es tod espero k alguien
le sirva ps bueno chau





si aprecen unas caritas son comillas y parentesis
Datos archivados del Taringa! original
0puntos
5,125visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
3visitas
0comentarios
Dar puntos:

Dejá tu comentario

0/2000

Autor del Post

x
xXGINOXx🇦🇷
Usuario
Puntos0
Posts1
Ver perfil →
PosteameloArchivo Histórico de Taringa! (2004-2017). Preservando la inteligencia colectiva de la internet hispanohablante.

CONTACTO

18 de Septiembre 455, Casilla 52

Chillán, Región de Ñuble, Chile

Solo correo postal

© 2026 Posteamelo.com. No afiliado con Taringa! ni sus sucesores.

Contenido preservado con fines históricos y culturales.