Hi All ..
First Thanks to All For Help Me ..
ok ..This Code it Move Train but one errore small..
Where Correct Cods
Thanks All ..
:) -
import java.awt.*;
-
import java.awt.event.*;
-
import javax.swing.*;
-
import java.lang.Thread;
-
-
public class TestTrain{
-
public static void main(String[]args){
-
Train t= new Train ();
-
MoveTrain mt = new MoveTrain(t);
-
t.setTitle("Train");
-
t.setSize(421,550);
-
t.setVisible(true);
-
t.addWindowListener (
-
new WindowAdapter (){
-
public void windowClosing(WindowEvent e ){
-
System.exit(0);
-
}
-
});
-
mt.start();
-
}
-
}
-
-
-
class Train extends JFrame implements ActionListener {
-
-
private boolean START=false;
-
private boolean check=false;
-
private boolean stopped=false;
-
private int trainPlace = 0;
-
private int INDEX_START=0;
-
int speed = 300;
-
ImageIcon CurrentImage ;
-
boolean front=true, back=false ;
-
-
JPanel screen, area , controlroom;
-
JButton[][] street;
-
JButton[] keybord;
-
String s[] = {"Start","Stop","Fast","Slow" ,"Rest","Check"};
-
-
ImageIcon images[][] ={{
-
new ImageIcon("images/UpRight.jpg"),
-
new ImageIcon("images/RightDown.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
},
-
{new ImageIcon("images/Vert.jpg"),
-
new ImageIcon("images/DownRight.jpg"),
-
new ImageIcon("images/Horiz.jpg"),
-
new ImageIcon("images/RightDown.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
},{
-
new ImageIcon("images/Vert.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
new ImageIcon("images/Vert.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
},{
-
new ImageIcon("images/Vert.jpg"),
-
new ImageIcon("images/UpRight.jpg"),
-
new ImageIcon("images/Horiz.jpg"),
-
new ImageIcon("images/RightUp.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
},{
-
-
new ImageIcon("images/DownRight.jpg"),
-
new ImageIcon("images/RightUp.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
new ImageIcon("images/NoTrack.jpg"),
-
new ImageIcon("images/NoTrack.jpg") }};
-
-
ImageIcon frontImagesTrain[]={new ImageIcon("images/TrainUp.jpg"),
-
new ImageIcon("images/TrainLeft.jpg"),
-
new ImageIcon("images/TrainLeft.jpg"),
-
new ImageIcon("images/TrainUp.jpg"),
-
new ImageIcon("images/TrainLeft.jpg"),
-
-
new ImageIcon("images/TrainLeft.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
-
new ImageIcon("images/TrainRight.jpg"),
-
new ImageIcon("images/TrainUp.jpg"),
-
new ImageIcon("images/TrainRight.jpg"),
-
new ImageIcon("images/TrainUp.jpg"),
-
-
};
-
-
ImageIcon BackImagesTrain[]=new ImageIcon[]{
-
new ImageIcon("images/TrainUp.jpg"),
-
new ImageIcon("images/TrainLeft.jpg"),
-
new ImageIcon("images/TrainLeft.jpg"),
-
new ImageIcon("images/TrainUp.jpg"),
-
new ImageIcon("images/TrainLeft.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
new ImageIcon("images/TrainDown.jpg"),
-
new ImageIcon("images/TrainRight.jpg"),
-
new ImageIcon("images/TrainUp.jpg"),
-
new ImageIcon("images/TrainRight.jpg"),
-
new ImageIcon("images/TrainRight.jpg"),
-
new ImageIcon("images/TrainUp.jpg")
-
};
-
-
-
-
-
int[]frontPath={13, 18,17,16,21,20,15,10,5,0,1,6,7,8};
-
int[]backPath={13,8, 7,6,1,0,5,10,15,20,21,16,17,18};
-
-
-
ImageIcon icon;
-
-
JLabel labelInfo;
-
-
-
public Train () {
-
screen = new JPanel(new GridLayout(1,1));
-
Font f =new Font ("Sanserif",Font.BOLD,18);
-
labelInfo = new JLabel("WELCOM" ,JLabel.CENTER);
-
labelInfo.setFont(f);
-
-
screen.setBackground(Color.red);
-
screen.add(labelInfo);
-
getContentPane().add(BorderLayout.NORTH,screen );
-
-
street = new JButton[5][5];
-
area = new JPanel (new GridLayout(5,5));
-
-
-
-
for(int r=0; r<5; r++)
-
for (int c=0; c<5; c++){
-
street[r][c] = new JButton("", images[r][c]);
-
area.add(street[r][c]);
-
}
-
getContentPane().add(BorderLayout.CENTER,area );
-
-
keybord = new JButton[6];
-
controlroom = new JPanel(new GridLayout(3,3));
-
-
for (int i=0; i <6; i++)
-
{
-
-
keybord[i] = new JButton(s[i]);
-
keybord[i].addActionListener(this);
-
controlroom.add(keybord[i]);
-
-
-
-
}
-
getContentPane().add(BorderLayout.SOUTH,controlroom );
-
-
-
}
-
-
public void actionPerformed(ActionEvent e){
-
if(e.getSource()==keybord[0])//Start
-
setStop(false);
-
else if(e.getSource()==keybord[1])//Stop
-
setStop(true);
-
else if(e.getSource()==keybord[2]) //Fast
-
setSpeed(++speed);
-
else if(e.getSource()==keybord[3])//Slow
-
setSpeed(--speed);
-
else if(e.getSource()==keybord[4])//Rest
-
-
else if(e.getSource()==keybord[5])//Check
-
setCheck(true);
-
}
-
-
public void moveTrain(){
-
-
-
-
}
-
void setCheck (boolean c)
-
{
-
int TrainPlace = trainPlace;
-
int i = frontPath[trainPlace]/5;
-
int j = frontPath[trainPlace] - i * 5;
-
street[i][j].setIcon = new JButton("",frontImagesTrain[0]);
-
-
-
check = c ;
-
}
-
-
boolean getCheck ()
-
{
-
return check ;
-
-
}
-
-
void setSpeed (int s)
-
{
-
speed = s ;
-
}
-
-
int getSpeed ()
-
{
-
return speed ;
-
-
}
-
-
-
void setStop (boolean s)
-
{
-
stopped = s ;
-
}
-
-
boolean getStop ()
-
{
-
return stopped ;
-
-
}
-
-
}
-
-
class MoveTrain extends Thread {
-
Train train ;
-
-
public MoveTrain (Train train){
-
this.train= train;
-
}
-
-
public void run(){
-
while(!train.getCheck());
-
while (train.getCheck()){
-
try {sleep (train.getSpeed()); }
-
catch (InterruptedException e ){}
-
if (!train.getStop() )
-
train.moveTrain () ;
-
}
-
}
-
}
-
-
This Link image http://www.4shared.com/file/13555551/ff070bf/images.html
Thanks
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
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
:)
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
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
-
void setCheck (boolean c)
-
{
-
int TrainPlace = trainPlace;
-
int i = frontPath[trainPlace]/5;
-
int j = frontPath[trainPlace] - i * 5;
-
street[i][j].setIcon = new JButton("",frontImagesTrain[0]);// HER ERRORE
-
-
-
check = c ;
-
}
-
THANKS
JosAH 11,448
Recognized Expert MVP -
void setCheck (boolean c)
-
{
-
int TrainPlace = trainPlace;
-
int i = frontPath[trainPlace]/5;
-
int j = frontPath[trainPlace] - i * 5;
-
street[i][j].setIcon = new JButton("",frontImagesTrain[0]);// HER ERRORE
-
-
-
check = c ;
-
}
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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.
|
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...
|
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 è...
| |
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...
|
by: mg |
last post by:
Errore: uncaught exception: Permesso negato per ottenere la proprietà
HTMLDivElement.parentNode
qualcuno puo' rispondermi in italiano?????
grazie
|
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...
|
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...
|
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. ...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |