473,564 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I Need Help ... Plez ..The Smole Errore :)

11 New Member
Hi All ..
First Thanks to All For Help Me ..

ok ..This Code it Move Train but one errore small..

Where Correct Cods

Thanks All ..

:)
Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.lang.Thread; 
  5.  
  6. public class TestTrain{      
  7.     public static void main(String[]args){
  8.         Train t= new Train ();
  9.         MoveTrain mt = new MoveTrain(t);
  10.         t.setTitle("Train");
  11.         t.setSize(421,550);
  12.         t.setVisible(true);
  13.         t.addWindowListener (
  14.         new WindowAdapter (){
  15.              public void windowClosing(WindowEvent e ){
  16.                   System.exit(0); 
  17.              }
  18.         });
  19.         mt.start();
  20.     }
  21. }
  22.  
  23.  
  24. class Train extends JFrame implements ActionListener {
  25.  
  26.     private boolean START=false;
  27.     private boolean check=false;
  28.     private boolean stopped=false;
  29.     private int trainPlace = 0;
  30.     private int INDEX_START=0;
  31.     int speed = 300;
  32.    ImageIcon CurrentImage ;
  33.    boolean front=true, back=false ; 
  34.  
  35.     JPanel screen, area , controlroom;
  36.     JButton[][] street;
  37.     JButton[] keybord;
  38.     String s[] = {"Start","Stop","Fast","Slow" ,"Rest","Check"};
  39.  
  40.     ImageIcon images[][] ={{
  41.                     new ImageIcon("images/UpRight.jpg"),
  42.                     new ImageIcon("images/RightDown.jpg"),
  43.                     new ImageIcon("images/NoTrack.jpg"),
  44.                     new ImageIcon("images/NoTrack.jpg"),
  45.                     new ImageIcon("images/NoTrack.jpg"),
  46.                     },
  47.                     {new ImageIcon("images/Vert.jpg"),
  48.                     new ImageIcon("images/DownRight.jpg"),
  49.                     new ImageIcon("images/Horiz.jpg"),
  50.                     new ImageIcon("images/RightDown.jpg"),
  51.                     new ImageIcon("images/NoTrack.jpg"),
  52.                     },{
  53.                     new ImageIcon("images/Vert.jpg"),
  54.                     new ImageIcon("images/NoTrack.jpg"),
  55.                     new ImageIcon("images/NoTrack.jpg"),
  56.                     new ImageIcon("images/Vert.jpg"),
  57.                     new ImageIcon("images/NoTrack.jpg"), 
  58.                     },{
  59.                     new ImageIcon("images/Vert.jpg"),
  60.                     new ImageIcon("images/UpRight.jpg"),
  61.                     new ImageIcon("images/Horiz.jpg"),
  62.                     new ImageIcon("images/RightUp.jpg"),
  63.                     new ImageIcon("images/NoTrack.jpg"), 
  64.                     },{
  65.  
  66.                     new ImageIcon("images/DownRight.jpg"),
  67.                     new ImageIcon("images/RightUp.jpg"),
  68.                     new ImageIcon("images/NoTrack.jpg"), 
  69.                     new ImageIcon("images/NoTrack.jpg"), 
  70.                     new ImageIcon("images/NoTrack.jpg") }};
  71.  
  72.     ImageIcon frontImagesTrain[]={new ImageIcon("images/TrainUp.jpg"),
  73.                     new ImageIcon("images/TrainLeft.jpg"),
  74.                     new ImageIcon("images/TrainLeft.jpg"),
  75.                     new ImageIcon("images/TrainUp.jpg"),
  76.                     new ImageIcon("images/TrainLeft.jpg"),
  77.  
  78.                     new ImageIcon("images/TrainLeft.jpg"),
  79.                     new ImageIcon("images/TrainDown.jpg"),
  80.                     new ImageIcon("images/TrainDown.jpg"),
  81.                     new ImageIcon("images/TrainDown.jpg"),
  82.                     new ImageIcon("images/TrainDown.jpg"),
  83.  
  84.                     new ImageIcon("images/TrainRight.jpg"),
  85.                     new ImageIcon("images/TrainUp.jpg"),
  86.                     new ImageIcon("images/TrainRight.jpg"),
  87.                     new ImageIcon("images/TrainUp.jpg"),  
  88.  
  89.        };
  90.  
  91.         ImageIcon BackImagesTrain[]=new ImageIcon[]{ 
  92.         new ImageIcon("images/TrainUp.jpg"),
  93.         new ImageIcon("images/TrainLeft.jpg"),
  94.         new ImageIcon("images/TrainLeft.jpg"),
  95.         new ImageIcon("images/TrainUp.jpg"),
  96.         new ImageIcon("images/TrainLeft.jpg"),
  97.         new ImageIcon("images/TrainDown.jpg"),
  98.         new ImageIcon("images/TrainDown.jpg"),
  99.         new ImageIcon("images/TrainDown.jpg"),
  100.         new ImageIcon("images/TrainDown.jpg"),
  101.         new ImageIcon("images/TrainRight.jpg"),
  102.         new ImageIcon("images/TrainUp.jpg"),
  103.         new ImageIcon("images/TrainRight.jpg"),
  104.         new ImageIcon("images/TrainRight.jpg"),
  105.         new ImageIcon("images/TrainUp.jpg")
  106.     };
  107.  
  108.  
  109.  
  110.  
  111.     int[]frontPath={13, 18,17,16,21,20,15,10,5,0,1,6,7,8}; 
  112.     int[]backPath={13,8, 7,6,1,0,5,10,15,20,21,16,17,18};   
  113.  
  114.  
  115.     ImageIcon icon;
  116.  
  117.     JLabel labelInfo;
  118.  
  119.  
  120.     public Train () {   
  121.        screen = new JPanel(new GridLayout(1,1));
  122.        Font f =new Font ("Sanserif",Font.BOLD,18);
  123.        labelInfo = new JLabel("WELCOM" ,JLabel.CENTER);
  124.        labelInfo.setFont(f);
  125.  
  126.        screen.setBackground(Color.red);
  127.        screen.add(labelInfo);
  128.        getContentPane().add(BorderLayout.NORTH,screen );
  129.  
  130.         street = new JButton[5][5];
  131.         area = new JPanel (new GridLayout(5,5));
  132.  
  133.  
  134.  
  135.         for(int r=0; r<5; r++)    
  136.             for (int c=0; c<5; c++){
  137.                 street[r][c] = new JButton("", images[r][c]);
  138.                 area.add(street[r][c]);
  139.             }                
  140.         getContentPane().add(BorderLayout.CENTER,area );    
  141.  
  142.         keybord = new JButton[6];
  143.         controlroom = new JPanel(new GridLayout(3,3));    
  144.  
  145.         for (int i=0; i <6; i++)
  146.         {
  147.  
  148.             keybord[i] = new JButton(s[i]);
  149.             keybord[i].addActionListener(this);
  150.             controlroom.add(keybord[i]);
  151.  
  152.  
  153.  
  154.         }       
  155.         getContentPane().add(BorderLayout.SOUTH,controlroom );
  156.  
  157.  
  158.     }
  159.  
  160.       public void actionPerformed(ActionEvent e){
  161.            if(e.getSource()==keybord[0])//Start
  162.                setStop(false);
  163.            else if(e.getSource()==keybord[1])//Stop
  164.            setStop(true);
  165.          else if(e.getSource()==keybord[2]) //Fast
  166.            setSpeed(++speed);
  167.          else if(e.getSource()==keybord[3])//Slow
  168.            setSpeed(--speed);
  169.          else if(e.getSource()==keybord[4])//Rest
  170.  
  171.          else if(e.getSource()==keybord[5])//Check
  172.            setCheck(true);
  173.       }
  174.  
  175.     public void moveTrain(){
  176.  
  177.  
  178.  
  179.     }
  180.     void setCheck (boolean c)
  181.     {
  182.         int TrainPlace = trainPlace;
  183.         int i = frontPath[trainPlace]/5;
  184.         int j = frontPath[trainPlace] - i * 5;
  185.     street[i][j].setIcon = new JButton("",frontImagesTrain[0]);
  186.  
  187.  
  188.         check = c ;
  189.     }
  190.  
  191.    boolean getCheck ()
  192.    {
  193.            return  check ;
  194.  
  195.    }
  196.  
  197.     void setSpeed (int s)
  198.     {
  199.         speed = s ;
  200.     }
  201.  
  202.    int getSpeed ()
  203.    {
  204.    return  speed ;
  205.  
  206.    }
  207.  
  208.  
  209.      void setStop (boolean s)
  210.     {
  211.         stopped = s ;
  212.     }
  213.  
  214.    boolean getStop ()
  215.    {
  216.       return  stopped ;
  217.  
  218.    }
  219.  
  220. }  
  221.  
  222. class MoveTrain extends Thread {
  223.     Train train ;
  224.  
  225.     public   MoveTrain (Train train){
  226.          this.train= train;
  227.     }
  228.  
  229.     public void run(){
  230.          while(!train.getCheck());
  231.          while (train.getCheck()){
  232.              try {sleep (train.getSpeed()); }
  233.              catch (InterruptedException e ){}
  234.               if (!train.getStop() )
  235.                   train.moveTrain () ;
  236.          }
  237.     }
  238. }
  239.  
  240.  

