Creating breakout game. Need help with thread starting.

Howdy. As the title says, I've got an assignment to make a breakout game. So far it's going alright, but I've run into a rather large snag...I can't get it to animate :P I've got my main applet, then I created a class heirarchy for the paddle, ball, and brick objects. For this question, lets just focus on the ball object.
This is my applet code so far (it is not even close to being done, so don't laugh :P )
import java.awt.*;
import javax.swing.*;
import java.util.*;
* Class BreakoutApplet - Plays a simple game of Breakout.
* @author Kris Nelson
* @version November 10, 2004
public class BreakoutApplet extends JApplet implements Runnable
    protected Brick brick; // creates an object of class brick
    protected Ball ball; // creates an object of class ball
    protected Paddle paddle; // creates an object of class paddle
    protected boolean running; // tells the program whether or not the thread is running
    protected ArrayList brickArray = new ArrayList(); // stores all the bricks in the game
    protected Thread timer; // the thread which controls the animation for the applet
    * Called by the browser or applet viewer to inform this JApplet that it
    * has been loaded into the system. It is always called before the first
    * time that the start method is called.
    public void init()
        // this is a workaround for a security conflict with some browsers
        // including some versions of Netscape & Internet Explorer which do
        // not allow access to the AWT system event queue which JApplets do
        // on startup to check access. May not be necessary with your browser.
        JRootPane rootPane = this.getRootPane();   
        rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
        createBricks(); // creates the games array of bricks
        ball = new Ball(400, 400, 2, 2); // sets the values for the ball
        paddle = new Paddle(300, 660, 2); // sets the values for the paddle
        // !!!!!!! have tried placing ball.start() here
    * Paint method for applet.
    * @param  g   the Graphics object for this applet
    public void paint(Graphics g)
        // draws the background, border, and all the games objects
        g.setColor(Color.lightGray); // sets the drawing color to light gray
        g.fillRect(0, 0, 600, 700); // displays the game screens background
        displayBorder(g); // displays the game screens border
        displayBricks(g); // displays the array of bricks
        ball.display(g); // displays the ball
        paddle.display(g); // displays the paddle
    * Creates the games array of bricks
    public void createBricks()
        int colorNumber = 1; // starts the color of the bricks at orange
        double yPosition = 100; // starts the bricks y screen position at 100
        for(int i = 0; i < 4; i++)
            double xPosition = 12; // starts the bricks x screen position at 12
            for(int j = 0; j < 8; j++)
                if(colorNumber == 0)
                    colorNumber = 1; // sets the color of the bricks to orange
                else
                    colorNumber = 0; // sets the color of the bricks to green
                brickArray.add(brick = new Brick(xPosition, yPosition, colorNumber)); // adds a brick to the current container in the brick array
                xPosition = xPosition + brick.getWidth(); // move the bricks x screen position to the next column
            yPosition = yPosition + brick.getHeight(); // moves the bricks y screen position to the next row
            if(colorNumber == 0)
                colorNumber = 1; // sets the color of the bricks to orange
            else
                colorNumber = 0; // sets the color of the bricks to green
    * Displays the game screens border
    * @param  g   the Graphics object for this applet
    public void displayBorder(Graphics g)
        g.setColor(Color.black); // sets the drawing color to black
        g.fillRect(0, 0, 600, 24); // draws a border on the top of the screen
        g.fillRect(0, 0, 12, 700); // draws a border on the left of the screen
        g.fillRect(588, 0, 12, 700); // draws a border on the right of the screen
    * Displays the array of bricks on the screen
    * @param  g   the Graphics object for this applet
    public void displayBricks(Graphics g)
        Brick currentBrick; // holds the brick data from the current ArrayList container
        for(int i = 0; i < 32; i++)
            currentBrick = (Brick)(brickArray.get(i)); // grabs the brick data from the current ArrayList container
            currentBrick.display(g); // displays the current brick
    * Called by the browser or applet viewer to inform this JApplet that it
    * should start its execution. It is called after the init method and
    * each time the JApplet is revisited in a Web page.
     public void start()
         if(timer == null)
             timer = new Thread(this); // creates a new object of type Thread
             timer.start(); // starts the new thread
             running = true; // tells the program that the new thread is running
    * Runs the code that controls the animation
    public void run()
        do{
            repaint(); // redraws the screen
            try{
                timer.sleep(100); // puts the thread to sleep for 100 milliseconds
            } catch(InterruptedException e) {running = false;}
            // !!!!!!! have tried placing ball.start() here
        } while(running);
        timer = null; // destroys the timer thread
    * Called by the browser or applet viewer to inform this JApplet that
    * it should stop its execution. It is called when the Web page that
    * contains this JApplet has been replaced by another page, and also
    * just before the JApplet is to be destroyed.
    public void stop()
        running = false; // tells the program that the thread is now done
}These are the bits of code for my class heirarchy, just to (hopefully) make it easier to follow.
import java.awt.*;
* The parent class of all the games objects.
* @author Kris Nelson
* @version November 9, 2004
public class Sprite
    protected double screenX, screenY; // stores the x and y location of the object
    * Constructor for objects of class Sprite
    * @param  xPosition   the initial x screen position
    * @param  yPosition   the initial y screen position
    public Sprite(double xPosition, double yPosition)
        screenX = xPosition; // sets the initial x screen position
        screenY = yPosition; // sets the initial y screen position
    * Sets new x and y screen locations for an object
    * @param  newX   the new x screen location
    * @param  newY   the new y screen location
    public void setScreenXY(double newX, double newY)
        screenX = newX; // sets the new x screen location
        screenY = newY; // sets the new y screen location
    * Sends back the current x screen location
    * @return     the current x screen location
    public double getScreenX()
        return screenX; // returns the current x screen location
    * Sends back the current y screen location
    * @return     the current y screen location
    public double getScreenY()
        return screenY; // returns the current y screen location
