code stuff
public class Move{
ImageIcon cup = new ImageIcon("C:\\Documents and Settings\\Michael Leaf\\My Documents\\My Pictures\\acer.jpg");
JLabel label = new JLabel(cup);
public Move() {
JFrame frame = new JFrame();
frame.setSize(600, 600);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel cp = (JPanel)frame.getContentPane();
cp.setLayout(null);
cp.setBackground(Color.white);
label.setSize(250,100);
label.setLocation(100,100);
cp.add(label);
frame.setVisible(true);
}
public static void main(String[] args) {
Move myMove = new Move();
int x, y;
//repeat forever
while(true) {
for(x = 0; x < 400; x++) {
myMove.label.setLocation(0,x );
pause(5);
}
for(x = 400; x > 0; x--) {
myMove.label.setLocation(x, x);
pause(5);
}
}
}
static void pause(long time) {
try {
Thread.sleep(time);
}
catch(InterruptedException e) {
throw new RuntimeException("dont care.");
}
}
}
I see poorly formated code (use code tags!) and no question.So, no answer.
> who understands that?repost your code formated, please.
public class Move{
ImageIcon cup = new ImageIcon("C:\\Documents and Settings\\Michael Leaf\\My Documents\\My Pictures\\acer.jpg");
JLabel label = new JLabel(cup);
public Move() {
JFrame frame = new JFrame();
frame.setSize(600, 600);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel cp = (JPanel)frame.getContentPane();
cp.setLayout(null);
cp.setBackground(Color.white);
label.setSize(250,100);
label.setLocation(100,100);
cp.add(label);
frame.setVisible(true);
}
public static void main(String[] args) {
Move myMove = new Move();
int x, y;
//repeat forever
while(true) {
for(x = 0; x < 400; x++) {
myMove.label.setLocation(0,x );
pause(5);
}
for(x = 400; x > 0; x--) {
myMove.label.setLocation(x, x);
pause(5);
}
}
}
static void pause(long time) {
try {
Thread.sleep(time);
}
catch(InterruptedException e) {
throw new RuntimeException("dont care.");
}
}
}
do you know about code tags? you surround your code with [ code ] and [ /code ] (without the spaces). It then makes the code readable.
Also, why not give us your interpretation first and then any specific questions you might have. The question above is not really specific enough. I could say, "I do" which is a perfectly valid answer, but probably not the one you want to hear.
public class Move{
ImageIcon cup = new ImageIcon("C:\\Documents and Settings\\Michael Leaf\\My Documents\\My Pictures\\acer.jpg");
JLabel label = new JLabel(cup);
public Move() {
JFrame frame = new JFrame();
frame.setSize(600, 600);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel cp = (JPanel)frame.getContentPane();
cp.setLayout(null);
cp.setBackground(Color.white);
label.setSize(250,100);
label.setLocation(100,100);
cp.add(label);
frame.setVisible(true);
}
public static void main(String[] args) {
Move myMove = new Move();
int x, y;
//repeat forever
while(true) {
for(x = 0; x < 400; x++) {
myMove.label.setLocation(0,x );
pause(5);
}
for(x = 400; x > 0; x--) {
myMove.label.setLocation(x, x);
pause(5);
}
}
}
static void pause(long time) {
try {
Thread.sleep(time);
}
catch(InterruptedException e) {
throw new RuntimeException("dont care.");
}
}
}
all right.When you click "reply" - just above the text box where you'd type your reply, there is a "code" button. Click it. Then you will see to tags, one says [ code ] the other says [ /code ]. Insert your code between the [ code ] tag and the [ /code ] tag.
public class Move{
ImageIcon cup = new ImageIcon("C:\\Documents and Settings\\Michael Leaf\\My Documents\\My Pictures\\acer.jpg");
JLabel label = new JLabel(cup);
public Move() {
JFrame frame = new JFrame();
frame.setSize(600, 600);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel cp = (JPanel)frame.getContentPane();
cp.setLayout(null);
cp.setBackground(Color.white);
label.setSize(250,100);
label.setLocation(100,100);
cp.add(label);
frame.setVisible(true);
}
public static void main(String[] args) {
Move myMove = new Move();
int x, y;
//repeat forever
while(true) {
for(x = 0; x < 400; x++) {
myMove.label.setLocation(0,x );
pause(5);
}
for(x = 400; x > 0; x--) {
myMove.label.setLocation(x, x);
pause(5);
}
}
}
static void pause(long time) {
try {
Thread.sleep(time);
}
catch(InterruptedException e) {
throw new RuntimeException("dont care.");
}
}
}
> so thats how ppl do itNo, usually they just type in the code tags manually.... at least I do.
Muuuuuch better...Now, what part about this prog don't you understand?
well my friend made it for me and it works i can change stuff but i dont understand how to control it
> well my friend made it for me and it works i can> change stuff but i dont understand how to control it"Control it"? Could you give an example of what you mean?