This Link image http://www.4shared.com/file/13555551/ff070bf/images.html


Thanks
Apr 29 '07 #1
5 1682
JosAH
11,448 Recognized Expert MVP
What's the error then? Is it a compile time error or a runtime error?

kind regards,

Jos
Apr 29 '07 #2
ra7l
11 New Member
What's the error then? Is it a compile time error or a runtime error?

kind regards,

Jos
its compile 2 error
but i need after compile Click on Check and Train Start

Thanks All .. Thanks Admin

:)
Apr 29 '07 #3
JosAH
11,448 Recognized Expert MVP
its compile 2 error
but i need after compile Click on Check and Train Start
Can you please show use the exact compilation errors? I'm afraid that the
program you're starting is a previous incarnation where you haven't upset the
compiler.

kind regards,

Jos
Apr 29 '07 #4
ra7l
11 New Member
Can you please show use the exact compilation errors? I'm afraid that the
program you're starting is a previous incarnation where you haven't upset the
compiler.

kind regards,

Jos
Expand|Select|Wrap|Line Numbers
  1. void setCheck (boolean c)
  2.     {
  3.         int TrainPlace = trainPlace;
  4.         int i = frontPath[trainPlace]/5;
  5.         int j = frontPath[trainPlace] - i * 5;
  6.     street[i][j].setIcon = new JButton("",frontImagesTrain[0]);// HER ERRORE 
  7.  
  8.  
  9.         check = c ;
  10.     }
  11.  

