elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


  Mostrar Mensajes
Páginas: 1 2 [3]
21  Programación / Java / Re: Demasiado rápido en: 17 Junio 2012, 20:54 pm
vale, gracias pero me dice de añadirle; Surround with try/catch. y no se como funciona... ni donde ponerlo
22  Programación / Java / Re: Demasiado rápido en: 17 Junio 2012, 19:48 pm
Porfavor ayudarme  :huh: que es para clase....
23  Programación / Java / Demasiado rápido en: 17 Junio 2012, 18:59 pm
Hola,
he hecho el siguiente código con eclipse cuya función es la de mostrar aleatoriamente colores en cuartos de venta cada x segundos.
Pero va tan rápido que los muestra todos a la vez.
¿Alguien podría ayudarme? (soy novato lo habréis notado por la penosa calidad del código)

import java.awt.AWTException;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Robot;

import javax.management.relation.Role;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class quenivelquieres extends JFrame {
   
   
   
   private static final long serialVersionUID = 8585544783492126617L;
   public static quenivelquieres app;   
   public static final int        APP_WIDTH   = 500;
    public static final int        APP_HEIGHT  = 500;
   private JMenuBar Barra;
   private JMenu Archivo;
   private JMenuItem salir;
    public static void main(String[] args) {
       app = new quenivelquieres ();
       app.show();
       }
   

    public void paint(Graphics gfx) {
        setLayout(null);
       setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
       Barra = new JMenuBar();
       Archivo = new JMenu ("Archivo");
       Barra.add(Archivo);
       salir = new JMenuItem ("Salir");
       Archivo.add(salir);
       salir.addActionListener(
         new ActionListener() {
            public void actionPerformed( ActionEvent evento ){
               System.exit( 0 );
            }
         }
      );
       this.setJMenuBar(Barra);
       setVisible(true);
          
       Container workArea = this.getContentPane();
        Graphics workAreaGfx = workArea.getGraphics();
        int z = 0;
              while (z<1000){
        int x =  (int) (Math.random()*10+1);
 
       
       
      
      if(x==5){x= x-1;}
      if(x==6){x= x-3;}//3
      if(x==7){x= x-5;}//2
      if(x==8){x= x-7;}//1
      if(x==9){x= x-5;}//4
      
      if(x==10){x= x-9;}//1
       
       
       
      if(x==1){
        workAreaGfx.setColor(Color.blue);
        int width = workArea.getWidth();
        int height = workArea.getHeight();
        workAreaGfx.fillRect(0,0, width/2, height/2);}
      if(x==2){
          workAreaGfx.setColor(Color.red);
          int width = workArea.getWidth();
          int height = workArea.getHeight();
          workAreaGfx.fillRect(250,250, width,height);}
      if(x==3){
          workAreaGfx.setColor(Color.yellow);
          int width = workArea.getWidth();
          int height = workArea.getHeight();
          workAreaGfx.fillRect(250,0, width/2, height/2);}
      if(x==4){
          workAreaGfx.setColor(Color.green);
          int width = workArea.getWidth();
          int height = workArea.getHeight();
          workAreaGfx.fillRect(0,250, width/2, height/2);}
   
 
   z+=1;
    this.setSize(APP_WIDTH, APP_HEIGHT);
    this.setTitle("Dale al Azúl");
 

   
       }
              

      
   }
24  Sistemas Operativos / GNU/Linux / Rj 45 en: 17 Febrero 2012, 14:19 pm
hola,
he innstalado la última versión de ubuntu en mi vieja torre pentium 4 y no detecta
la conexión por cable.
Me preguntaba si a alguien le ha pasado algo parecido o tiene la solución.

Gracias.
Páginas: 1 2 [3]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines