Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at the Callable interface, which can return a value and throw Exceptions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This was also mentioned by myself and s.o.s. two days ago in your other post about the char array... :P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

628

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

622

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

618
edit: Doh! posted at same time as stephen.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Wow, an entire web site filled with pathetic pleas for "send me teh codez for dis project". Very impressive... :icon_rolleyes:

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In that case, all you need to do is use BufferedReader.readLine() to get the line(row) and String.toCharArray() to split the characters.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You mentioned a 3D array in the original post. If it's just a 2D rectangular array, you don't even need an offset. The offset is only needed for 3D (or greater) arrays.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If they are rectangular arrays and not jagged, meaning the number of elements in each dimension remains constant, you can simply stripe them into lines with a plain old loop and read them back out by the dimension offsets.
This array:
123
456
789
Can be written like this:
123456789
And can be reconstructed with a row offset of three.

If your dimensions vary, you may need to write the offsets into the file as well (i.e. on the first line)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

612

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That has nothing to do with trying to use a class constructor that does not exist, which is what you are doing right here

Lottery lot = new Lottery(userNumbers);

If you make changes to the code, repost it using [code]

[/code] tags, because it's just a mess with all the formatting removed.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That's because you only declared those variables locally in the calculateperimeter() method and they have no scope in your calculatearea() method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Rather I would say the error is from calling methods that do not exist on the Thread class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

608

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

604

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sure. Your first mini-project is to find and use the forum search feature to locate the thousands of "final year project" threads that are already littered throughout these forums.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

594

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

590

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Seems to me you would put the code to carry out the operations you've been instructed to perform for each of those menu options.

Perhaps if you can post some code and ask more specific questions, someone here can help you out. They won't write it for you though.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Very simple example of this

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;

public class TimerExample extends JFrame {

    final JLabel label;
    Timer countdownTimer;
    // Initial game time
    int timeRemaining = 10;

    public TimerExample() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(200, 200);
        label = new JLabel(String.valueOf(timeRemaining), JLabel.CENTER);
        getContentPane().add(label);

        countdownTimer = new Timer(1000, new CountdownTimerListener());
        setVisible(true);
        countdownTimer.start();
    }

    class CountdownTimerListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            if (--timeRemaining > 0) {
                label.setText(String.valueOf(timeRemaining));
            } else {
                label.setText("Time's up!");
                countdownTimer.stop();
            }
        }
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TimerExample();
            }
        });
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The amount of time allotted for the game is something you would set in your program. You use the timer to subtract a certain amount of time from your game time when it fires. So if you start with say 60 seconds and use the timer to subtract 1 from that every second (1000ms timer interval), you simply display the remainder in your applet.

Edit: That's not going to give you a fine-grained timer due to scheduling updates on the AWT thread, but it's close enough for your purposes.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please see the forum rules regarding "chatroom speak".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

584

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

580

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

-4 due to this post: http://www.daniweb.com/forums/post749526-136.html
+2 for me

576

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, it was removed shortly after he posted it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Do you believe that I posted that answer and link to the tutorial just because I enjoy suggesting random, irrelevant possibilities?

PoovenM commented: Agreed :) +3
stephen84s commented: lolzz ..... :D +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why did you create a new thread for this when you already have one on the same question?
Animation: http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html
GUI: http://java.sun.com/docs/books/tutorial/uiswing/index.html

Here is another great source on animation:
http://letmegooglethatforyou.com/?q=java+animation+tutorial

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"Doesn't work" is a little thin on the problem description as well.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

this is my first time to daniweb and I have heard nothing but great feedback from my peers!

And did your peers also mention that help is only given to those who demonstrate some effort?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Agreed. You haven't supplied nearly enough detail for anyone to offer suggestions. Being "familiar with Core Java" says very little about what concepts you do know and a four word project title doesn't adequately describe what you intend to accomplish or how you plan to go about it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Though it is not Java specific and not targeted for beginners, Code Complete 2nd Edition is an excellent book for anyone engaged in non-trivial programming or interested in software best practices. It's filled with a ton of information and suggestions gleaned from years of professional development experience - all that stuff that most of us working developers have learned the hard way in bits and pieces and wish we'd known from the outset.

~s.o.s~ commented: Indeed; like they say, "If I have seen further it is only by standing on the shoulders of Giants" +25
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

550

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

His original post had an attached pdf, which I assume was the assignment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually, I just noticed that your "board" variable should probably be a HiLoCanvas, not "HiLo" as you have it declared. I really don't think you intended to add an instance of a JApplet to a JApplet content pane.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, "implements board()" is invalid syntax due to the parenthesis, but even so, that does nothing for your listener. The addActionListener() method requires an object that implements the ActionListener interface - which is why I mentioned that "board" must implement that if you expect to pass it as a listener. So you need the HiLo class to implement ActionListener if you expect it to act like one.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And your problem is going to persist if you can't describe it more clearly and post the relevant code.

Dropping the "IM-speak" wouldn't hurt either. We aren't your "peeps" and this isn't a chat room.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It can't be applied if "board" does not implement ActionListener.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Obama Against Outsourcing ??

During his campaign, Obama said he would offer incentives to companies that created jobs at home and halt tax breaks to those that ship work abroad.

what do you think ? Rolling Eyes

I think it's great.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First, use [code] .. [/code] tags around any code that you post.

Secondly, don't put all of your update logic in the paint() method. Do that in your animation loop, or better yet, another method called by your animation loop. The paint() method should just paint the ball(s) and paddle in their current positions, which were determined by the other method.

I was woundering how to put more balls into it

Use an array or List of Ball objects.

and how to make the balls flash very fast almost like a strobe light.

In your animation loop, toggle a variable on each ball if you want them to flash individually or a single variable for all of them on/off. Use that variable in your paint() method to determine whether to paint the ball that cycle.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're better off using the Timer anyway to avoid repaint issues and stalling the AWT event thread.
Here's a simple example of the label with a timer:

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;

public class TimerExample extends JFrame {

    final String[] words = {"The", "cat", "in", "the", "hat"};
    final JLabel label;
    Timer wordTimer;
    int wordIndex = 0;

    public TimerExample() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(200, 200);
        label = new JLabel("", JLabel.CENTER);
        getContentPane().add(label);

        wordTimer = new Timer(1000, new WordTimerListener());
        setVisible(true);
        wordTimer.start();
    }

    class WordTimerListener implements ActionListener {
        int wordIndex = 0;

        public void actionPerformed(ActionEvent e) {
            if (wordIndex < words.length) {
                label.setText(words[wordIndex++]);
            } else {
                wordTimer.stop();
            }
        }
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TimerExample();
            }
        });
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please do not start multiple threads for what is essentially the same issue and use [code] [/code] tags (you can type them or use the button on the editor pane) around all code if you want anyone to bother to read it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

544

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use MappedByteBuffers as well, but as s.o.s. mentioned, they are more complex.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

540

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

536
;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think this poster is just starting threads to stamp their sig links.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Or split(), regex, indexOf(), trim()... all of those could be useful, depending on the intent.