THANKS
Apr 29 '07 #5
JosAH
11,448 Recognized Expert MVP
Expand|Select|Wrap|Line Numbers
  1. void setCheck (boolean c)
  2.     {
  3.         int TrainPlace = trainPlace;
  4.         int i = frontPath[trainPlace]/5;
  5.         int j = frontPath[trainPlace] - i * 5;
  6.     street[i][j].setIcon = new JButton("",frontImagesTrain[0]);// HER ERRORE 
  7.  
  8.  
  9.         check = c ;
  10.     }
  11.  

THANKS
And what was the exact error message the compiler gave you?

kind regards,

Jos

ps. always show the relevant code as well as the exact compiler or runtime error.
It makes it much easier for us to help you.
Apr 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2540
by: giancaMI | last post by:
Salve a tutti, la mia configurazione è la seguente: win 2k sp4 dreamweaver MX 2004 MySql ver. 4.1 su pc locale IIS Microsoft installato dunque, dopo avere installato MySql (che funziona regolarmente da prompt e con la interfaccia Control Center per Windows scaricata dal sito di MySql) e dopo avere creato una pagina PHP con Dreamweaver...
1
3281
by: Andrea Canegrati | last post by:
Ciao a tutti, devo eseguire una INSERT su un db in remoto...visto che non lo uso frequentemente utilizzo la funzione OPENDATASOURCE invece di linkare il server. Tutto funziona alla perfezione..ma quando sposto il codice all'interno di un Trigger (che lancio dopo l'inserimento in un altra tabella su un altro db) mi dice che non puù aggiungere...
1
2161
by: leo | last post by:
all'improvviso quando utilizzo istruzioni tipo: server.mappath("..\db") o nell'include uso il percorso scritto '..\file.inc' ho il seguente errore: Tipo di errore: Server.MapPath(), ASP 0175 (0x80004005) Impossibile utilizzare i caratteri ".." nel parametro Path del metodo MapPath.
0
1079
by: Giuseppe Esposito | last post by:
"The state information is invalid for this page and might be corrupted" Non è che non abbia già cercato... ma è che tutto quello che è venuto fuori dalla ricerca non è stato utile. Succede fondamentalmente che ho preso un progetto 1.1 ... convertito in 2.0 .... a partire parte, ad un certo punto, dopo n volte che la pagina viene...
0
3489
by: and251076 | last post by:
Buongiorno, da pochi giorno ho installato la versione 2005 di Visual Studio, ma ahi mè non funziona tutto perfettamente. Infatti non riesco ad eseguite le miei applicazioni web in localhost. Se provo ad eseguire il debug mi ritorna la seguente segnalazione di errore: Impossibile avviare il debug sul server Web.Il server Web non è...
19
2068
by: ash | last post by:
hi friends, i have some questions whch is in my last year question papers.i need some help to get logic of these questions. 1) write a C function, that takes two strings as arguments and returns a pointer to the first occurrence of 1st string in 2nd string or NULL if it is not present. -- i tried to solve it but it seems that i am not...
1
2165
by: mg | last post by:
Errore: uncaught exception: Permesso negato per ottenere la proprietà HTMLDivElement.parentNode qualcuno puo' rispondermi in italiano????? grazie
1
1984
by: michele.binetti | last post by:
Ciao a tutti, accedendo, per la prima volta, ad una pagina contenuta in un iframe non ho problemi. se riaccedo alla stessa, per la seconda volta, Internet Explorer mi da questa segnalazione: Errore:Prevista Funzione. la pagina contiene alcune semplici funzione che verificazno il contenuto di alcuni campi e li disabilitano. Ma cosa vuol...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.