Here's my chess program

If anyone wants to try it out you can download the .java files here...
http://www.geocities.com/john_harnagel/chess0_1.zip
If you find any rules errors please let me know, but in advance, the en-passant rule was not implemented. Everything else should work.
On a side note, does anyone know how to make the program close down when the frame is closed? Right now it just kind of sits there, which I assume is pretty bad.
The main program is in Chess.java, can I add something to close the program?
public class Chess
     public static void main (String[] args)
          Chess_GUI frame = new Chess_GUI();
          frame.show();
}

frame.setDefaultCloseOperation(frame.CLOSE_ON_EXIT);Here is the error when I inserted that into my main method...
C:\Program Files\Xinox Software\JCreator LE\MyProjects\Exercises\Chess\ChessGame\Chess.java:13: cannot resolve symbol
symbol : variable CLOSE_ON_EXIT
location: class Chess_GUI
          frame.setDefaultCloseOperation(frame.CLOSE_ON_EXIT);
^
1 error
Process completed.

Similar Messages

  • Chess Program Development

    Hello,
    I'm in the process of developing a chess program to be played over a distributed network. Due to the complexity of the problem I'm going to be starting with the very basics. I've read some of the previous posts on this forum about chess games and found them very helpful. I've already made a text-based Tic-Tac-Toe game, which was suggested as a good starting point on this forum, and I would like to do the same with the chess game to start with. I figured that this would enable me to concentrate on the game mechanics. Below is a brief outline of how I would like to go about it:
    1)Game class - used to set up the game and alternate the turns between the players
    2)Board class - maintains the current game state and where the pieces are. Checks for mates, check mates, stalemates and draws (after 50 moves) as well as illegal moves.
    3)ChessPiece - this will be an abstract class which will contain information about the colour of the piece, whether it has been captured or not and its position on the board
    4)The specific pieces themselves will be sub-classes of ChessPiece. This would contain information about what type the piece is, type of move it is capable of and how much it is worth.
    Is there anything else that would be useful to include in these classes that would make development of the game easier?In a previous post, someone suggested representing the Board as ChessPiece[8][8]. Would this be a good idea? Would it be worth keeping track of which squares on the board are black and which are white?What would be a good way of checking for illegal moves efficently if I'm going to use an array?
    Thanks in advance

    representing the Board as ChessPiece[8][8]. Would this
    be a good idea?Choosing how to represent the board is a trade off:
    1) array[8][8]: looks like a human thinks of a chess board but can have a performance impact if you're writing an AI. Keeping x & y coords is simple but it complicates checking for when a piece can move off the board, particularly knights.
    2) array[10][10]: same as [8][8] but this eases the range checking because you keep a ring of "out of bounds" squares around the board. Knights can still move off the board in one jump though, so you could use array[12][12] to solve this if you're not too worried about memory.
    3) array[64]: a little faster than [8][8] but suddenly keeping (x,y) coords is trickier. Checking for out of bounds moves is a little easier though.
    4) or you could use an array[100] (or [144]) to include the ring of out-of-bounds squares as in (2) above.
    Whatever you do you should develop the API first before deciding which setup you want to use. IIRC most big chess progs use a straight arrays like 3 or 4, but that's because they're written in assembler ;-)

  • Fans/Heat go off the charts when playing Apple's Chess program

    Received my MacBook Core 2 Duo with 2GB ram on Nov. 20th.
    When my wife plays the chess game included with the laptop, both shoot up to 50% and fluctuate to 100%, spending a lot of time near 70 - 90%.
    Subsequently, the fans kick in like mad - very loud and the heat emanating from the MacBook is uncomfortable.
    Using smcFanControl, the temp remains at 80-81 degress Centigrade and the fan runs at 6196 rpm throughout the duration of the game.
    This does not seem normal/acceptable? Especially for the stock chess game?

    I'm sitting here quite incredulous at the service and response I just experienced with Applecare.
    After explaining my problem with the 80-83C/6200 rpm fan MacBook, the rep asked where we were using the Macbook.
    I explained that my wife uses it primarily on her lap while riding the train or bus, and on her lap while on the couch or in bed.
    Without addressing the cause of the hot Macbook, the rep directed me to stop using the macbook on the lap. Instead, the recommendation was to use it on a desk or any other flat surface.
    When I pressed her on the high temp/fan speed, she put me on hold for 10 minutes to only later return and tell me to send it in for inspection - min. 7 day turnaround.
    When I asked her for a case #, she put me on hold for another 15 minutes.
    This is a Macbook that I received from Apple on the 20th of November.
    Is this what I can expect from Applecare?

  • Package system does not exist, need help here.. my 2nd program...

    public class UserArgument{
    public static void main(String[] args){
    System.out.print("Hi, ");
    Sysmtem.out.print(args[0]);
    System.out.println(". How are you");
    1 error found:
    File: C:\introcs\HI\UserArgument.java [line: 4]
    Error: package Sysmtem does not exist

    Edit: Balls to it, I misinterpreted your last line and have dragged up an entirely useless post. Here's a joke instead.
    Why don't Mexicans like going out in the rain?
    They get wet.

  • Chessmaster 900 chess program. My Apple notebook tells me I cannot open it because it is no longer supported. Must I send it back, or is there another solution?

    My Apple notebook tells me I cannot open it because it (Power PC games/programmes) are  no longer supported. Must I send it back, or is there another solution?

    WOW: It only took you an hour to accept "No" for an answer
                                  [click on image to enlarge]

  • Chess game programming

    I have to create a text-based chess game between uppercase and lowercase letters against each other using a two-dimensional arrays.
    1. I have to create the board and initialize the position of the letters.
    2. I have to give the output of the initial state of the game, showing the board and the first positions of the letters.
    3. I have to create the moves.(Meaning that i have to create an input to perform the entering moves)
    And i have to make sure that with every bad input the program will to repeat the input....
    If anybody of you have programmed a chess game like this before, i would appreciate any kind of help....
    Edited by: 812599 on Nov 17, 2010 8:26 AM

    mario.beka wrote:
    meacod wrote:
    812599 wrote:
    I have to create a text-based chess game between uppercase and lowercase letters against each other using a two-dimensional arrays.
    1. I have to create the board and initialize the position of the checkers.Just to give you a nudge - are you familiar with chess? What's the size of the board? How might that affect the structure you store your 'pieces' in? How will you represent pawns as opposed to kings, queens, rooks, and so forth?
    Scratch out some ideas on paper,
    Turn that into some pseudocode,
    Write some Java,
    Then come back to us if you have a specific question.Yeah that's the problem, cuz i have never played chess in my life....I'm just reading around now for the rules and movements of this game...in that case, don't bother.
    A decent chess program requires in-depth knowledge of the game, knowledge only gained through years of playing it at competition level.
    I've a small library of books about chess, have played it for going on 30 years, plus 15 years experience using Java professionally, and I'd not consider writing a chess playing program in Java as something I'd undertake on my own (and yes, I've studied the possibility of writing just that in a variety of languages I know about over the years, and even made a start a few times only to abandon it when the project became too big for me to handle).
    If you're only looking to make a digital chessboard, that's a much simpler task and one that you can certainly attempt even without knowing the game (except maybe the starting positions and accepted icons for the pieces and the size and nomenclature for the board and its fields).
    Start with that, then add rules validation as players move pieces. Start with large rules (like enforcing that pieces can only move legally, in itself a somewhat daunting task as there are several pitfalls and special rules depending on piece positions).
    At this stage there's still no AI, no computer player option. That's where the real work sits, and it's very much a non-trivial task.

  • The access to our new chess hall may be blocked by your local firewall. You would need to reconfigure your firewall to open port 15010 for TCP traffic.

    How do I do the following so I can get into my chess program??
    The access to our new chess hall may be blocked by your
    local firewall. You would need to reconfigure your firewall to open port 15010
    for TCP traffic.

    This is not really Firefox related.
    What you need to do here is to read the firewall manual which usually explains how to create a rule for what you want to do.
    If you're using the Windows XP firewall, see this Microsoft article: http://windows.microsoft.com/en-US/windows-vista/Firewall-frequently-asked-questions

  • Error message or program crashing when printing on Epson printer

    In July 2008, I upgraded my computer from a MacBook to a MacBook Pro (and bought a Time Machine so that all my files are backed up regularly!) I then bought my wife a MacBook Pro in November 2008. We both used to have iBook G4s.
    We have an Epson EPL-6200 Laser Printer that we print from using our Airport Express. It used to work fine printing documents from any program and printing wirelessly from the iBook G4 computers we had when we bought the printer around three years ago.
    But since I have switched to a MacBook and now a MacBook Pro, I have all kinds of problems printing on the Epson EPL-6200 printer. At first, my MacBook did not print remotely at all. I had long conversations with both Apple and Epson, knowing there was a problem with the Epson driver. To top it off, the problems seemed worst with Microsoft Office, so both of them also said it was Microsoft's fault!
    Now that Epson has upgraded its drivers and I have dowloaded the latest one, and switched to a MacBook Pro, I can print some files easily -- Word documents now print immediately, although I get an error message saying that the printer is not connected. But trying to print from other programs such as Firefox either takes a very long time (around 5-8 minutes for one page) or causes the program to crash.
    Any ideas? The strange thing is that my wife's computer and mine are exactly the same (running Mac OS X version 10.5.6) but behave slightly differently when printing. I can print from Firefox, albeit after a long time per page, whereas if she tries to print from her computer in that program it instantly crashes.
    I guess we still have driver issues with the Epson EPL-6200.
    But I have looked on the Apple support forums and there seem to be a lot of printer-related issues like this. Do you guys have any suggestions? Or is there a printer that will work well with our MacBook Pros, an Airport Express and/or Time Machine (we have both) and when printing remotely?
    All the best,
    Alex

    hey,
    well, i use the below machines with the current mac os (10.5.6).
    i (kind of often) had issues with the network printer epson epl-6200.
    of which every issue could be resolved by myself, more or less quickly.
    i.e. until the last update (10.5.6).
    none of my machines is able to get anything through the network to the printer.
    at least they don't get the printer to print a page.
    today i spent (almost) the whole day, trying out things to get it fixed this time.
    none of it worked.
    just to let you know:
    i can access the printer through its http-interface.
    i can ping it.
    it gets recognized by the printer/fax-dialog in the system-preferences.
    here's what i tried so far:
    i tried to install the osx driver for the epl-6200 with every single protocol that's available in osx (i.e.: Appletalk, IPP, Bonjour, EPSON (IP), etc.)
    i of course tried to update the driver with the latest software available on the epson-website. and did the thing with the different protocols again.
    i tried the "generic" postscript driver of osx, too.
    then it was getting interesting:
    i tried to get "cups" for the epl-6200. i don't want to get into details here, but to drop some names:
    foomatic-rip (combined with ghostscript)
    http://linuxfoundation.org/en/OpenPrinting/MacOSX/foomatic
    gutenprint (doesn't have an epl-6200 driver included)
    pxlmono (doesn't have an epl-6200 driver included)
    to sum that up:
    there are two drivers on the "openprinting"-site (foomatic). but one is (of course) the official epson driver.
    but:
    there is a "third-party" driver downloadable on that website.
    http://openprinting.org/show_printer.cgi?recnum=Epson-EPL-6200
    well, i downloaded it, installed the required additional software (foomatic + ghostscript), all very fine. i could choose it in the osx printer setup menu.
    but:
    my printer still won't print a single page.
    the error messages i got:
    other than the above post none of my programs ever crashed, or was "dead slow".
    but:
    the printing job got constantly stopped, i could restart it, but it was then stopped again. without any error message.
    there was the same thing with the halt of the printer (also monitored in the printing cue window). i could restart it, but it would stop again. without any error message.
    but i also got two decent error messages: :))
    the first involved the pdftoescpage.app, either it was failing (shown in the printer cue window), or it was crashing (i got the error message in a separate window popping up). according to folks on the net this malfunction involved user permissions, so i to set up the "right" permissions (giving everybody the right to do anything (rwx) - i know i shouldn't have :)) ). but it didn't help. still crashing or failing.
    the second decent error message, finally:
    "double free" - what that meant, i cannot tell.
    conclusion:
    i don't know. :))
    required action:
    i will await the next osx update, and hope it'll be fixed then. :))
    good night, y'all
    p.s.: ahh, if anybody knows anything i didn't and should try. please drop a line. thx

  • Can you help me with my program please?

    hi all,
    I have a problem with the sellMilk function at the Milk class I don't know how to write it right I've tried everything so I need you to help me.
    this function should check the expiry date of the milk and sell the required amount if it is not expired. if it was expired just delete the milkbox.
    I have cases like if the first box has 5 kg and not expired , second box has 10 kg and expired, third box has 8 kg and not expired .. and if the required amount to sell is 6 kg for example it should work like this: first box should become zero because 5 kg has been sold and remainder is 1 .. so it should check the expiry date of the second box and it is expired so delete it. and then check the third box's expiry date and it is not expired so 8-1 = 7 .. and by that way 6 kg has been sold.
    my program it just delete the expired box if it was the first element.
    my code doesn't work well like that! here is the full program so you can check the code to help me please ..
    the problem is just with SellMilk() at the Milk Class
    Thank you
    import java.io.*;
    import java.text.*;
    import java.util.*;
    public class Market
        public static void main(String args[ ])
        { System.out.print("Enter the Market name: " );
            String name1 = Stdin.readLine();
            Market_Store mymarketstore = new Market_Store(name1);
       System.out.println("Welcome To " +name1+" Market ");
       System.out.println("");
            System.out.println("1-Stock new Milk");
            System.out.println("2-Stock new Milk Box");
            System.out.println("3-Sell");
            System.out.println("4- Display");
            System.out.println("");
            System.out.print("Enter your choice: ");
            int choice = Stdin.readInteger();
            while (choice != 5)
                switch (choice)
                case 1:
                 mymarketstore.stockNewMilk();
                    break;
                case 2:
                    mymarketstore.stockMilkBox();
                    break;
                    case 3:
             mymarketstore.sell();
                break;
                case 4:
               mymarketstore.display();
                            break;
                            case 5:
                default:
                    System.out.println("wrong Number");
                    System.out.println("Enter a number between 1 to 4 ");
                    System.out.println("Enter 5 to Exit");
                    break;
                System.out.println("");
              System.out.println("Welcome To " +name1+" Market ");
       System.out.println("");
            System.out.println("1-Stock new Milk");
            System.out.println("2-Stock new Milk Box");
            System.out.println("3-Sell");
            System.out.println("4-Display");
            System.out.println("");
             System.out.print("Enter your choice: ");
                choice = Stdin.readInteger();
    class Market_Store
            private String name;
            private Vector mymilk;
            public Market_Store(String n)
                    name=n;
                    mymilk = new Vector();
            public void stockNewMilk()
                    String N;//milk type
                    System.out.print("Enter the type of the milk: ");
                    N=Stdin.readLine();
                    Milk  m1 = new Milk (N);
                    mymilk.addElement(m1);
            public void stockMilkBox()
            System.out.println("Milk Available in stock : ");
            for (int i=0; i<mymilk.size(); i++){
            Milk m2 = (Milk)mymilk.elementAt(i);
            System.out.print(i+1+")");
            System.out.println(m2.getMilkType());  }
                    System.out.print("Enter the number of the milk to stock new box: ");
            int     ii = Stdin.readInteger();
            ((Milk)(mymilk.elementAt(ii-1))).addNewBox();
            }//end stockMilkBox
            public void sell()
                    //sell specific type of milk
                   System.out.println("Milk Available in stock : ");
            for (int i=0; i<mymilk.size(); i++){
            Milk m2 = (Milk)mymilk.elementAt(i);
            System.out.print(i+1+")");
            System.out.println(m2.getMilkType());
                                   System.out.print("Enter the number of the milk to sell:  ");
            int     ii = Stdin.readInteger();
    System.out.print("Enter the amount required in Kg:  ");
    double amount = Stdin.readDouble();
            ((Milk)(mymilk.elementAt(ii-1))).sellMilk(amount);
            public void display()
            {      System.out.println("Milk Available in stock : ");
            for (int i=0; i<mymilk.size(); i++){
            Milk m2 = (Milk)mymilk.elementAt(i);
            System.out.print(i+1+")");
            System.out.println(m2.getMilkType());
                    System.out.print("Enter the number of the milk to display:  ");
            int     ii = Stdin.readInteger();
                    ((Milk)(mymilk.elementAt(ii-1))).display();
    class MilkBox
            private Date expiredate;
            private Date date;
            private double stock;
            public MilkBox(double stck, Date ed)
                     date = new Date();
                    expiredate = ed;
            public double getStock()
             return stock;     }
            public Date getDate()
                     return date;
    public void setStock(double st)
    { stock = st;}
    public void setExDate(Date dd)
    {expiredate = dd;}
            public Date getExDate()
                     return expiredate;
      public   double sellMilkBox(double amount)
            double excessAmount = 0;
            if (amount < stock)
                double newAmount = stock - amount;
                setStock(newAmount);
            else  
                excessAmount = amount - stock;
                setStock(0);
            return excessAmount;
    public     void display()
                            System.out.println("The box of "+date+" has " +stock+" KG");
    class Milk
            private String Mtype;//milk type
            private Vector mybox;//vector of batches
            public Milk (String n)
                    Mtype =n;
            mybox = new Vector();
      public  void addNewBox()
    double stook;
    System.out.print("Enter the weight of the box: ");
    stook = Stdin.readDouble();
         Date exdate;//expirey date
    System.out.println("Enter the expirey date of the milk box:");
           int d; int m1; int y;
              System.out.println("Enter Year:" );
              y = Stdin.readInteger();
              System.out.println("Enter Month:" );
              m1 = Stdin.readInteger();
              System.out.println("Enter Day:" );
              d = Stdin.readInteger();
                   Calendar r=new GregorianCalendar(y,m1,d);
                    exdate= r.getTime();
                    //send the attributes to Box constructor
                   MilkBox newBox = new MilkBox(stook,exdate);
                    newBox.setStock(stook);
                    newBox.setExDate(exdate);
                    mybox.addElement(newBox);
       public void display()
                    System.out.println("Milk "+Mtype);
                            for (int i=0; i<mybox.size(); i++){
                    MilkBox b= (MilkBox)mybox.elementAt(i);
                    b.display();
    public double sellMilk (double amount)
       for(int i=0;i<mybox.size();i++)
               MilkBox b = (MilkBox)mybox.elementAt(i);
                double stock = b.sellMilkBox(amount);
                double value = b.getStock();
                Date ExpireyDate = b.getExDate();
      if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
    if (stock >1|| value  ==  0 && ExpireyDate.after(new Date()))
    {       mybox.remove(b);  
    amount = stock;
    if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
      if(amount != 0)
      System.out.println("The extra amount is "+amount+ " KG");
    return amount;}
    public String getMilkType()
    { return Mtype;}
    //set method
    void setMilkType(String n)
    { Mtype = n;}
    }//end class milk
    //STDIN FILE
    final class Stdin
       public static BufferedReader reader=new BufferedReader
        (new InputStreamReader(System.in));
       public static String readLine()
       while(true)
       try{
           return reader.readLine();
           catch(IOException ioe)
             reportError(ioe);
           catch(NumberFormatException nfe)
            reportError(nfe);
       public static int readInteger()
        while(true)
        try{
        return Integer.parseInt(reader.readLine());
        catch(IOException ioe)
        reportError(ioe);
        catch(NumberFormatException nfe)
        reportError(nfe);
       public static double readDouble()
        while(true)
        try{
        return Double.parseDouble(reader.readLine());
        catch(IOException ioe)
        reportError(ioe);
        catch(NumberFormatException nfe)
        reportError(nfe);
        public static void reportError (Exception e)
        System.err.println("Error input:");
        System.err.println("please re-enter data");
        }Edited by: mshadows on Dec 22, 2007 12:06 AM

    ok here is the code that has the problem .. what's wrong with it?
    public double sellMilk (double amount)
       for(int i=0;i<mybox.size();i++)
               MilkBox b = (MilkBox)mybox.elementAt(i);
                double stock = b.sellMilkBox(amount);
                double value = b.getStock();
                Date ExpireyDate = b.getExDate();
      if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
    if (stock >1|| value  ==  0 && ExpireyDate.after(new Date()))
    {       mybox.remove(b);  
    amount = stock;
    if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
      if(amount != 0)
      System.out.println("The extra amount is "+amount+ " KG");
    return amount;}

  • Wireless connection not working after installed newest Lenovo ThinkVantage System Update programs

    Hi, everyone!
    I've installed some newest programs through Lenovo ThinkVantage System Update and just after that my wireless connection has stopped working. Here are the installed programs:
    ThinkPad UltraNav Driver for Windows 32-bit version 15.0.24.0;
    ThinkPad Power Management Driver version 1.60;
    ThinkPad Modem Adapter version 7.80.8.0;
    ThinkPad Hotkey Features Integration Package Setup version 3.11.0001;
    Inter Wireless WiFi Link for Window XP version 13.02.0000;
    ThinkVantage Access Connections for Windows XP version 5.62;
    ThinkPad Power Manager version 1.88;
    Lenovo ThinkVantage Toolbox (32-bit) version 6.0.5514.61.
    I've got a Lenovo T61 with Windows XP SP3.
    Also in Device Manager, there are now the two "Other devices" bellow with a yellow question point and a yellow exclamation point by side:
    Bluetooth Hands-free Audio;
    Bluetooth LAN Access Server Driver.
    Does anyone have any idea what can be done to have these issues solved?
    P.S.: when I click Fn+F5 it shows only the Bluetooth Radio.

    Hello and welcome,
    I've seen something like this on XP machines after updates a couple of times now - my T61, a friend's T400, and his daughter's T61.  I guess that makes 3
    _Maybe_  your situation is the same.
    The fix in all 3 cases was to go to device manager and uninstall the wifi driver.  Then scan for hardware changes and let it reinstall the driver.  Something about how Access Connections or some other networking mangement thingy was hooking the drivers I guess.
    On both of the friend's machines, the wired networking was also b0rked.  Same fix there.
    Z.
    The large print: please read the Community Participation Rules before posting. Include as much information as possible: model, machine type, operating system, and a descriptive subject line. Do not include personal information: serial number, telephone number, email address, etc.  The fine print: I do not work for, nor do I speak for Lenovo. Unsolicited private messages will be ignored. ... GeezBlog
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество

  • I am trying to install a program on my Mac and the Automator is interfering....can it be overridden or disabled?

    I purchased a program from a trusted website and was able to download it....however when I try to install it I get an "Apple Run Script Error"....the support team for the web site thinks it is Automator....so not sure how to get around this....anyone out there can help? Would be greatly appreciated.

    Well there's not enough info to even guess beyond what I previously posted.
    My only "judgement" here is that whatever program you are using has questionable tech support if all they say is "it's Automator" and offer no further assistance as to why their program doesn't work on your machine and aren't even curious.

  • Keyboard-lock of swing program on Linux box

    We are developing swing program on Linux, and we often meet keyboard-lock issues.
    I try to simplify some of them to small programs, and still meet keyboard-lock.
    Here I post two programs to show the error:
    //---first ----------------------------------------------
    package test;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class KeyLock extends JFrame {
      JPanel contentPanel = new JPanel();
      JPanel wizardToolPan = new JPanel();
      JButton btnBack = new JButton("Back");
      JButton btnNext = new JButton("Next");
      JButton btnAbout = new JButton("About");
      public static final String aboutMsg =
              "<html>  This program will help to find keyboard lock problems, two way to reproduce:<br><br>" +
              "1 - press Alt+N to navigate next, and don't release keys untill there are no more next page, <br>" +
              "then try Alt+B to navigate back and also don't release keys untill page 0,<br>" +
              "repeat Alt+N and Alt+B again and again, keyboard will be locked during navigating. <br><br>" +
              "2 - press Alt+A in main window, it will popup an about dialog,<br>" +
              "then press down space key and don't release, <br>" +
              "the about dialog will be closed and opened again and again,<br>" +
              "keyboard will be locked sooner or later." +
              "</html>";
      public KeyLock() {
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setTitle("Keyboard lock test");
        getContentPane().setLayout(new BorderLayout());
        btnBack.setMnemonic('B');
        btnBack.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            KeyLock.this.goBack(e);
        btnNext.setMnemonic('N');
        btnNext.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            KeyLock.this.goNext(e);
        btnAbout.setMnemonic('A');
        btnAbout.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(KeyLock.this, aboutMsg, "About", JOptionPane.INFORMATION_MESSAGE);
        contentPanel.setLayout(new BorderLayout());
        contentPanel.setPreferredSize(new Dimension(400, 250));
        contentPanel.setMinimumSize(new Dimension(400, 250));
        wizardToolPan.setLayout(new FlowLayout());
        wizardToolPan.add(btnBack);
        wizardToolPan.add(btnNext);
        wizardToolPan.add(btnAbout);
        this.getContentPane().add(contentPanel, java.awt.BorderLayout.CENTER);
        this.getContentPane().add(wizardToolPan, java.awt.BorderLayout.SOUTH);
        this.setSize(400, 300);
        this.createContentPanels();
        this.showCurrent();
      private Vector<JPanel> slides = new Vector<JPanel>();
      private int current = 0;
      private void createContentPanels() {
        for (int j = 0; j < 20; ++j) {
          JPanel p = new JPanel(new FlowLayout());
          p.add(new JLabel("Page: " + j));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JLabel("Input something in password box:"));
          p.add(new JPasswordField(20));
          p.add(new JCheckBox("Try click here, focus will be here."));
          p.add(new JRadioButton("Try click here, focus will be here."));
          slides.add(p);
      public void showCurrent() {
        if (current < 0 || current >= slides.size())
          return;
        JPanel p = slides.get(current);
        this.contentPanel.add(p, java.awt.BorderLayout.CENTER);
        this.pack();
        Component[] comps = p.getComponents();
        if (comps.length > 0) {
          comps[0].requestFocus(); // try delete this line
        this.repaint();
      public void goNext(ActionEvent e) {
        if (current + 1 >= slides.size())
          return;
        this.contentPanel.remove(slides.get(current));
        current++;
        sleep(100);
        this.showCurrent();
      public void goBack(ActionEvent e) {
        if (current <= 0)
          return;
        this.contentPanel.remove(slides.get(current));
        current--;
        sleep(100);
        this.showCurrent();
      public static void sleep(int millis) {
        try {
          Thread.sleep(millis);
        } catch (Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        KeyLock wizard = new KeyLock();
        wizard.setVisible(true);
    }The first program will lead to keyboard-lock in RHEL 4 and red flag 5, both J2SE 5 and 6.
    //---second -----------------------------------------
    package test;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class KeyFocusLost extends JFrame {
      private JButton btnPopup = new JButton();
      private JTextField jTextField1 = new JTextField();
      private JPasswordField jPasswordField1 = new JPasswordField();
      private JPanel jPanel1 = new JPanel();
      private JScrollPane jScrollPane3 = new JScrollPane();
      private JTree jTree1 = new JTree();
      private JButton btnAbout = new JButton("About");
      public static final String aboutMsg =
              "<html>  This program is used to find keyboard focus lost problem.<br>" +
              "Click 'popup' button in main window, or select any node in the tree and press F6,<br>" +
              "a dialog popup, and click ok button in the dialog,<br>" +
              "keyboard focus will lost in main window." +
              "</html>";
      public KeyFocusLost() {
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setTitle("Keyboard focus test");
        getContentPane().setLayout(null);
        btnPopup.setBounds(new Rectangle(33, 482, 200, 35));
        btnPopup.setMnemonic('P');
        btnPopup.setText("Popup and lost focus");
        btnPopup.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            PopupDialog dlg = new PopupDialog(KeyFocusLost.this);
            dlg.setVisible(true);
        btnAbout.setBounds(new Rectangle(250, 482, 100, 35));
        btnAbout.setMnemonic('A');
        btnAbout.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(KeyFocusLost.this, aboutMsg, "About", JOptionPane.INFORMATION_MESSAGE);
        jTextField1.setText("Try input here, and try input in password box below");
        jTextField1.setBounds(new Rectangle(14, 44, 319, 29));
        jPasswordField1.setBounds(new Rectangle(14, 96, 319, 29));
        jPanel1.setBounds(new Rectangle(14, 158, 287, 291));
        jPanel1.setLayout(new BorderLayout());
        jPanel1.add(new JLabel("Select any node in the tree and press F6."), java.awt.BorderLayout.NORTH);
        jPanel1.add(jScrollPane3, java.awt.BorderLayout.CENTER);
        jScrollPane3.getViewport().add(jTree1);
        Object actionKey = "popup";
        jTree1.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), actionKey);
        jTree1.getActionMap().put(actionKey, new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            PopupDialog dlg = new PopupDialog(KeyFocusLost.this);
            dlg.setVisible(true);
        this.getContentPane().add(jTextField1);
        this.getContentPane().add(jPasswordField1);
        this.getContentPane().add(jPanel1);
        this.getContentPane().add(btnPopup);
        this.getContentPane().add(btnAbout);
      public static void main(String[] args) {
        KeyFocusLost keytest = new KeyFocusLost();
        keytest.setSize(400, 600);
        keytest.setVisible(true);
      static class PopupDialog extends JDialog {
        private JButton btnOk = new JButton();
        public PopupDialog(Frame owner) {
          super(owner, "popup dialog", true);
          setDefaultCloseOperation(DISPOSE_ON_CLOSE);
          this.getContentPane().setLayout(null);
          btnOk.setBounds(new Rectangle(100, 100, 200, 25));
          btnOk.setMnemonic('O');
          btnOk.setText("OK, then focus lost");
          btnOk.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              PopupDialog.this.getOwner().toFront();
              try {
                Thread.sleep(100); // try delete this line !!!
              } catch (Exception ex) {
                ex.printStackTrace();
              PopupDialog.this.dispose();
          this.getContentPane().add(btnOk);
          this.getRootPane().setDefaultButton(btnOk);
          this.setSize(400, 300);
    }The second program will lead to keyboard-focus-lost in RHEL 3/4 and red flag 4/5, J2SE 5, not in J2SE 6.
    And I also tried java demo program "SwingSet2" in red flag 5, met keyboard-lock too.
    I guess it should be some kind of incompatibleness of J2SE with some Linux platform. Isn't it?
    Please help, thanks.

    Hi.
    I have same problems on Ubuntu with Java 6 (all versions). I would like to use NetBeans or IntelliJ IDEA but it is not possible due to keyboard locks.
    I posted this bug
    https://bugs.launchpad.net/ubuntu/+bug/174281
    before I found some info about it:
    http://forums.java.net/jive/thread.jspa?messageID=189281
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6506617
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6568693
    I don't know from which part this bug comes, but I wonder why it isn't fixed yet. Does anybody else use NetBeans or IntelliJ IDEA on linux with Java 6 ?
    (I cannot insert link :\ )

  • Major Problem Here! I have no idea what to do and need help with OSX

    Hello all, thanks for viewing my topic.
    First of all, I have OSX 10.2.8
    I just got a christmas gift - an Ipod Nano
    I went into my Itunes only to find out that I need Itunes 7.0, but when I went to download it from the site, after running the install, it said I needed OSX 10.3.4
    So, I looked over and over for 10.3.4 only finding I needed 10.3 to run that
    So basically, i'm stuck here. Can I not use my Christmas gift? What do I have to do to get either the newest version of OSX to work with Itunes, or get my new Ipod 4G nano to work with my Itunes. Either solution would be great.
    Thanks

    Welcome To Discussions CJAAA!
    Some additional information.
    Mac OS X Versions 10.1, 10.2, 10.3, and 10.4, are complete system upgrades that must be purchased.
    The point upgrades, such as 10.1.x to 10.1.5 (Final) 10.2.x to 10.2.8 (Final), 10.3.x to 10.3.9 (Final), and 10.4.x to 10.4.8 (Pending), can be downloaded for free.
    Tiger is available for purchase at The Apple Store (U.S.).
    Panther, is no longer available directly from the Apple Online Store, as Tiger 10.4.x is the most up to date OS.
    If you know what to look for, a Full Retail Version, of the Panther Install CDs, or a Full Retail Version, of the Tiger Install DVD, can also be purchased rather inexpensively, at some online Apple retailers, Amazon, eBay, AppleRescue, FastMac, etc.
    Be sure not to purchase grey, upgrade or machine specific CDs or DVDs.
    Panther is only on CDs, not DVDs.
    The discs must look exactly like the images in the above links.
    Additional info in these links.
    Using OS X Install CDs/DVDs On Multiple Macs
    What's A Computer Specific Mac OS X Release
    Software Update, Upgrade: What's The Difference?
    Once Panther 10.3.x is installed, you can use the 10.3.9 Combo Update, to upgrade to the final version.
    If your Mac meets the System Requirements for Tiger, you could also consider installing that.
    And then use the PPC 10.4.8 Combo Update, to upgrade to the current version.
    Panther System Requirements
    Additional Panther System Requirements
    Tiger System Requirements
    Additionally,
    "Tiger ships on a DVD, but if your Mac doesn’t have a built-in DVD-ROM player, you’ll need CD media. When you buy Mac OS X Tiger, you qualify to purchase Tiger CDs for only $9.95."
    Download The Order Form Here. Media Exchange Program
    Orders must be mailed by March 19, 2007
    AppleRescue, also sells a Tiger installation set on CD
    Shop Carefully, Examine All Documentation, And Good Luck!
    ali b

  • Which is better Function modules or Include programs?

    Hi,
    I am working on an enhancement and it has lot of screens with a tree structure on the left. Now we are planning to have each screen to have its PAI/PBO and the processing logic to be in seperate include programs.
    However in our team we have debate as to go in for include programs or for Function modules. The opinion here is that the program should not take long time to load if its going to be include programs.
    Please suggest what approach is better, is it Function modules or include programs.
    Any other suggestion is also welcome.
    Thank You,
    SAC.

    Thank You all.
    In this enhancement I have about 13 screens and has business logic in each. So if I go with each screens and business logic coding in seperate Function modules than includes under 1 function group is adviceable?
    Using object oriented approach is really the best thing here, but however most of my team members are not welversed in OO concepts. The deadlines are very tight for grooming my team members as well.
    My only concern is that with so much screens and business logic in 1 transaction should not bring down this programs performance when its executed.
    Any other suggestions to keep in mind for this is appreciated.
    Thank You.
    SAC

  • Questions on one of my first programs for school

    I am taking an intro to Java class and I am in need of some help. I am not looking for anyone to do the work for me just to help me figure out what I am missing and get me back on track.
    Here is what the program is I am suppose to write:
    Write a Java class that declaires variables to represent the length and width of a room in feet and the price of carpeting per square foot in dollars and cents. Assign appropriate values to the variables. Compute and display, with explanatory text, the cost of carpeting the room.
    Here is what I have been able to come up with so far. While it seems to work in the basic idea of what the program is suppose to be I am still not complete in everything I need in it and I am still coming up with errors on just what I have so far.
    // File name Carpet
    // Created by
    // Written 05/12/2009
    import java.JOptionpane
    import java.util.Scanner;
    public class Carpet
        public static void main(String[] args)
            int entry;
            int anotherEntry;
            int carpetEntry;
            Scanner keyBoard = new Scanner(System.in);
                System.out.print("Enter the width ");
    // Entry for width of room
                entry = keyBoard.nextInt();
                System.out.print("Enter the length ");
    // Entry for length of room
                anotherEntry = keyBoard.nextInt();
                System.out.print(" Length ");
                System.out.println(entry);
                System.out.print(" Width ");
                System.out.println(anotherEntry);
                System.out.println(entry + " times " + anotherEntry + " is " + (entry * anotherEntry));
    // Actual square footage of the room being measured
                carpetEntry = keyBoard.nextInt();
                System.out.print(" Enter the carpet price per sq. foot ");
                System.out.println(Carpet Price);
                System.out.println(entry + " times " + anotherEntry + " times " + carpetPrice " is " + (entry * anotherEntry * carpetEntry));
    }Any and all ideas tips or pointers would be great. If I am not even close to what its asking please let me know what I am missing or how I am off track. Again I am not looking for anyone to give me the final and end result without me doing the work to actually learn this. Couldnt figure how to post a .zip file so hope how I pasted the code shows up correctly.

    Feel free to smack me on the back of the head at anytime HAHA :P
    // File name Carpet
    // Created by
    // Written 05/12/2009
    import java.util.Scanner;
    public class Carpet
         public static void main(String[] args)
              int legnth;
              int width;
              int carpet;
              Scanner keyBoard = new Scanner(System.in);
                   System.out.print("Enter the width ");
    // Entry for width of room
                   length = keyBoard.nextInt();
                   System.out.print("Enter the length ");
    // Entry for length of room
                   width = keyBoard.nextInt();
                   System.out.print(" Length ");
                   System.out.println(length);
                   System.out.print(" Width ");
                   System.out.println(width);
                   System.out.println(length + " times " + width + " is " + (length * width));
    // Actual square footage of the room being measured
                   System.out.print(" Enter the carpet price per sq. foot ");
                   carpet = keyBoard.nextInt();
                   System.out.println(carpet);
                   System.out.println(length + " times " + width + " times " + carpet + " is " + (length * width * carpet));
    }Errors:
    Carpet.java:15: cannot find symbol
    symbol : variable length
    location: class Carpet
                   length = keyBoard.nextInt();
                   ^
    Carpet.java:20: cannot find symbol
    symbol : variable length
    location: class Carpet
                   System.out.println(length);
                   ^
    Carpet.java:23: cannot find symbol
    symbol : variable length
    location: class Carpet
                   System.out.println(length + " times " + width + " is " + (length * width));
                   ^
    Carpet.java:23: cannot find symbol
    symbol : variable length
    location: class Carpet
                   System.out.println(length + " times " + width + " is " + (length * width));
                   ^
    Carpet.java:28: cannot find symbol
    symbol : variable length
    location: class Carpet
                   System.out.println(length + " times " + width + " times " + carpet + " is " + (length * width * carpet));
                   ^
    Carpet.java:28: cannot find symbol
    symbol : variable length
    location: class Carpet
                   System.out.println(length + " times " + width + " times " + carpet + " is " + (length * width * carpet));
                   ^
    6 errors
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

Maybe you are looking for

  • Need help in extracting value from an xml tag.

    Hi ALL, Good Morning to all, i have problem in fetching a value from a xml tag. I have created a xml schema based on the schema i have created a xmltype table and inserted a value to the table. When i am trying to fetch a value from a particular tag

  • Error Uploading an excel file

    I have a program that uploads excel file into sql server table and it works fine within my network. However, when try to run it in my service provider environment i am getting the following error. any idea what is causing this? thanks An error occurr

  • JDBC connector problem

    Hi All, I installed SAP BW 3.5 by following Installation Seqence in the mySAP ERP 2004 SR1 master guide, there are two servers under Visual Administator -> Cluster -> sapsid: one is "Server 0 10_37758"(I think this is Central Instance), another is "S

  • Maximum pixel size

    here's something new i just came across. A SWF built at 250x1850 is getting cropped/clipped/trimmed whatever you want to call it. It is exporting at 1825, losing the bottom 25 pixels of the SWF. Is there some px size limitation? It would suck as this

  • My app store not open, my app store not open

    No abre la app store , me envia a ITUNE .