|
91
|
Programación / Java / mover imagen con el mouse
|
en: 6 Septiembre 2012, 23:34 pm
|
me ayudan con el problema de este code please!!! import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.IOException;
public class DragTest extends JFrame{
JLabel label; ImageIcon image;
public DragTest(){
setBounds(10, 10, 1000, 700); setVisible(true); setLayout(null); image=new ImageIcon("oficina1.jpg"); label=new JLabel(image); label.setBounds(10, 10, 100, 100); add(label); oyenteArrastre();
} public void oyenteArrastre(){ Arrastre a=new Arrastre(); label.addMouseMotionListener(a); }
class Arrastre implements MouseMotionListener{
@Override public void mouseDragged(MouseEvent e) {
setLocation(label.getX() + e.getX() - label.getWidth()/2 , label.getY() + e.getY() - label.getHeight()/2);
}
@Override public void mouseMoved(MouseEvent e) { throw new UnsupportedOperationException("Not supported yet."); }
} public static void main(String [] args) { DragTest d=new DragTest(); } }
|
|
|
92
|
Programación / Java / dar movimiento a una imagen
|
en: 6 Septiembre 2012, 01:01 am
|
hola a toda la comunidad quiero que me ayuden a dar movimiento a una imagen dentro del Jframe estuve realizando un pequeño ejemplo pero no genera el movimiento ayuda con este pequeño codigo please!!! import java.io.IOException; import java.lang.Thread; import javax.swing.*;
public class Prueba extends Thread { JFrame frame; JLabel punto; ImageIcon icono; int iniX=50; int finX=200; int iniY=100;
public Prueba(){
frame= new JFrame(); frame.setVisible(true); frame.setLayout(null); frame.setBounds(50, 50, 500, 500); ImageIcon icono= new ImageIcon("5.jpg"); JLabel punto=new JLabel(icono); punto.setSize(50, 30);
frame.add(punto);
}
public void run(){ for(int i=iniX+5; i<=finX; i=i+5) { punto.setLocation(i, iniY);//(iniX+i, iniY); try { sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } public static void main(String [] args) throws IOException { Prueba p=new Prueba(); p.start(); } }
|
|
|
93
|
Programación / Java / imagen boton
|
en: 1 Septiembre 2012, 03:28 am
|
alguien me podria ayudar a implementar que una imagen sea un boton!!! citen algunas paginas webs gracias por la ayuda!!! ayuda please........
|
|
|
94
|
Programación / Programación C/C++ / ayuda con caracteres
|
en: 31 Agosto 2012, 15:25 pm
|
bueno gracias por leer este tema
alguien me podria ayudar con estos caracteres...
:: % / * & por ejemplo int MPI::Intracomm::Get_size() int MPI_Comm_size(MPI_Comm comm, int *psize) void MPI::Init(int & argv,char & ** argv) void MPI::Init(int & argv,char & ** argv) printf("Hola mundo, Este es el rango %d de %d\n",rank,size);
alguna referencia de donde encuentro un buen tutorial sobre c++?? por que la verdad que estuve buscando mucho y no encuentro la funcionalidad de estos caracteres!!! ayuda please!!!
|
|
|
95
|
Programación / Java / interfaze de calidad
|
en: 20 Julio 2012, 05:41 am
|
alguien me puede ayudar a tener alguna idea de como hacer la cabezera en java
me refiero al panel de trabajo donde estan todos los botones
alguien sabe hacer k una palabra o una imagen sea un boton
|
|
|
97
|
Programación / Java / java y trigger
|
en: 12 Junio 2012, 01:05 am
|
hola como ejecuto los trigger desde java????????
necesito un ejemplo con los comandos que ejecuta los triggers en java
|
|
|
98
|
Programación / Bases de Datos / TRIGGERS ayuda
|
en: 19 Mayo 2012, 03:37 am
|
create table DETALLE_VENTA ( ID_VENTA NUMERIC not null, ID_PROD VARCHAR(30) null, CANTIDAD NUMERIC null, PRECIO_UNIT_PRO FLOAT8 null, MONTO_TOTAL FLOAT4 null );
create table VENTA ( ID_VENTA NUMERIC not null, ID_CAJERO NUMERIC null, CI_CLI NUMERIC null, FECHA DATE not null, HORA TIME not null, constraint PK_VENTA primary key (ID_VENTA) );
create table HISTO_PRODUCTO ( ID_PROD VARCHAR(30) null, nombre_pro VARCHAR(30) not null, FECHA DATE not null, NOMBRE_PROC VARCHAR(50) not null );
create table PRODUCTO ( ID_PROD VARCHAR(30) not null, PROCEDENCIA VARCHAR(20) not null, NOMBRE VARCHAR(20) not null, PESO FLOAT8 null, GARANTIA CHAR(2) null, UDS INT4 null, SECTOR_PRO VARCHAR(20) not null, UBICACION VARCHAR(20) not null, LITROS INT4 null, PUNTO_REORDEN INT4 not null, STOCK INT4 not null, constraint PK_PRODUCTO primary key (ID_PROD) ); en la tabla detalle_venta se encuentra el atributo cantidad, y el la tabla producto se encuentra el atributo stock, entonces lo que quiero que me ayuden es que como puedo hacer automatico la disminucion del stock para cada producto en cada venta. ya se que tengo que utilizar triggers, pero en lo que fallo es como hacer la funcion del trigger ya que tengo que modificar para cada producto y para cada determinada venta.
|
|
|
99
|
Programación / Java / Ueps y Peps
|
en: 1 Abril 2012, 02:42 am
|
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Progress extends JFrame { JProgressBar current; JTextArea out; JButton find; Thread runner; Ventana v; int num = 0; public Progress() { super("Progress"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel pane = new JPanel(); pane.setLayout(new FlowLayout()); current = new JProgressBar(0, 3000); current.setValue(0); current.setOrientation(current.VERTICAL); current.setStringPainted(true); pane.add(current); setContentPane(pane); }
public void iterate() { while (num < 3000) { current.setValue(num); try { runner.sleep(1000); } catch (InterruptedException e) { } num = num + 95; } v=new Ventana(); } public static void main(String[] arguments) { Progress frame = new Progress(); frame.pack(); frame.setVisible(true); frame.iterate(); frame.setVisible(false); } } import java.util.*; public class Kardex { ArrayList<Integer> ingSal = new ArrayList<Integer>(); ArrayList<Integer> CopingSal = new ArrayList<Integer>(); ArrayList<Integer> saldo = new ArrayList<Integer>(); ArrayList<Double> saldo2 = new ArrayList<Double>(); ArrayList<Double> cu = new ArrayList<Double>(); ArrayList<Double> ingreso = new ArrayList<Double>(); ArrayList<Double> egreso = new ArrayList<Double>(); ArrayList<Integer> ingSal2 = new ArrayList<Integer>(); ArrayList<Integer> CopingSal2 = new ArrayList<Integer>(); ArrayList<Integer> saldoDos = new ArrayList<Integer>(); ArrayList<Double> saldo22 = new ArrayList<Double>(); ArrayList<Double> cu2 = new ArrayList<Double>(); ArrayList<Double> ingreso2 = new ArrayList<Double>(); ArrayList<Double> egreso2 = new ArrayList<Double>(); int tam; public Kardex(String transaccion, String costo){ transaccion =transaccion.trim(); transaccion =transaccion.replaceAll(" ",""); costo =costo.trim(); costo =costo.replaceAll(" ",""); StringTokenizer tocador1 = new StringTokenizer(transaccion, ","); while(tocador1.hasMoreTokens()) {
String cadena = tocador1.nextToken(); int number=Integer.parseInt(cadena); ingSal.add(number); ingSal2.add(number); CopingSal.add(number); CopingSal2.add(number); } StringTokenizer tocador2 = new StringTokenizer(costo, ","); while(tocador2.hasMoreTokens()) {
String cadena = tocador2.nextToken(); double number=Double.parseDouble(cadena); cu.add(number); cu2.add(number); } generarPeps(); generarIngresosEgresosPeps(); generarUeps(); generarIngresosEgresosUeps(); } public void generarUeps(){ int i=0; int dato=0; int dato2=0; int j=0; int cont=0; boolean bandera=false; while(i<=ingSal2.size()-1){ dato=ingSal2.get(i); if(dato<0){ cont=0; j=i; ingSal2.remove(i); CopingSal2.remove(i); cu2.remove(i); while(dato<0){ while( dato2==0 && j>=0 ){ j=j-1; if(ingSal2.get(j)>0){ dato2=ingSal2.get(j); } } if (dato*-1>dato2){ bandera=true; } else{ bandera=false; } if(dato<=dato2 && bandera==true){ ingSal2.set(j,0); ingSal2.add(i,dato2*-1); CopingSal2.add(i,dato2*-1); dato=dato+dato2; dato2=0; cont++; cu2.add(i,cu2.get(j)); } else{ if(cont==0){ dato2=dato2+dato; ingSal2.set(j,dato2); ingSal2.add(i,dato); CopingSal2.add(i,dato); dato2=0; dato=0; cu2.add(i,cu2.get(j)); } else{ dato2=dato2+dato; ingSal2.set(j,dato2); ingSal2.add(i,dato); CopingSal2.add(i,dato); dato=0; dato2=0; cu2.add(i,cu2.get(j)); } } } i=i+cont; } i++; }
} public void generarIngresosEgresosUeps(){ double valor=0; for(int i=0; i<=ingSal2.size()-1; i++){ valor=CopingSal2.get(i)*cu2.get(i); if(valor>0){ ingreso2.add(valor); egreso2.add(0.0); }else{ ingreso2.add(0.0); egreso2.add(valor); } } } public ArrayList<Double> GenerarSaldo2Ueps(){
double valor=0; for(int i=0; i<=ingSal2.size()-1; i++){ valor=valor+CopingSal2.get(i)*cu2.get(i); saldo22.add(valor); } System.out.println(saldo22); return saldo22; } public ArrayList<Integer> GenerarSaldoUeps(){ int valor=0; for(int i=0; i<=CopingSal2.size()-1; i++){ valor=valor+CopingSal2.get(i); saldoDos.add(valor); } System.out.println(saldoDos); return saldoDos; } public ArrayList<Integer> transaccionUeps(){ System.out.println(ingSal2); return ingSal2; } public ArrayList<Double> ponerCostoUeps(){
System.out.println(cu2); return cu2; } public ArrayList<Double> generarIngresosUeps(){
System.out.println(ingreso2); return ingreso2; } public ArrayList<Double> generarEgresosUeps(){
System.out.println(egreso2); return egreso2; } public void generarPeps(){ int i=0; int dato=0; int dato2=0; int j=0; int cont=0; boolean bandera=false; while(i<=ingSal.size()-1){ dato=ingSal.get(i); if(dato<0){ cont=0; j=0; ingSal.remove(i); CopingSal.remove(i); cu.remove(i); while(dato<0){ while( dato2==0 && j<=ingSal.size()-1 ){ if(ingSal.get(j)>0){ dato2=ingSal.get(j); } j=j+1; } if (dato*-1>dato2){ bandera=true; } else{ bandera=false; } if(dato<=dato2 && bandera==true){ ingSal.set(j-1,0); ingSal.add(i,dato2*-1); CopingSal.add(i,dato2*-1); dato=dato+dato2; dato2=0; cont++; cu.add(i,cu.get(j-1)); } else{ if(cont==0){ dato2=dato2+dato; ingSal.set(j-1,dato2); ingSal.add(i,dato); CopingSal.add(i,dato); dato2=0; dato=0; cu.add(i,cu.get(j-1)); } else{ dato2=dato2+dato; ingSal.set(j-1,dato2); ingSal.add(i,dato); CopingSal.add(i,dato); dato=0; dato2=0; cu.add(i,cu.get(j-1)); } } } i=i+cont; } i++; } } public void generarIngresosEgresosPeps(){ double valor=0; for(int i=0; i<=ingSal.size()-1; i++){ valor=CopingSal.get(i)*cu.get(i); if(valor>0){ ingreso.add(valor); egreso.add(0.0); }else{ ingreso.add(0.0); egreso.add(valor); } } } public ArrayList<Double> GenerarSaldo2Peps(){
double valor=0; for(int i=0; i<=ingSal.size()-1; i++){ valor=valor+CopingSal.get(i)*cu.get(i); saldo2.add(valor); } System.out.println(saldo2); return saldo2; } public ArrayList<Integer> GenerarSaldoPeps(){ int valor=0; for(int i=0; i<=CopingSal.size()-1; i++){ valor=valor+CopingSal.get(i); saldo.add(valor); } System.out.println(saldo); return saldo; } public ArrayList<Integer> transaccionPeps(){ System.out.println(ingSal); return ingSal; } public ArrayList<Double> ponerCostoPeps(){
System.out.println(cu); return cu; } public ArrayList<Double> generarIngresosPeps(){
System.out.println(ingreso); return ingreso; } public ArrayList<Double> generarEgresosPeps(){
System.out.println(egreso); return egreso; } } import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
import javax.swing.*; import java.util.*;
public class Ventana extends JFrame { JButton botonUeps; JButton botonPeps; JPanel panel; JTextField campo1; JTextField campo2; JComboBox combo; JComboBox combo2; JComboBox combo3; JComboBox combo4; JComboBox combo5; JComboBox combo6; JComboBox combo21; JComboBox combo22; JComboBox combo23; JComboBox combo24; JComboBox combo25; JComboBox combo26; Kardex kardex; public Ventana(){ super("karder 1.01"); setVisible(true); setBounds(10, 10, 530, 550); setLayout(null); panel =new JPanel(); botonUeps=new JButton("Generar Ueps"); botonPeps=new JButton("Generar Peps"); campo1 =new JTextField(); campo2 =new JTextField(); combo =new JComboBox(); combo2 =new JComboBox(); combo3 =new JComboBox(); combo4 =new JComboBox(); combo5 =new JComboBox(); combo6 =new JComboBox(); combo21 =new JComboBox(); combo22 =new JComboBox(); combo23 =new JComboBox(); combo24 =new JComboBox(); combo25 =new JComboBox(); combo26 =new JComboBox(); agregar(); ordenando(); oyentes(); } public void ordenando(){ panel.setBounds(10, 10, 500, 600); panel.setVisible(true); panel.setLayout(null); add(panel); botonPeps.setBounds(50, 100, 150, 30); botonUeps.setBounds(270, 100, 150, 30); campo1.setBounds(120, 20, 200, 30); campo2.setBounds(120, 50, 200, 30); combo.setBounds(20,150,60,30); combo2.setBounds(90,150,60,30); combo3.setBounds(170,150,60,30); combo4.setBounds(240,150,60,30); combo5.setBounds(320,150,60,30); combo6.setBounds(400,150,60,30); combo21.setBounds(20,300,60,30); combo22.setBounds(90,300,60,30); combo23.setBounds(170,300,60,30); combo24.setBounds(240,300,60,30); combo25.setBounds(320,300,60,30); combo26.setBounds(400,300,60,30); } public void agregar(){ panel.add(botonPeps); panel.add(botonUeps); panel.add(combo); panel.add(combo2); panel.add(combo3); panel.add(combo4); panel.add(combo5); panel.add(combo6); panel.add(combo21); panel.add(combo22); panel.add(combo23); panel.add(combo24); panel.add(combo25); panel.add(combo26); panel.add(campo1); panel.add(campo2); } public void oyentes(){ Accion a=new Accion(); botonPeps.addActionListener(a); botonUeps.addActionListener(a); } public class Accion implements ActionListener{ public void actionPerformed(ActionEvent e) { if(e.getSource().equals(botonPeps)){ kardex=new Kardex(campo1.getText(),campo2.getText()); ArrayList<Integer> array=kardex.transaccionPeps(); ArrayList<Integer> array2=kardex.GenerarSaldoPeps(); ArrayList<Double> array3=kardex.ponerCostoPeps(); ArrayList<Double> array4=kardex.generarIngresosPeps(); ArrayList<Double> array5=kardex.generarEgresosPeps(); ArrayList<Double> array6=kardex.GenerarSaldo2Peps(); for(int i=0; i<=array.size()-1;i++){ combo.addItem(String.valueOf(array.get(i))); combo2.addItem(String.valueOf(array2.get(i))); combo3.addItem(String.valueOf(array3.get(i))); combo4.addItem(String.valueOf(array4.get(i))); combo5.addItem(String.valueOf(array5.get(i))); combo6.addItem(String.valueOf(array6.get(i))); } botonPeps.setEnabled(false); } if(e.getSource().equals(botonUeps)){ kardex=new Kardex(campo1.getText(),campo2.getText()); ArrayList<Integer> array=kardex.transaccionUeps(); ArrayList<Integer> array2=kardex.GenerarSaldoUeps(); ArrayList<Double> array3=kardex.ponerCostoUeps(); ArrayList<Double> array4=kardex.generarIngresosUeps(); ArrayList<Double> array5=kardex.generarEgresosUeps(); ArrayList<Double> array6=kardex.GenerarSaldo2Ueps(); for(int i=0; i<=array.size()-1;i++){ combo21.addItem(String.valueOf(array.get(i))); combo22.addItem(String.valueOf(array2.get(i))); combo23.addItem(String.valueOf(array3.get(i))); combo24.addItem(String.valueOf(array4.get(i))); combo25.addItem(String.valueOf(array5.get(i))); combo26.addItem(String.valueOf(array6.get(i))); } botonUeps.setEnabled(false); } } } public static void main (String args[]){ new Ventana(); }
} GEnerAr la clase Ventana en la casilla de arriba poner la cantidad de productos de ingreso y salida en la casilla de abajo poner el costo unitario de cada ingreso nota: los ingresos no tiene costo unitario lo cual debera ser 0 ejemplo: la casilla 1---> "400,500,-720" la casilla 2---> "10,10.7,0"
|
|
|
|
|
|
|