Newbie - Help needed starting with Threads

Hi Friends,
I have a class which extends thread and all it does is displays its name and then goes to sleep. So, I have this in my run method:
public void run() {
        System.out.println("Name: "+name);
        try{
             Thread.sleep(1000);
        }catch(Exception e){
          e.printStackTrace();
    }Now I have a tester class which created objects of these class and they should keep running until the user explicitly stops the program. So, I have this in my tester class:
Thread one = new MyClass("one");
Thread one = new MyClass("two");
one.start();
two.start();They run fine for one time but how can i make them run continously?? Any help will be appreciated.
Thanks

Micks80 wrote:
I tried to add that while loop but it throws IllegalStateException because I guess you cannot call the start method more then once...
So any other ways to accomplish this???As suggested in reply #1 put the while loop inside the run method of the Runnable.
Also it is better for MyClass to implement Runnable rather than extending Thread. It is always better to implement Runnable than extend Thread.

Similar Messages

  • Newbie - help needed with array and dictionary objects

    Hi all
    Please see the code below. I've posted this code in another thread however the original issue was resolved and this is now a new issue I'm having although centered around the same code.
    The issue is that I'm populating an array with dictionary objects. each dictionary object has a key and it's value is another array of custom objects.
    I've found that the code runs without error and I end up with my array as I'm expecting however all of the dictionary objects are the same.
    I assume it's something to do with pointers and/or re-using the same objects but i'm new to obj-c and pointers so i am a bit lost.
    Any help again is very much appreciated.
    // Open the database connection and retrieve minimal information for all objects.
    - (void)initializeDatabase {
    NSMutableArray *authorArray = [[NSMutableArray alloc] init];
    self.authors = authorArray;
    [authorArray release];
    // The database is stored in the application bundle.
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"books.sql"];
    // Open the database. The database was prepared outside the application.
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
    // Get the primary key for all books.
    const char *sql = "SELECT id, author FROM author";
    sqlite3_stmt *statement;
    // Preparing a statement compiles the SQL query into a byte-code program in the SQLite library.
    // The third parameter is either the length of the SQL string or -1 to read up to the first null terminator.
    if (sqlite3preparev2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
    // We "step" through the results - once for each row.
    // We start with Letter A...we're building an A - Z grouping
    NSString *letter = @"A";
    NSMutableArray *tempauthors = [[NSMutableArray alloc] init];
    while (sqlite3_step(statement) == SQLITE_ROW) {
    author *author = [[author alloc] init];
    author.primaryKey = sqlite3columnint(statement, 0);
    author.title = [NSString stringWithUTF8String:(char *)sqlite3columntext(statement, 0)];
    // FOLLOWING WAS LEFT OVER FROM ORIGINAL COMMENTS IN SQLBooks example....
    // We avoid the alloc-init-autorelease pattern here because we are in a tight loop and
    // autorelease is slightly more expensive than release. This design choice has nothing to do with
    // actual memory management - at the end of this block of code, all the book objects allocated
    // here will be in memory regardless of whether we use autorelease or release, because they are
    // retained by the books array.
    // if the author starts with the Letter we currently have, add it to the temp array
    if ([[author.title substringToIndex:1] compare:letter] == NSOrderedSame){
    [tempauthors addObject:author];
    } // if this is different letter, then we need to deal with that too...
    else {
    // create a dictionary to store the current tempauthors array in...
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    // add the dictionary to our appDelegate-level array
    [authors addObject:tempDictionary];
    // now prepare for the next loop...
    // set the new letter...
    letter = [author.title substringToIndex:1];
    // remove all of the previous authors so we don't duplicate...
    [tempauthors removeAllObjects];
    // add the current author as this was the one that didn't match the Letter and so
    // never went into the previous array...
    [tempauthors addObject:author];
    // release ready for the next loop...
    [author release];
    // clear up the remaining authors that weren't picked up and saved in the "else" statement above...
    if (tempauthors.count > 0){
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    [authors addObject:tempDictionary];
    else {
    printf("Failed preparing statement %s
    ", sqlite3_errmsg(database));
    // "Finalize" the statement - releases the resources associated with the statement.
    sqlite3_finalize(statement);
    } else {
    // Even though the open failed, call close to properly clean up resources.
    sqlite3_close(database);
    NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
    // Additional error handling, as appropriate...
    Message was edited by: dotnetter

    Ok, so I know what the issue is now...I just don't know enough to be able to resolve it!
    it's the tempAuthors objects.
    It's an NSMutableArray which is create on the line before the start of the WHILE loop.
    Having looked through the debugger, I can see that each dictionary object is created (with different codes which I assume are memory addresses) so all is well there. However, on each iteration of the loop in the middle there is an IF...ELSE... statement which in the ELSE section is clearing all objects from the tempAuthors array and beginning to repopulate it again.
    Looking at the containing dictionary objects in the debugger I can see that the tempAuthors object that each contains has the same code (again, I'm assuming this is a memory address) - so if I understand correctly, it's the same object...I assumed that when I created the dictionary using the dictionWithObject call that I would be passing in a copy of the object, but it's referencing back to the object which I then go on to change.
    Assuming the above is correct, I've tried several "stabs in the dark" at fixing it.
    I've tried relasing the tempAuthors object within the ELSE and initialising it again via an alloc...init - but this didn't work and again looking through the debugger it looks as though it was confused as to which object it was supposed to be using on the following iteration of the WHILE loop (it tried to access the released object).
    Having read a little more about memory management can someone tell me if I'm correct in saying that the above is because the tempAuthors object is declare outside the scope of the WHILE loop yet I then try to re-instantiate it within the loop (does that make sense???).
    Sorry for the long post...the more I can understand the process the less I can hopefully stop relying on others for help so much.
    I am continuing to read up on memory management etc but just not there yet.
    Regards
    Wayne

  • Beginner! Need help getting started with recording music.

    I am the definition of 'new' at the moment. I want to record my own music at home and I've been told that using an Apple Mac is one of the better ways to go about it at home.
    I have a number of questions, most of which have probably been asked before (apologies!) starting right from the beginning.
    1. What type of Mac would be best suited as a dedicated tool for recording music? Obviously speed and memory are big factors, but are there any other considerations here (available inputs, drivers, sound cards etc)? I'm hoping to keep the cost below AUS$3000 if possible.
    2. Do i need any other hardware for this application? (this is where you can tell how inexperienced I am haha) such as mixers etc? If I should need a mixer, is there a particular type or brand of mixer that works well with Macs?
    3. Will plugging a guitar amp into the mac improve sound quality over plugging the guitar directly into the Mac? I bought a Griggin Garage Band guitar cable a while ago to record some background music for a friend's DVD, and I found it worked well, but I'm looking for the best quality sound now.
    4. What would be the most effective software to use? I've briefly used Garage Band and found that to be simple and useful, but I've heard that there are better software packages available.
    I'm hoping to be able to record guitar, bass and vocals directly on to the Mac, and create drum tracks using samples and loops. I know how to play music but as you can tell I know very little about recording it! Any help or suggestions would be appreciated!
    Thanks..

    I would presume one line level input will suffice?
    Close, you need a Line Level AND Mic Level input since you'll want to record vocals.
    Thanks for the link to your Q&A page, I found some very useful info there.
    It's showing its age, and will hopeful get updated soon, but most of the info is good at least for a background.
    Anyway, I think I might recommend this Presonus INSPIRE over the FireBox, it'll save you about $100 and since PreSonus makes excellent equipment (and we have an active member here that uses the Inspire), I'm confident that it offers great quality.
    I think the firepod that you use looks great, but might be overkill
    I agree, the FirePod would be serious overkill for your needs. Again, an awesome interface, but you'd be paying for all those Mic PREs, and using 1. That wouldn't make sense, and since the FP isn't cheap...
    my talent and engineering knowledge is quite limited
    Then I would strongly suggest GB as the software, and then do lots of reading. The weakest link in music production is your engineering skills. Mixing and Mastering (especially the latter) are art forms. A bad engineer using a $10,000 bit of software and hardware would make a fantastic performance sound like garbage. With good engineering skills you can make a pro recording with GB.
    The learning curve with something like Logic is dramatically increased, and again, without the skills to take advantage of what it offers, your recordings are not going to sound any better. At the very least, start with GB to learn the skills of Recording/Editing/Mixing/Mastering. The "price of admission" is low enough that if in a year you find that you need a feature GB doesn't offer, your money will not have been wasted, it will have been valuable learning time.
    Hope those more specific answers help
    ~~HangTIme [Will Compute for Food] %-)>
    Note: I am an Amazon Associate, if you purchase this item via my link I will get a small commission)

  • Please help this newbie make a start with LabView 7

    Sorry for these very very basics but I failed to resolve these myself though I did my best.
    I try to make a GPIB i/o on a block diagram.How to ?
    I cannot find such in the functions menu.
    I find only a vi for typing direct commands ( which does work ).
    I tried many many variances, but end of all i get stuck, e.g. at : file>new>instrument i/o(gpib)>read and display>right click>controls>search>i/o....i get stuck.
    I am afraid I do miss a lot.....
    I have a NI GPIB PCI 488.2 card and some HPIB instuments.
    The PCI card and the NI 488.2 drivers work.
    I can read the instruments' dev.#.
    How should I implement instruments' r/w commands in an i/o block diagram ( if possible at all ).
    I cannot use VISA ( I
    assume C++ or VB is needed for that, which is beyond my capabilities ).
    Any help will be gratefully welcomed.
    Peter van Daalen.

    LabVIEW can do VISA and NI-488.2 directly; you don't need C++ or VB.
    First of all, you should see if there are instrument drivers available for your instruments. There are thousands of free drivers available on http://ni.com/idnet/. Search there first, because if you can find a driver for any of your instruments, it will save you a lot of time.
    If you can't find a driver, you will have to send and receive messages from the instrument directly, and this is where NI-VISA and NI-488.2 come in. The simplest way to get started with this direct communcation is to use the "Instrument I/O Assistant". This is in your "Functions->Input" palette, and you can read about it in the online help.
    The Instrument I/O Assistant will bring up a dialog to select th
    e device, send it a command and parse the results. Once you click "OK", it creates an Express VI on your diagram for you to incorporate into the rest of your application.
    I hope this helps you get started.
    Brian

  • Help needed please, with Iphone stuck with apple picture and progress bar after software update attempted

    Help needed please, everytime I try to update the software version on my iphone it comes up with a message saying it could not be completed and is now frozen with the apple picture and progress bar on it. Do I unplug it and hope the macbook pro sees it again, I also stupidly did not back up before starting the download which I realise I will have to go back to the previous back up. This keeps happening, everytime I do this type of update, I'm starting to think I should just give up on updating my software on the Iphone. I thought it was happening because I was using a window based computer to do the updates, this time I used my Macbook Pro. Please somebody help

    ljm17 wrote:
    ...This keeps happening, everytime I do this type of update, I...
    Then you should know what you need to do... If you don't remember...
    See Here  >  http://support.apple.com/kb/HT1808

  • Input Help Calendar start with Sunday

    Hi.
    I've an InputField binded with a node atributte type Dats. The input Help Mode it's Automatically. When I show the help, the calendar start with Sunday. I want that the calendar start with Monday. Can I Do that?

    Hi,
    this issue has been solved with SAP note 1061074
    Regards, Heidi

  • Help Getting Started with the Zen Vision:M (Z

    Hi,I just got my ZVM and want to get started with it. I have a couple of questions, first:?. I have Windows Vista. Can I just plug in the ZVM and go without using the Installation CDs? Or do I still need to install something off of the installation discs?2. Why 2 installation discs? There is with a black cover that says Easy Start CD and has the Urge and Window Media Player logo at the bottom. The other is just in a plain white bordered sleeve with a light colored disc that says Zen Vision: M Installation CD at the bottom. I think I want to start with the light colored disc, but want to make sure. Thanks.

    I think that the White disk that says Zen on it is the one you want it has Creative Media Source on it and is a very useful tool for me, the other disk has Windows Media Player on it and will also install a connection to a website that you can purchase tracks from (which i took off as soon as i found this out) not the WMP though, for some reason i could not get my Zen to work properly without the WMP loaded on my pc, however i use the Creative Media Source instead of the WMP.

  • Need help to start with some file and text manipulation

    Hello script mavens,
    I need help with starting a script that does the following:
    -within a base folder it takes an inventory (list?) of all the files (which happen to be image files).
    -creates a new folder inside the base folder and calls it imagesX where X increases by one every time the script is run
    -moves all the files into the images folder
    -within the base folder it creates a new text file and calls it imagesX.js
    -writes a "//-" into imagesX.js
    -then writes the list of filenames into the imagesX.js twice, separated by an empty line, and adds a semicolon to the end of each filename and saves imagesX.js
    -from a folder a level above the base folder it copies a file called index.html into the base folder and renames in indexX.html
    -in indexX.html it replaces a string "replaceThis" with "imagesX.js"
    The task is more complex but this would help me tremendously do the rest.
    If I am asking for too much on this forum please let me know

    This should get you started.
    The description of how you want to write the data isn't clear, but the rest should work (untested):
    property imageNum : 0 -- last used ImageNumber
    -- within a base folder it takes an inventory (list?) of all the files (which happen to be image files).
    -- get the folder:
    set baseFolder to (choose folder)
    -- now get the files within it:
    tell application "Finder"
    set fileList to every file of folder baseFolder as alias list
    end tell
    --creates a new folder inside the base folder and calls it imagesX where X increases by one every time the script is run
    tell application "Finder"
    set imageNum to imageNum + 1
    set newImageFolder to make new folder at baseFolder with properties {name:"images" & imageNum}
    -- moves all the files into the images folder
    move every file of folder baseFolder to newImageFolder
    --within the base folder it creates a new text file and calls it imagesX.js
    set textFile to (open for access file (baseFolder as text) & "images" & imageNum & ".js" with write permission)
    --writes a "//-" into imagesX.js
    write "//-" to textFile
    -- then writes the list of filenames into the imagesX.js twice, separated by an empty line, and adds a semicolon to the end of each filename and saves imagesX.js
    -- need more info here
    -- a blank line between each instance of the file name? or all file names, blank line, all file names again?
    -- an example, please
    close access textFile
    --from a folder a level above the base folder it copies a file called index.html into the base folder
    --and renames in indexX.html
    --in indexX.html it replaces a string "replaceThis" with "imagesX.js"
    -- the easiest way of doing this is to read the file and write a new copy with the changes - that's easier than changing it in situ:
    set indexHTML to (read file "index.html" of folder (container of baseFolder))
    set {oldTIDs, my text item delimiters} to {my text item delimiters, "replaceThis"}
    set indexHTML to text items of indexHTML
    set my text item delimiters to "imagesX.js"
    set indexHTML to indexHTML as text
    set my text item delimiters to oldTIDs
    set indexFile to (open for access file ("index" & imageNum & ".html") with write permission)
    write indexHTML to indexFile
    close access indexFile
    end tell

  • NEWBIE: Help needed - Eclipse freeze after starting WLS 9.2

    Hi All,
    I'm very new in development with wls 9.2 and eclipse.
    I'm trying to create a simple application (an EAR with a Session Bean).
    When I start the WLS inside Eclipse (debug or run mode), this one, after a few seconds or clicks, freeze with 99%CPU usage.
    Thanks in advance for help.... it's urgent....
    Eclipse 3.3.0
    WLST 1.1.0
    WLS 9.2
    Edited by mtode at 10/07/2007 2:04 AM
    Edited by mtode at 10/07/2007 2:05 AM

    If I understand you correctly, Eclipse stops responding after a while.
    This may not be actually related to starting WLS. It sounds a bit like
    you might be having a memory problem. Could you specify your operating
    system, the amount of physical memory and the contents of your
    eclipse.ini file?
    Thanks,
    - Konstantin

  • Need help getting started with the ML505 Development Kit

    First of all, an admission...I am a newb to the FPGA world. A babe in the wilderness. I am trying to run a simple little logic design to get my feet wet. Four inputs using the WEST, CENTER, SOUTH, and EAST pushbuttons feeding two AND gates which feeds an OR gate which turns on the NORTH LED. I have tried to use the Platform Cable USB to download the project to the XCF32P Platform Flash PROM using the iMPACT software. As of yet I have been unable to get the program to run. The iMPACT program says the programming was successful but after pressing the PROG button, the DONE LED does not turn on. I've tried different settings with the Configuration Address and Mode DIP switches with no success. To anyone using the ML505, given the gear I have at my disposal, what would you recommend? What modes have you used that worked? Thanks in advance.

    Here is the latest setup I have used in trying to get my FPGA to read from the Platform FLASH PROM. Configuration Address/Mode DIP switches set to 01011001 as per "My Own Platform Image Demonstration" method in the "ML505/ML506/ML507 Getting Started Tutorial" The Platform Cable USB is plugged into the JTAG connector on the ML505. Its status LED is green. In iMPACT the Boundary Scan reveals the following chain... TDI ----- xcf32p -----xcf32p-----xc9s144x1-----xccace-----xc5vlx50t-----TDO   The same mcs file is loaded into both PROMs (xcf32p). I start the programming cycle. It completes and says "Programming Successful" I press the PROG button on the ML505 and the DONE LED does not turn on and the design does not work. With the same chain I add the bit file to the xc5vlx50t so I have the PROMs loaded with mcs files and the FPGA with the bit file. I run the program function again. "Programming successful" is again indicated. The DONE LED lights and the design works. I then press the PROG button. The DONE LED turns off and the design ceases to function. I have also tried this with only one PROM loaded with a mcs file with no success. What am I doing wrong? Am I missing something? Thanks in advance.

  • Need some help getting started with Mobility Services Engine

    Someone has ordered several 3602 access points, a 5508 controller, and a MSE 3310 for one of our remote locations. The access points and controller are in place and are working fine (we use lightweight APs at many other locations), but I'm not sure how to approach the MSE. I've gone through the set up, and it's onsite, on the network, and I've added it to our WCS server. It's got a 2000 user context-aware services license. But I'm not sure where to go from here. It doesn't seem to actually be doing much of anything. Is there some quick start guide as to where to go from this point? The wireless users are mostly mini netbooks and iPads.

    Well, I'm no expert, but I did spend the night...
    Ok.  In the WCS on the Services tab, Mobility Services, your MSE is recognized and reachable with matching SW Versions.
    So, on the home tab, ContextAware tab, you see your MSE and it is showing Zero's  for data in most if not all fields?
    Back to the Services tab, Synchronize Services...  is this empty?
    The MSE can only 'SEE' what you tell it to 'LOOK' at.  That is, buildings and floor areas.  I haven't tried just a building.
    Check the left hand box for all the floor areas of interest.  Scroll to the bottom an slect 'Change MSE Assignment"
    select which (of the many or the one) MSE you wish to have monitor the area.  Check the 'CAS' box and save.
    Up on the upper levt is a Synchronization block..  push the Synchronize button and sit back..
    All MSE data is presented only to the WCS (or Pi).
    Good Luck
    David

  • Need help on starting with OSB

    Hi , I am new to OSB. Can some body guide me how i can start working on this ?
    to be specific any books or guides which will have the practical implementations , so that its easy to understand...

    some self promotion as author of the book : OSB 11g Development Cookbook http://www.packtpub.com/oracle-service-bus-11g-development-cookbook/book
    in this book we describe recipes which have level beginners to advanced.
    So in the beginning you will learn all the basics on how to create all the resources in the osb and further on you will continue with the more advanced recipes and technics of the osb

  • Newbie help needed with Applet

    I am having a problem with the following Applet. I have highlighted it in bold.
    How can I ensure that all of the conditions are met regardless of the order they are inserted on the graph,within the program?
    At the moment I have to do them in the exact order they are in the code in order to get the "Winner" message.
    Also if I insert an image at any time at the point if(x >= 290 && x <= 350 && y >= 290 && y <= 350) I also receive the "Winner" message. I realise this happens because it is the last line of code in this statement.
    However I am very new to this and dont know how to fix it. Indeed I dont even know if this is the correct way to do this.
    Hope this makes sense.
    Any help would be very much appreciated
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class MyDraughts extends Applet implements MouseListener,ActionListener,
                   MouseMotionListener{
                        public MyDraughts(){
                             points = new ArrayList();
                             pawncount = 0;
                             pawncount1 = 14;
                             message = "";
                             message1 = "";
                             title = new Font ("Arial", Font.BOLD, 18);
         private Point square1, square2, square3, square4, square5, square6, square7,square8,square9,
         square10,square11,square12,square13,square14,square15,square16,square17,square18,square19,
         square20,square21,square22,square23,square24,square25,square26,square27,square28,square29,
         square30,square31,square32,mouse;
         private int select;
         private Image pawn;
         private Point icon;
         private ArrayList points;
         private int x;
         private int y;
         private int pawncount;
         private int pawncount1,pawncount2;
         private Button undoButton;
         private String message,message1;
         private Font title;
         public void init(){
              setBackground(new Color(210,255,210));
              this.addMouseMotionListener(this);
              this.addMouseListener(this);
              select = 0;
              square1=new Point(50,10);
              square2=new Point(130,10);
              square3=new Point(210,10);
              square4=new Point(290,10);
              square5=new Point(10,50);
              square6=new Point(90,50);
              square7=new Point(170,50);
              square8=new Point(250,50);
              square9=new Point(50,90);
              square10=new Point(130,90);
              square11=new Point(210,90);
              square12=new Point(290,90);
              square13=new Point(10,130);
              square14=new Point(90,130);
              square15=new Point(170,130);
              square16=new Point(250,130);
              square17=new Point(50,170);
              square18=new Point(130,170);
              square19=new Point(210,170);
              square20=new Point(290,170);
              square21=new Point(10,210);
              square22=new Point(90,210);
              square23=new Point(170,210);
              square24=new Point(250,210);
              square25=new Point(50,250);
              square26=new Point(130,250);
              square27=new Point(210,250);
              square28=new Point(290,250);
              square29=new Point(10,290);
              square30=new Point(90,290);
              square31=new Point(170,290);
              square32=new Point(250,290);
              undoButton = new Button("Undo");
    add(undoButton);
    undoButton.addActionListener(this);
              mouse= new Point();
              icon = new Point();
              pawn = getImage(getCodeBase(), "pawn.gif");
    public void actionPerformed(ActionEvent actionevent){
    if(actionevent.getSource() == undoButton){
    int a = points.size();
    int b = a - 1;
    points.remove(b);
    a = points.size();
    repaint();
    public void paint (Graphics g){
         drawBox(g);
         g.fillRect(square1.x, square1.y,40,40);
         g.fillRect(square2.x, square2.y,40,40);
         g.fillRect(square3.x, square3.y,40,40);
         g.fillRect(square4.x, square4.y,40,40);
         g.fillRect(square5.x, square5.y,40,40);
         g.fillRect(square6.x, square6.y,40,40);
         g.fillRect(square7.x, square7.y,40,40);
         g.fillRect(square8.x, square8.y,40,40);
         g.fillRect(square9.x, square9.y,40,40);
         g.fillRect(square10.x, square10.y,40,40);
         g.fillRect(square11.x, square11.y,40,40);
         g.fillRect(square12.x, square12.y,40,40);
         g.fillRect(square13.x, square13.y,40,40);
         g.fillRect(square14.x, square14.y,40,40);
         g.fillRect(square15.x, square15.y,40,40);
         g.fillRect(square16.x, square16.y,40,40);
         g.fillRect(square17.x, square17.y,40,40);
         g.fillRect(square18.x, square18.y,40,40);
         g.fillRect(square19.x, square19.y,40,40);
         g.fillRect(square20.x, square20.y,40,40);
         g.fillRect(square21.x, square21.y,40,40);
         g.fillRect(square22.x, square22.y,40,40);
         g.fillRect(square23.x, square23.y,40,40);
         g.fillRect(square24.x, square24.y,40,40);
         g.fillRect(square25.x, square25.y,40,40);
         g.fillRect(square26.x, square26.y,40,40);
         g.fillRect(square27.x, square27.y,40,40);
         g.fillRect(square28.x, square28.y,40,40);
         g.fillRect(square29.x, square29.y,40,40);
         g.fillRect(square30.x, square30.y,40,40);
         g.fillRect(square31.x, square31.y,40,40);
         g.fillRect(square32.x, square32.y,40,40);
         g.setFont(title);
         g.drawString(message, 350, 300);
         g.drawString(message1, 350, 320);
         for(int i = 0; i < points.size(); i++){
    icon = (Point)points.get(i);
    g.drawImage(pawn, icon.x, icon.y, 25, 25, this);
         g.drawImage(pawn,175,135,25,25,this);
         g.drawImage(pawn,135,175,25,25,this);
         g.setFont(title);
         g.drawString("Click A Square To Place A Pawn", 350, 50);
    public void mouseDragged(MouseEvent e){}
    public void mouseMoved(MouseEvent e){}
    //require for the interface
    public void mousePressed(MouseEvent mouseevent){
    setBackground(new Color(210,255,210));
    x = mouseevent.getX();
    y = mouseevent.getY();
    if(x > 19 && x < 312 && y > 19 && y < 312){
    pawncount = pawncount + 1;
    points.add(mouseevent.getPoint());
    if(pawncount > pawncount1){
    setBackground(Color.red);
    message = "Too Many Pawns!You can only place 14";
    message1 = "Hit restart to play again";
    pawncount1 = 14;
    if(x >= 10 && x <= 50 && y >= 290 && y <= 330){
    setBackground(Color.red);
    message = "A Pawn Can't be placed here";
    pawncount = 15;
    if(x >= 50 && x <= 90 && y >= 250 && y <= 290){
    setBackground(Color.red);
    message = "A Pawn Can't be placed here";
    pawncount = 15;
    if(x >= 90 && x <= 130 && y >= 210 && y <= 250){
    setBackground(Color.red);
    message = "A Pawn Can't be placed here";
    pawncount = 15;
    //This is the solution for the puzzle
    if(x >= 90 && x <= 130 && y >= 10 && y <= 50);
    if(x >= 250 && x <= 290 && y >= 10 && y <= 50);
    if(x >= 90 && x <= 130 && y >= 50 && y <= 90);
    if(x >= 170 && x <= 210 && y >= 50 && y <= 90);
    if(x >= 10 && x <= 50 && y >= 90 && y <= 130);
    if(x >= 50 && x <= 90 && y >= 90 && y <= 130);
    if(x >= 250 && x <= 290 && y >= 130 && y <= 170);
    if(x >= 50 && x <= 90 && y >= 170 && y <= 210);
    if(x >= 210 && x <= 250 && y >= 210 && y <= 250);
    if(x >= 290 && x <= 350 && y >= 210 && y <= 250);
    if(x >= 10 && x <= 50 && y >= 250 && y <= 290);
    if(x >= 130 && x <= 170 && y >= 250 && y <= 290);
    if(x >= 210 && x <= 250 && y >= 290 && y <= 350);
    if(x >= 290 && x <= 350 && y >= 290 && y <= 350){
    setBackground(Color.green);
    message = "Winner";
    pawncount = 14;
    repaint();
    //required for the interface
    public void mouseClicked(MouseEvent event){}
    public void mouseReleased(MouseEvent event){}
    public void mouseEntered(MouseEvent event){}
    public void mouseExited(MouseEvent event){}
    public void drawBox(Graphics g){
         for(int i=10;i<=350;i+=40){
    g.drawLine(i,10,i,330);
    g.drawLine(10,i,330,i);
    }

    Since your code is heavilly dependant on which square is clicked on I'd define a class extending JComponent to represent a square. You can make this an inner class, which would simplify access to other squares etc. Then lay these out in your JPanel, and each will have it's own paint method which will paint it with or without a pawn.
    At the same time you add all these as a two dimensional array for logical access. Each square has (or is) it's own mouseListener so that you can let awt figure out which you clicked on.
    private static final int CELL_SIZE=50;
    private static final int BOARD_SIZE= 8;
    private class Square extends JComponent implements MouseListener {
        public boolean hasPawn;
        private Square(int row, int col) {
             Rectangle where = new Rectangle(col * CELL_SIZE, row * CELL_SIZE,
    CELL_SIZE, CELL_SIZE);
            setBounds(where);
           addMousListener(this);
       public void addPawn() {
         if(!hasPawn) {
           hasPawn = true;
           repaint();
      public void paint(Graphics g) {
    } // end of inner class
    Square[][]board = new Square[BOARD_SIZE][BOARD_SIZE];}

  • Newby...need help getting started with 80g

    ok...
    with 30gb ipod video i could connect to any type of computer pc or mac and upload music...
    with the ipod classic is it one or the other...

    17 hours??! Just to do the factory restore? Or does that include repopulating an 80Gb library. Either way it still sounds excessive to me. I take it you have USB 2.0 and a broadband net connection. I'm sure I've seen some postings about moving from PC to Mac elsewhere in the forums. You might want to track these down for useful advice before commiting to such drastic action.
    Restoring will wipe the hard drive of the iPod removing all content so be sure that there is nothing you want on the iPod that you don't have backed up somewhere else before you proceed.
    tt2

  • Need Help Getting Started with New iPod

    I already had an 8g iPod, however, I just purchased a 64 on Amazon ... it was new but open box.  I hooked it into my computer and the only thing that shows on the screen is the power chord pointing up to iTunes.
    I have reinstalled iTunes, but my system will not recognize this iPod, nor can I get to any other screens on the iPod.
    Can someone please provide some direction?
    Thanks much!
    Shelli

    Start here:
    iOS: Device not recognized in iTunes for Windows
    The Users Guide is noice to have too.
    iPod touch User Guide (For iOS 5.0 Software)

Maybe you are looking for