import java.awt.*;
* Parent class of any game object that moves.
* @author Kris Nelson
* @version November 9, 2004
public class MovingSprite extends Sprite implements Runnable
     protected double speedX, speedY; // stores the speed of an object in the x and y directions
     protected Thread timer; // the thread which controls animation for all moving objects
     protected boolean running; // tells the program whether or not the thread is running
     * Constructor for objects of class MovingSprite
     * @param  xPosition   the initial x screen position
     * @param  yPosition   the initial y screen position
     * @param  xSpeedValue   the speed in the x direction
     * @param  ySpeedValue   the speed in the y direction
     public MovingSprite(double xPosition, double yPosition, double xSpeedValue, double ySpeedValue)
          super(xPosition, yPosition); // passes the initial screen positions to Sprite
          speedX = xSpeedValue; // sets the speed in the x direction
          speedY = ySpeedValue; // sets the speed in the y direction
     * Sends back the speed in the x direction
     * @return     the speed in the x direction
     public double getSpeedX()
         return speedX; // returns the speed in the x direction
     * Sends back the speed in the y direction
     * @return     the speed in the y direction
     public double getSpeedY()
         return speedY; // returns the speed in the y direction
     * Starts the thread in order to start animation
     public void start()
         if(timer == null)
             timer = new Thread(this); // creates a new object of type Thread
             timer.start(); // starts the new thread
             running = true; // tells the program that the new thread is running
     * Empty since the child objects have their own run methods
     public void run()
     * Stops the thread from running
     public void stop()
         running = false; // tells the program that the thread is now done
import java.awt.*;
* Creates a single ball who's purpose is to bounce around and destroy the bricks.
* @author Kris Nelson
* @version November 10, 2004
public class Ball extends MovingSprite
    protected static final double BALL_WIDTH = 15; // sets the width of the ball
    protected static final double BALL_HEIGHT = 15; // sets the height of the ball
    * Constructor for objects of class Ball
    * @param  xPosition   the initial x screen position
    * @param  yPosition   the initial y screen position
    * @param  xSpeedValue   the speed in the x direction
    * @param  ySpeedValue   the speed in the y direction
    public Ball(double xPosition, double yPosition, double xSpeedValue, double ySpeedValue)
        super(xPosition, yPosition, xSpeedValue, ySpeedValue); // passes the initial screen positions and ball speeds to MovingSprite
        // !!!!!!!! have tried placing timer.start() here
    * Displays a ball onto the screen
    * @param  g   the Graphics object for this applet
    public void display(Graphics g)
        g.setColor(Color.blue); // sets the balls color
        g.fillOval((int)(screenX), (int)(screenY), (int)(BALL_WIDTH), (int)(BALL_HEIGHT)); // displays the ball
    * Runs the code that controls the balls animation
    public void run()
        do{
            try{
                timer.sleep(100); // puts the thread to sleep for 100 milliseconds
            } catch(InterruptedException e) {running = false;}
            screenX = screenX + speedX;
            screenY = screenY + speedY;  // this is VERY SIMPLE BALL MOVEMENT FOR TESTING PURPOSES, WILL BE CHANGED LATER
        } while(running);
}Sorry if that was too much code. I'm just trying to make this easier to follow.
I placed a // !!!!!!!!!!!!! comment in the places where I have tried starting the ball thread.
So basically, everything is running fine, except that I'm not at all sure of where to start the ball Thread, and thus can't start anything moving. If someone could tell me where I should be starting the thread, I would REALLY appriciate it. Thank you :D
- Kris

