473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

11
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 1659
JosAH
11,448 Expert 8TB
What's the error then? Is it a compile time error or a runtime error?

kind regards,

Jos
Apr 29 '07 #2
ra7l
11
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 Expert 8TB
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
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 Expert 8TB
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
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...
1
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...
1
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...
0
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...
0
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...
19
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...
1
by: mg | last post by:
Errore: uncaught exception: Permesso negato per ottenere la proprietà HTMLDivElement.parentNode qualcuno puo' rispondermi in italiano????? grazie
1
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:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.