Some advice.
1. the start method on the ball should be called from the start method on the applet and should in turn call the start method on the sprite's thread.
2. the run method of the Moveable sprite should have been declare abstract
3. don't implement borders manually. There's a java.awt.Border class for that.
4. probably, you don't want to have the game invoke each sprite by name; just make a big list of all the sprites and invoke all of them every time
5. do you really need provision for a non-circular ball? this isn't rugby.
6. I don't think you ever had a threading problem, just a display problem.
7. Don't write comments like this:     ball.display(g); // displays the ballHere's my (even more simplified version):import java.awt.*;
import javax.swing.*;
import java.util.*;
* Class BreakoutApplet - Plays a simple game of Breakout.
* @author Kris Nelson, modified by Michael Lorton
* @version November 10, 2004
public class BreakoutApplet extends JApplet implements Runnable {  
    protected Ball ball;
    protected Paddle paddle;
    public boolean running; // tells the program whether or not the thread is running
    protected Thread timer; // the thread which controls the animation for the applet
    public void init() {
        // this is a workaround for a security conflict with some browsers
        // including some versions of Netscape & Internet Explorer which do
        // not allow access to the AWT system event queue which JApplets do
        // on startup to check access. May not be necessary with your browser.
        getRootPane().putClientProperty("defeatSystemEventQueueCheck",
                                        Boolean.TRUE);
         ball = new Ball(this, GAMEWIDTH / 2, GAMEHEIGHT / 2, 5, 5);
    public final static int GAMEWIDTH = 600;
    public final static int GAMEHEIGHT = 400;
    public void paint(Graphics g) {
        g.setColor(Color.lightGray);
        g.fillRect(0, 0,
                   GAMEWIDTH, GAMEHEIGHT);
        ball.display(g); // displays the ball
    * Called by the browser or applet viewer to inform this JApplet that it
    * should start its execution. It is called after the init method and
    * each time the JApplet is revisited in a Web page.
    public void start() {
        if(timer == null) {
            timer = new Thread(this); // creates a new object of type Thread
            timer.start(); // starts the new thread
            running = true; // tells the program that the new thread is running
        ball.start();
    * Runs the code that controls the animation
    public void run() {
        do{
            repaint(); // redraws the screen
            try{
                Thread.sleep(100);
            } catch(InterruptedException e) {running = false;}
        } while(running);
    public void stop() {
        running = false;
abstract class Sprite {
    protected double screenX, screenY; // stores the x and y location of the object
    protected final BreakoutApplet parent;
    * Constructor for objects of class Sprite
    * @param  xPosition   the initial x screen position
    * @param  yPosition   the initial y screen position
    public Sprite(BreakoutApplet parent, double xPosition, double yPosition) {
        this.parent = parent;
        screenX = xPosition; // sets the initial x screen position
        screenY = yPosition; // sets the initial y screen position
    * Sets new x and y screen locations for an object
    * @param  newX   the new x screen location
    * @param  newY   the new y screen location
    public void setScreenXY(double newX, double newY) {
        screenX = newX; // sets the new x screen location
        screenY = newY; // sets the new y screen location
    * Sends back the current x screen location
    * @return     the current x screen location
    public double getScreenX() {
        return screenX; // returns the current x screen location
    * Sends back the current y screen location
    * @return     the current y screen location
    public double getScreenY() {
        return screenY; // returns the current y screen location
    abstract public void display(Graphics g);
* Parent class of any game object that moves.
* @author Kris Nelson
* @version November 9, 2004
abstract class MovingSprite extends Sprite implements Runnable {
    protected double speedX, speedY; // stores the speed of an object in the x and y directions
    protected Thread timer; // the thread which controls animation for all moving objects
    protected boolean running; // tells the program whether or not the thread is running
    * Constructor for objects of class MovingSprite
    * @param  xPosition   the initial x screen position
    * @param  yPosition   the initial y screen position
    * @param  xSpeedValue   the speed in the x direction
    * @param  ySpeedValue   the speed in the y direction
    public MovingSprite(BreakoutApplet parent,
                        double xPosition, double yPosition,
                        double xSpeedValue, double ySpeedValue) {
        super(parent, xPosition, yPosition);
        speedX = xSpeedValue; // sets the speed in the x direction
        speedY = ySpeedValue; // sets the speed in the y direction
    * Starts the thread in order to start animation
    public void start() {
        if(timer == null) {
            timer = new Thread(this); // creates a new object of type Thread
            timer.start(); // starts the new thread
            running = true; // tells the program that the new thread is running
    * Runs the code that controls the balls animation
    public void run() {
        while (parent.running) {
            try{
                Thread.sleep(100);
            } catch(InterruptedException e) {
                System.err.println(e);
            step();
    abstract protected void step();
* Creates a single ball whose purpose is to bounce around and destroy the bricks.
* @author Kris Nelson
* @version November 10, 2004
class Ball extends MovingSprite {
    protected static final int BALL_DIAMETER = 15;
    * Constructor for objects of class Ball
    * @param  xPosition   the initial x screen position
    * @param  yPosition   the initial y screen position
    * @param  xSpeedValue   the speed in the x direction
    * @param  ySpeedValue   the speed in the y direction
    public Ball(BreakoutApplet parent,
                double xPosition, double yPosition,
                double xSpeedValue, double ySpeedValue) {
        super(parent, xPosition, yPosition, xSpeedValue, ySpeedValue);
    * Displays a ball onto the screen
    * @param  g   the Graphics object for this applet
    public void display(Graphics g) {
        g.setColor(Color.blue);
        g.fillOval((int)(screenX),
                   (int)(screenY),
                   BALL_DIAMETER, BALL_DIAMETER);
    protected void step() {
            screenX = screenX + speedX;
            if (screenX < 0) {
                screenX = -screenX;
                speedX = -speedX;
            else if ((screenX + BALL_DIAMETER)> BreakoutApplet.GAMEWIDTH) {
                screenX = 2*(BreakoutApplet.GAMEWIDTH  - BALL_DIAMETER) - screenX;
                speedX = -speedX;
            screenY = screenY + speedY;
            if (screenY < 0) {
                screenY = -screenY;
                speedY = -speedY;
            else if ((screenY  + BALL_DIAMETER) > BreakoutApplet.GAMEHEIGHT) {
                screenY = 2*(BreakoutApplet.GAMEHEIGHT - BALL_DIAMETER) - screenY;
                speedY = -speedY;
}

Similar Messages

  • Need help with threads?.. please check my approach!!

    Hello frnds,
    I am trying to write a program.. who monitors my external tool.. please check my way of doing it.. as whenever i write programs having thread.. i end up goosy.. :(
    first let me tell.. what I want from program.. I have to start an external tool.. on separate thread.. (as it takes some time).. then it takes some arguments(3 arguments).. from file.. so i read the file.. and have to run tool.. continously.. until there are arguments left.. in file.. or.. user has stopped it by pressing STOP button..
    I have to put a marker in file too.. so that.. if program started again.. file is read from marker postion.. !!
    Hope I make clear.. what am trying to do!!
    My approach is like..
    1. Have two buttons.. START and STOP on Frame..
    START--> pressed
    2. check marker("$" sign.. placed in beginning of file during start).. on file..
         read File from marker.. got 3 arg.. pass it to tool.. and run it.. (on separate thread).. put marker.. (for next reading)
         Step 2.. continously..
    3. STOP--> pressed
         until last thread.. stops.. keep running the tool.. and when last thread stops.. stop reading any more arguments..
    Question is:
    1. Should i read file again and again.. ?.. or read it once after "$" sign.. store data in array.. and once stopped pressed.. read file again.. and put marker ("$" sign) at last read line..
    2. how should i know when my thread has stopped.. so I start tool again??.. am totally confused.. !!
    please modify my approach.. if u find anything odd..
    Thanks a lot in advance
    gervini

    Hello,
    I have no experience with threads or with having more than run "program" in a single java file. All my java files have the same structure. This master.java looks something like this:
    ---master.java---------------------------------------------------
    import java.sql.*;
    import...
    public class Master {
    public static void main(String args []) throws SQLException, IOException {
    //create connection pool here
    while (true) { // start loop here (each loop takes about five minutes)
    // set values of variables
    // select a slave process to run (from a list of slave programs)
    execute selected slave program
    // check for loop exit value
    } // end while loop
    System.out.println("Program Complete");
    } catch (Exception e) {
    System.out.println("Error: " + e);
    } finally {
    if (rSet1 != null)
    try { rSet1.close(); } catch( SQLException ignore ) { /* ignored */ }
    connection.close();
    -------end master.java--------------------------------------------------------
    This master.java program will run continuously for days or weeks, each time through the loop starting another slave process which runs for five minutes to up to an hour, which means there may be ten to twenty of these slave processes running simultaneously.
    I believe threads is the best way to do this, but I don't know where to locate these slave programs: either inside the master.java program or separate slave.java files? I will need help with either method.
    Your help is greatly appreciated. Thank you.
    Logan

  • Need help with threading in Swing GUI !!!

    I've written an app that parses and writes
    files. I'm using a Swing GUI. The app
    could potenially be used to parse hundreds or even
    thousands of files. I've included a JProgressBar
    to monitor progress. The problem is when I parse
    a large number of files the GUI freezes and only
    updates the values of the progress bar when the
    parsing and writing process is finished.
    I assume I need to start the process in a seperate thread. But, I'm new to threads and I'm not sure
    whether to start the Progressbar code in a seperate
    thread or the parsing code. As a matter of fact I really
    don't have any idea how to go about this.
    I read that Swing requires repaints be done in the
    event dispatch thread. If I start the parsing in a seperate
    thread how do I update the progressbar from the other
    thread? I'm a thread neophyte.
    I need a cigarette.

    In other words do this:
    Inside event Thread:
    handle button action
    start thread
    return from action listener
    Inside worker Thread:
    lock interface
    loop
    perform action
    update progress bar
    unlock interface
    return from worker ThreadDoesn't updating the progress bar (and locking/unlocking the interface components) from within the worker thread violate the rule that you shouldn't mess with Swing components outside the event thread? (Do I have that rule right?)
    In any case, is there any way to just post some kind of event to the progress bar to update it from within the worker thread, thereby insuring that the GUI progress bar update is being invoked from the event thread? This would also obviate the need to use a timer to poll for an update, which I think is a waste especially when the monitored progress is at a variable rate, (or for number crunching, is executing on different speed machines).
    Also, doesn't using invokeLater() or invokeAndWait() still block the event dispatching thread? I don't understand how having a chunk of code started in the event thread doesn't block the event thread unless the code's executed in a "sub-thread", which would then make it not in the event thread.
    I'm also looking to have a progress bar updated to monitor a worker thread, but also want to include a "Stop" button, etc. and need the event queue not to be blocked.
    The last thing I can think of is to implement some kind of original event-listener class that listens to events that I define, then register it with the system event queue somehow, then have the worker thread post events to this listener which then calls setValue() in the progress bar to insure that the bar is updated from the event queue and when I want it to be updated. I don't know yet if it's possible to create and register these kinds of classes (I'm guessing it is).
    Thanks,
    Derek

  • Need help with Threading GUI progress bar

    Anyone able to help? I'm sure you've seen this a million times. I've google'd around and tried examples but still can't get a progress bar to work properly under the following situation:
    1. Created a panel with several components to select directory, display directory in tree etc.
    2. When a specific button (Search) is clicked, I want a secondary window to popup and report progress of searching down the directory.
    As you'll probably guess, the progress window isn't being updated until the end. I'm using Threads and using InvokeLater but nothing happens. Is there any good example that does the above? I can't seem to find one to figure this out.
    Thanks
    Speedy.
    Sample code:
    main.java:
    ========
    public class Main {
    public static void main(String[] args) {
    MainPanel mainPanel = new MainPanel();
    mainPanel.show();
    MainPanel.java:
    ============
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class MainPanel extends JFrame implements ActionListener {
    public MainPanel() {
    this.setSize(100,100);
    JButton startButton = new JButton("Start");
    this.getContentPane().add(startButton);
    startButton.addActionListener(this);
    public void actionPerformed(ActionEvent event) {
    ProgressPanel pp = new ProgressPanel();
    pp.show();
    SimpleTask st = new SimpleTask(pp);
    st.start();
    while (st.isAlive()) {
    System.err.println("waiting..");
    try {
    Thread.sleep(100);
    } catch (Exception e) {};
    System.err.println("finished!");
    SimpleTask.java:
    =============
    import javax.swing.SwingUtilities;
    public class SimpleTask extends Thread {
    ProgressPanel pp = null;
    public SimpleTask(ProgressPanel _pp) {
    pp = _pp;
    this.setDaemon(true);
    int i = 0;
    String position = "";
    public void run() {
    Runnable updateGUI = new Runnable() {
    public void run() {
    pp.setText(position);
    try {
    for (i=0; i<50; i++) {
    position = "Now on = " + new Integer(i).toString();
    System.err.println(position);
    SwingUtilities.invokeLater(updateGUI);
    sleep(100);
    } catch (Exception e) {}
    ProgressPanel.java:
    ===============
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class ProgressPanel extends JFrame {
    private JLabel label = new JLabel();
    public ProgressPanel() {
    this.setSize(200,200);
    this.setLocation(100,100);
    this.getContentPane().add(label);
    setText("Start");
    public void setText(String text) {
    label.setText(text);
    }

    Ok, I'll look down that road. I should have said the Thread is being used because the current while loop will be changed to perform real work. Just an example at the moment to show what I'm trying to do. Does this make a difference? The real task will be to drill down directories, counting file types/dirs etc...

  • Need Help with Kick-Starting Web-Provider Development

    Hi,
    My requirement is to develop my own web-provider. This web-provider should talk to the portal and manage its portlets. (basically extend oracle.portal.provider.v1.http.HttpProvider)
    Though I have gone thru various documents about developing web-providers, I haven't been able to locate examples for the same.
    I would really appreciate it if someone can help me with
      1) the best place to look for information AND
      2) sample code for a web-provider.
    thanks in advance for the help.

    Anoop, <br>
    Thats a pretty good idea to add new portlets on the fly (at runtime) to your provider.xml
    I think this is how you could do this, <br>
    1. Generate your portlet's <portlet>....</portlet> tags & add them to the current provider's provider.xml file. You could follow this sequence, <br>
    - Get the path to your current provider.xml <br>
    - Generate an XMLDocument object out of this current de finition file. <br>
    - Create the new portlet's <portlet>...</portlet> structure. You would need to make sure that the new portlet added has a unique id & name in that definition file. <br>
    - Add this <portlet> node at the appropriate place in the XMLDocument<br><br>
    2. Refresh the provider to reflect the new portlet in the Portlet repository.<br><br>
    There isn't an explicit code sample in the JPDK that you could perhaps reuse for step I. So much of the effort here will have to come from your side. Anyway, let me know if you face any problems during its implementation.
    Regards,
    Abhinav

  • New User: Needs Help with getting started with the Z

    Hi, my son got a creative Zen for xmas, only getting round to getting it together now, and having some problems with the manual. All this is new to us -technology etc. We have managed to rip a CD but cant get any further! Downloading from internet sounds like such a good idea, but 'know-how-to do' seems light years away in this house! Is there an easy start manual or step by step directions that I've missed out on somewhere? the quick start manual is fine for learning how to use the player but doesn't give any info on ripping CDs and whatever comes after. Can any of you 'experts' bring yourselves back to the begining and explain what to do in simple english?
    Message Edited by Jeremy-CL on 02-0-2005 0:25 AM

    Mother,
    I moved and edited your message as your are more likely to get help out here. As far as suggestions go for downloading from the internet goes, there is not a lot of difference between getting it from CDs. The main difference is the process of actually getting the music.
    First off there are several music stores out there and some that are free. Here are a few suggestions (this is all personal knowledge, this is not an official endorsement of any of these):
    Napster - Integrates into Windows Media Player if you desire and can transfer directly to most Zens. Also allows a user to subscribe to an account that allows for streaming and computer only downloads of music (must purchase song to transfer to the player...usually around .99 a song)
    Buymusic.com - Website interface that sells individual tracks and albums.
    Wallmart music store - Website interface that sells individual tracks and albums.
    There are others but these three are the mains ones (outside of itunes, which is designed for the Ipod).
    Basically once you download them, you go into MediaSource or Windows Media Player and add the files to the music library. Then you just transfer like you do with CDs.
    JeremyMessage Edited by Jeremy-CL on 02-0-2005 0:34 AM

  • Createing a game need help

    ok im makeing a game i have made the map n photoshop just one big image
    and i want it so java grabes the coords and print the type of tile that they are at
    the map is pretty big
    12500 X 14300
    and i want to use that as the world map how would i grabe the pixiels from the map and use them as the ground the character will walk on

    If you're lucky enough to be doing MIDP 2.0, it's provided for by the profile.
    Otherwise, I imagine it's a matter of dividing the current user (x,y) location by the width and height of the tiles, thus getting an (x,y) position into the map. At that point it's just a matter of looking up the tiles from the map, and displaying them.
    For example, suppose you have a character at position (23233,98483), and the window is 800x600 with the character at the center. And suppose the tiles are all 100x100 wide. Then you'd draw the tiles around (232,984) in your map.
    Probably the easiest thing is to create a GameWorldMap object (I just made that name up to keep it from being confused with java.util.Map) that knows how to draw itself when handed a Graphics object and a position and a width and height. It would know how to translate map (world) coordinates into tile coordinates, and it would know how to offset the drawn tile images so the tiles could scroll smoothly off the edges of the screen.

  • Help with Threads

    I need help with threads. How can I break this code into teo threads without chaning the data objects at all? Producer will produce string line by line and consumer will take the line and search for the word. Help me please.
    Thank you
    public class WordFinder
    * Main program opens the file given by the user as an argument and
    * searches for the word given by the user. If the word is found,
    * the line number on which the word occurs is displayed.
    * @param args[0] Word to search for
    * @param args[1] Name of file to search
    public static void main(String[] args) throws IOException
    // To keep track of how long the program runs we'll set the startTime
    // variable to the current time in milliseconds and use that at
    // the end of the program to find out how long we ran.
    long startTime = System.currentTimeMillis();
    String wordToFind;
    String currentLine;
    int lineCount = 0; // Keep track of line numbers
    BufferedReader inputFile = null; // Needed to get compiler to quit
    // complaining about uninitialized
    // variables.
    // Make sure we have 2 arguments passed to us
    if (args.length < 2)
    // Nope. Show user how to run and then exit with an error (1)
    System.out.println("usage: java WordFinder <word> <file pathname>");
    System.exit(1);
    // So far, so good. Now try to open the file the user gave us as
    // a parameter. We'll use a BufferedReader object to read the file
    // so we can read one line at a time from the input. If opening the
    // file fails, print an error message and exit with an error (1).
    try
    inputFile = new BufferedReader(new FileReader(args[1]));
    catch (FileNotFoundException e)
    System.out.println(args[1] + ": File not found or is not readable");
    System.exit(1);
    // Set the wordToFind variable to refer to args[0]. We don't
    // really need to do this, but it makes our code more readable
    wordToFind = args[0];
    // We're going to read the file one line at a time. For each
    // line, we'll create a StringTokenizer object to break the line
    // into distinct words, checking each word to see if it's the same
    // as the given search word.
    // Read first line from the file
    currentLine = inputFile.readLine();
    while (currentLine != null) // Repeat until we reach EOF
    // Have a valid input line, increment the counter
    lineCount++;
    // Create a StringTokenizer object over the current line
    StringTokenizer tokens = new StringTokenizer(currentLine);
    // Check each word in the string by accessing each token
    while (tokens.hasMoreTokens())
    // See if the next word is the one we're looking for and
    // advance the token iterator to the next token
    if (wordToFind.equals(tokens.nextToken()))
    // Yes, display the current line number
    System.out.println(wordToFind + " found on line " + lineCount);
    // Read next line from the file
    currentLine = inputFile.readLine();
    } // while
    // Done with the input file
    inputFile.close();
    // Display the running time of this program in milliseconds by
    // subtracting the start time from the current time
    System.out.println((System.currentTimeMillis() - startTime) + " milliseconds");
    } // main
    } // WordFinder

    You may create Queue object. (I guess that you're already know QUEUE)
    Then ... use producer thread to load input file into queue. (Enqueue)
    Consumer ... dequeue
    Queue can be empty because of
    - Input file was read to EOF and Consumer had produced all queue.
    or
    - Cunsumer works too fast... So the queue is empty.
    So, you may have to use ... wait() in Consumer in case of the queue is empty.
    And use notify() in Producer to wake up consumer ...
    Is this right ?

  • I need help with shooting in my flash game for University

    Hi there
    Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
    listed below should be the correct code
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    listed below is my entire code
    import flash.display.MovieClip;
        //declare varibles to create mines
    //how much time before allowed to shoot again
    var cTime:int = 0;
    //the time it has to reach in order to be allowed to shoot (in frames)
    var cLimit:int = 12;
    //whether or not the user is allowed to shoot
    var shootAllow:Boolean = true;
    var minesInGame:uint;
    var mineMaker:Timer;
    var cursor:MovieClip;
    var index:int=0;
    var tankMine_mc:MovieClip;
    var antiTankmine_mc:MovieClip;
    var maxHP:int = 100;
    var currentHP:int = maxHP;
    var percentHP:Number = currentHP / maxHP;
    function initialiseMine():void
        minesInGame = 15;
        //create a timer fires every second
        mineMaker = new Timer(6000, minesInGame);
        //tell timer to listen for Timer event
        mineMaker.addEventListener(TimerEvent.TIMER, createMine);
        //start the timer
        mineMaker.start();
    function createMine(event:TimerEvent):void
    //var tankMine_mc:MovieClip;
    //create a new instance of tankMine
    tankMine_mc = new Mine();
    //set the x and y axis
    tankMine_mc.y = 513;
    tankMine_mc.x = 1080;
    // adds mines to stage
    addChild(tankMine_mc);
    tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal(evt:Event):void{
        evt.target.x -= Math.random()*5;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseMine();
        //declare varibles to create mines
    var atmInGame:uint;
    var atmMaker:Timer;
    function initialiseAtm():void
        atmInGame = 15;
        //create a timer fires every second
        atmMaker = new Timer(8000, minesInGame);
        //tell timer to listen for Timer event
        atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
        //start the timer
        atmMaker.start();
    function createAtm(event:TimerEvent):void
    //var antiTankmine_mc
    //create a new instance of tankMine
    antiTankmine_mc = new Atm();
    //set the x and y axis
    antiTankmine_mc.y = 473;
    antiTankmine_mc.x = 1080;
    // adds mines to stage
    addChild(antiTankmine_mc);
    antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal_2(evt:Event):void{
        evt.target.x -= Math.random()*10;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseAtm();
    function moveForward():void{
        bg_mc.x -=10;
    function moveBackward():void{
        bg_mc.x +=10;
    var tank_mc:Tank;
    // create a new Tank and put it into the variable
    // tank_mc
    tank_mc= new Tank;
    // set the location ( x and y) of tank_mc
    tank_mc.x=0;
    tank_mc.y=375;
    // show the tank_mc on the stage.
    addChild(tank_mc);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
    //creates the movement
    function onMovementKeys(evt:KeyboardEvent):void
        //makes the tank move by 10 pixels right
        if (evt.keyCode==Keyboard.D)
        tank_mc.x+=5;
    //makes the tank move by 10 pixels left
    if (evt.keyCode==Keyboard.A)
    tank_mc.x-=5
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    if (tank_mc.hitTestObject(antiTankmine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(antiTankmine_mc);
    if (tank_mc.hitTestObject(tankMine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(tankMine_mc);
        //var maxHP:int = 100;
    //var currentHP:int = maxHP;
    //var percentHP:Number = currentHP / maxHP;
        //Incrementing the cTime
    //checking if cTime has reached the limit yet
    if(cTime < cLimit){
        cTime ++;
    } else {
        //if it has, then allow the user to shoot
        shootAllow = true;
        //and reset cTime
        cTime = 0;
    function updateHealthBar():void
        percentHP = currentHP / maxHP;
        healthBar.barColor.scaleX = percentHP;
        if(currentHP <= 0)
            currentHP = 0;
            trace("Game Over");
        updateHealthBar();

    USe the trace function to analyze what happens and what fails to happen in the code you showed.  trace the conditional values to see if they are set up to allow a shot when you press the key

  • I need Help with a website I've created

    I need help with a website I've created (www.jonathanhazelwood.com/lighthouse) I created the folowing site with dreamweaver at my current resolution 1366 by 768. Looks great on my screen resolution but if it is viewed on other resolutions the menu moves and some of the text above and below. How can I keep all content centered and working like it does on 1366 by 768 on all resolutions. The htm to my site is below I started off with a blank template through dreamweaver CS5.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>The Lighthouse Church</title>
    <style type="text/css">
    <!--
    body {
        font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
        background: #42413C;
        margin: 0;
        padding: 0;
        color: #000;
        background-color: #000;
    /* ~~ Element/tag selectors ~~ */
    ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
        padding: 0;
        margin: 0;
    h1, h2, h3, h4, h5, h6, p {
        margin-top: 0;     /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
        padding-right: 15px;
        padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
    a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
        border: none;
    /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
    a:link {
        color: #42413C;
        text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
    a:visited {
        color: #6E6C64;
        text-decoration: underline;
    a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
        text-decoration: none;
    /* ~~ this fixed width container surrounds all other elements ~~ */
    .container {
        width: 960px;
        background: #FFF;
        margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
    /* ~~ This is the layout information. ~~
    1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
    .content {
        padding: 10px 0;
    /* ~~ miscellaneous float/clear classes ~~ */
    .fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
        float: right;
        margin-left: 8px;
    .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
        float: left;
        margin-right: 8px;
    .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
        clear:both;
        height:0;
        font-size: 1px;
        line-height: 0px;
    #apDiv1 {
        position:absolute;
        width:352px;
        height:2992px;
        z-index:1;
        top: 171px;
        left: 507px;
    #apDiv2 {
        position:absolute;
        width:961px;
        height:1399px;
        z-index:1;
        left: 187px;
        top: 1px;
    #apDiv3 {
        position:absolute;
        width:961px;
        height:1001px;
        z-index:1;
        top: -2px;
    #apDiv4 {
        position:absolute;
        width:963px;
        height:58px;
        z-index:1;
        left: 0px;
        top: 101px;
    #apDiv5 {
        position:absolute;
        width:961px;
        height:1505px;
        z-index:1;
        top: -5px;
    #apDiv6 {
        position:absolute;
        width:962px;
        height:150px;
        z-index:1;
        left: 0px;
        top: -1px;
    #apDiv7 {
        position:absolute;
        width:361px;
        height:25px;
        z-index:2;
        left: 35px;
        top: 1308px;
    #apDiv8 {
        position:absolute;
        width:320px;
        height:24px;
        z-index:2;
        left: 200px;
        top: 1479px;
    #apDiv9 {
        position:absolute;
        width:962px;
        height:63px;
        z-index:3;
        left: -10px;
        top: -1292px;
    #apDiv10 {
        position:absolute;
        width:270px;
        height:27px;
        z-index:2;
        left: 200px;
        top: 1478px;
    #apDiv11 {
        position:absolute;
        width:961px;
        height:44px;
        z-index:3;
        left: 195px;
        top: 183px;
    -->
    </style>
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #apDiv12 {
        position:absolute;
        width:295px;
        height:23px;
        z-index:4;
        left: 198px;
        top: 1px;
    #apDiv13 {
        position:absolute;
        width:135px;
        height:22px;
        z-index:5;
        left: 1001px;
        top: 3px;
    #apDiv14 {
        position:absolute;
        width:309px;
        height:992px;
        z-index:1;
        left: 33px;
        top: 479px;
    #apDiv15 {
        position:absolute;
        width:327px;
        height:999px;
        z-index:1;
        left: 324px;
    #apDiv16 {
        position:absolute;
        width:262px;
        height:1000px;
        z-index:2;
        left: 674px;
        top: 477px;
    #apDiv17 {
        position:absolute;
        width:85px;
        height:34px;
        z-index:1;
        left: -379px;
        top: 1001px;
    #apDiv18 {
        position:absolute;
        width:200px;
        height:115px;
        z-index:6;
    #apDiv19 {
        position:absolute;
        width:168px;
        height:31px;
        z-index:3;
        left: 448px;
        top: 1451px;
    #apDiv20 {
        position:absolute;
        width:94px;
        height:33px;
        z-index:3;
        left: 384px;
        top: 1477px;
    body {
        background-color: #000;
        margin-left: 0px;
        margin-right: 0px;
    #apDiv21 {
        position:absolute;
        width:920px;
        height:200px;
        z-index:4;
        left: 19px;
        top: 233px;
    </style>
    </head>
    <body>
    <div class="container">
      <div class="content">
        <div id="apDiv5">
          <div id="apDiv16">
            <div id="apDiv17">
              <map name="Map2" id="Map2">
                <area shape="rect" coords="4,2,77,28" href="http://www.myspace.com/lighthousechurch1" />
              </map>
              <img src="paypal-donate-button.png" width="83" height="33" border="0" usemap="#Map" />
              <map name="Map" id="Map">
                <area shape="rect" coords="2,2,80,30" href="https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=HgApKd0bxyPQv1ixwBW3HgWXaLxPIiT Po9gSsRELLQp72IZ2-_8uvSmCLRO&dispatch=5885d80a13c0db1f8e263663d3faee8d9384d85353843a619606 282818e091d0" />
              </map>
            </div>
          </div>
          <div id="apDiv21">
            <blockquote>
              <blockquote>
                <blockquote>
                  <blockquote>
                    <blockquote>
                      <blockquote>
                        <p><img src="faithexplosion.png" width="314" height="225" /></p>
                      </blockquote>
                    </blockquote>
                  </blockquote>
                </blockquote>
              </blockquote>
            </blockquote>
          </div>
          <div id="apDiv14">
            <div id="apDiv15">
              <div>
                <div>
                  <p> Special Message from Perry Stone </p>
                  <h2> Was Jesus Born on December 25?</h2>
                  <p> 12/20/2010 </p>
                  <p><img alt="iStock_000003631829XSmall" src="http://www.voe.org/images/iStock_000003631829XSmall.jpg" width="300" height="234" /></p>
                  <p>Last   year, in response to the growing number of Christians who celebrate   Hanukkah but hate Christmas, I wrote an article for this website titled   &ldquo;Hanukkah or Christmas?&rdquo; I explained why I think Jesus was either   conceived or birthed on December 25.</p>
                </div>
              </div>
              <div>
                <div><a href="http://www.voe.org/Prophecy-Update/what-happened-to-global-warming.html"> READ MORE</a>
                  <p> Prophecy Update </p>
                  <h2> What Happened to Global Warming?</h2>
                  <p> 12/17/2010 </p>
                  <p> </p>
                </div>
              </div>
              <div>
                <div></div>
              </div>
              <div>
                <div></div>
              </div>
            </div>
            <div>
              <p><font size="2">Special Word</font></p>
              <p><font size="2">January 7th, 2011</font></p>
              <p> <font size="2">Dear Viewers:</font></p>
              <p><font size="2">We have now entered into one of the most trying times; but also one of the most glorious            times in church history.  Many things are coming upon the world and also upon the church and we (the church) must be totally            prepared to take up our cross daily and venture out into the lost and</font></p>
              <p>  <a href="http://sermon.lighthousechurchinc.org/2011/01/07/special-word-1711-evangelist-barbara-lync h.aspx" target="_parent">Click Here for More</a></p>
            </div>
            <p> </p>
            <div></div>
            <div>
            <!--//              weAddFlash("lhi09hdr.swf",800, 100,"true","true","high","showall","true","#ffffff");              //--></div>
            <div></div>
            <p> </p>
          </div>
          <img src="lighthousegraphic2.jpg" width="960" height="1509" />
          <div id="apDiv20"><img src="myspacebutton.jpg" width="89" height="30" border="0" usemap="#Map3" />
            <map name="Map3" id="Map3">
            <area shape="rect" coords="3,2,87,28" href="http://www.myspace.com/lighthousechurch1" />
          </map>
      </div>
        </div>
      <p> </p>
      </div>
    <!-- end .container --></div>
    <div id="apDiv10"><font size="1"><font color="#FFFFFF">Copyright 2011 The Lighthouse Church Inc.</font></font></div>
    <div id="apDiv11">
      <ul id="MenuBar1" class="MenuBarHorizontal">
        <li><a href="#">Home</a>    </li>
        <li><a href="#" class="MenuBarItemSubmenu">Our Pastor</a>
          <ul>
            <li><a href="#">Fresh Word</a></li>
            <li><a href="#">Itinerary</a></li>
            <li><a href="#">Prophetic Word</a></li>
            <li><a href="#">Sermons</a></li>
            <li><a href="#">Special Words</a></li>
            <li><a href="#">Word of Month</a></li>
          </ul>
        </li>
        <li><a href="#">Men Ministry</a></li>
        <li><a href="#" class="MenuBarItemSubmenu">Ministers</a>
          <ul>
            <li><a href="#">Chris Gore</a></li>
    </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Our Church</a>
          <ul>
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Donate</a></li>
            <li><a href="#">Events</a></li>
            <li><a href="#">Our Store</a></li>
            <li><a href="#">Prayer Request</a></li>
            <li><a href="#">Salvation</a></li>
            <li><a href="#">Subscribe</a></li>
            <li><a href="#">Vision</a></li>
            <li><a href="#">We Believe</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Resources</a>
          <ul>
            <li><a href="#">Prepare for Disaster</a></li>
            <li><a href="#">How to Fast</a></li>
            <li><a href="#">Heaven &amp; Hell</a></li>
            <li><a href="#">Warfare Prayers</a></li>
            <li><a href="#">Wisdom Words</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Prophetic</a>
          <ul>
            <li><a href="#">Article Archive</a></li>
            <li><a href="#">Audio Prophecies</a></li>
            <li><a href="#">Color for Year</a></li>
            <li><a href="#">Major Articles</a></li>
            <li><a href="#">Prophecy Archive</a></li>
            <li><a href="#">Prophetic Articles</a></li>
            <li><a href="#">Word for Year</a></li>
          </ul>
        </li>
      </ul>
    </div>
    <div id="apDiv12"><font size="1"><font color="#FFFFFF">6 South Railroad Ave Wyoming,DE 19934</font></font></div>
    <div id="apDiv13"><font size="1"><font color="#FFFFFF">Phone:(302) 697-1472</font></font></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>

    Look at all the apdiv's you have.  Those are absolutely positioned layers.  I'm assuming by your post that you are very new to Dreamweaver and HTML and CSS.  I would highly recommend not using absolutely positioned layers until you have a better grasp on HTML and CSS.
    Looking at your code I would suggest that you consider using one of Dreamweaver's built in, or downloadable templates as a starting point and work from there. 
    http://www.adobe.com/devnet/dreamweaver/articles/dreamweaver_custom_templates.html

  • I need help with color pallette in iPhoto 11. I have created a book and would like to use a different color background than those given in "background." I have found the color palettes but can't seem to incorporate them into my backgrounds palette.

    I need help with color pallette in iPhoto 11. I have created a book and would like to use a different color background than those given in "background." I have found the color palettes but can't seem to incorporate them into my backgrounds palette.

    That is not a feature of iPhoto - suggest to Apple - iPhoto Menu ==> provide iPhoto feedback.
    Additionally I have no idea what you are saying here
    I have found the color palettes but can't seem to incorporate them into my backgrounds palette.
    And it always helps for you to dientify the version of iPhoto that you are using
    LN

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

  • Need help with a simple basketball game.

    Hi im new here and I need help with making this simple basketball game.
    Im trying to recreate this game from this video. Im not sure if he is using as2 or as3
    Or if anyone could help me make a game like this or direct me to a link on how to do it It would be greatly appreciated.

    If you couldn't tell whether it is AS2 or AS3, it is doubtful you can turn it from AS2 into AS3, at least not until you learn both languages.  There is no tool made that does it for you.

  • Need help with ending a game

    i'm making a game at the moment.......
    i need help with a way to check all the hashmaps of enimies in a class called room......i need to check if they all == 0...when they all equal zero the game ends......
    i know i can check the size of a hash map with size().....but i want to check if all the hashmaps within all the rooms == 0.

    First of all stop cross posting. These values in the HashMap, they are a "Collection" of values, so what is wrong with reply two and putting all these collections of values into a super collection? A collection of collections? You can have a HashMap of HashMaps. One HashMap that holds all your maps and then you can use a for loop to check if they are empty. A map is probably a bad choice for this operation as you don't need a key and an array will be much faster.
    HashMap [] allMaps = {new HashMap(),new HashMap()};

  • I need help with creating PDF with Preview...

    Hello
    I need help with creating PDF documetns with Preview. Just a few days ago, I was able to create PDF files composed of scanned images (notes) and everything worked perfectly fine. However, today I was having trouble with it. I scanned my notebook and saved 8 images/pages in jpeg format. I did the usual routine with Preview (select all files>print>PDF>save as PDF>then save). Well this worked a few days ago, but when I tried it today, I was able to save it, but the after opening the PDF file that I have saved, only the first page was there. The other pages weren't included. I really don't see anything wrong with what I'm doing. I really need help. Any help would be greatly appreciated.

    I can't find it.  I went into advanced and then document processing but no batch sequence is there and everything is grayed out.
    EDIT: I realized that you cant do batch sequences in standard.  Any other ideas?

Maybe you are looking for