Public int move(CDRack anotherRack)

I have problems with method: move(CDRack anotherRack).
It removes CDs from anotherRack, but the rack I'm trying to fill in with anotherRack's CDs is filled with a one same CD from the anotherRack not various CDs as it should.. hard to explain.:)
Is some willing to give me tips? And is there some other way
to use insert method with the help of the move-method?
/**Class CDRack represents collections of compact discs. Discs are
located in the rack in slots numbered from zero upwards.The discs are
represented by Record objects and empty slots by null values. */
public class CDRack extends Object { 
  private Record[] collection;
/**Creates a new, empty CD rack. Parameters:size - the size of the new
rack, i.e. the number of slots it has */
    public CDRack(int size) {
       collection = new Record[size];   
       this.size = size;
/**Inserts a cd in the given rack slot if the slot in question is
empty. Parameters: disc - the cd to be added in the rackslot - the
number of a (hopefully empty) slot
Returns: a boolean value indicating if the insertion was successful.
    public boolean insert(Record disc, int slot) { 
       if (collection[slot]==null)) {    
         collection[slot] = record;    
         return true; 
       else return false; 
/** Inserts the given cd in the first empty rack slot (if there is even
one empty slot in the rack).
Parameters: disc - the disc to be added in the rack
Returns:
the number of the slot where the disc was added, or a negative number
if the rack was already full */
    public int insert(Record disc) {
       for(slot=0; slot<collection.length; slot++) {
         if(collection[slot]==null) {
            collection[slot] = disc;
            return slot;
       return -1; //not enough place
/** Moves all the discs from the given cd rack to this rack. The cds
from the other rack are inserted in the empty slots of this rack (in
ascending numerical order of slot numbers) in the order in which they
are located in the other rack. The moved discs are removed from their
original rack. Even if there is not enough space for all the discs in
this rack, as many cds are moved as possible.
Parameters:
anotherRack - another rack whose cds are to be moved into this one
Returns:
the number of cds moved from the other rack to this one */
    public int move(CDRack anotherRack) {
       int howMuchPlace = this.getSize() - this.getNumberOfCDs();
         if(anotherRack.getNumberOfCDs() <= howMuchPlace) {
            for(int i=0; i<anotherRack.getNumberOfCDs()+1; i++) {
              this.insert(disc);
            for(slot=0; slot<anotherRack.getNumberOfCDs()+1; i++) {
              anotherRack.remove(slot);
            return anotherRack.getNumberOfCDs();
        if(anotherRack.getNumberOfCDs() > howMuchPlace) {
            for(int i=0; i<howMuchPlace+1; i++) {
              this.insert(disc);
            for(slot=0; slot<howMuchPlace+1; i++) {
              anotherRack.remove(slot);
            return howMuchPlace;
         return -1;

I'm about to leave the office (it's 7PM in London and
there at least a dozen beers with my name on them ;)
but I'll take a look on Monday and see how you got
on.Sheesh. Must be Christmas or something :)
You still need to implement organize() and sortAlphabetically(), plus move the classes to their own files and modify the parameter names to match the assignment.
But, apart form that, here's what you wanted.
Now, I realy am going to ge those beers...
public class Maria2
     static class Record {}
     static class CDRack
          private Record[] mRecords;
          CDRack(int size) { mRecords= new Record[size]; }
          int find(Record disk)
               for (int i= 0; i < mRecords.length; i++) {
                    if (mRecords.equals(disk))
                         return i;
               return -1;
          Record getCD(int index)
               if (index < 0 || index >= mRecords.length)
                    return null;
               return mRecords[index];
          int getNumberOfCDs() { return getSize() -available(); }
          int getSize() { return mRecords.length; }
          int insert(Record record)
               int index= 0;
               for (; index < mRecords.length && mRecords[index] != null; index++);
               if (insert(record, index))
                    return index;
               return -1;
          boolean insert(Record record, int index)
               if (index >= mRecords.length)
                    return false;
               if (mRecords[index] != null)
                    return false;
               mRecords[index]= record;
               return true;
          private int available()
               int available= 0;
               for (int i= 0; i < mRecords.length; i++) {
                    if (mRecords[i] == null )
                         available++;
               return available;
          Record remove(int index)
               Record record= getCD(index);
               mRecords[index]= null;
               return record;
          int move(CDRack source)
               int moved= 0;
               for (int i= 0; i< source.getSize(); i++) {
                    Record record= source.getCD(i);
                    if (record == null)
                         continue;
                    if (insert(record) < 0)
                         break;
                    source.remove(i);
                    moved++;
               return moved;
     public static void main(String[] argv)
          CDRack rack1= new CDRack(32);
          CDRack rack2= new CDRack(18);
          for (int i= 0; i< rack1.getSize()/2; i++)
               rack1.insert(new Record(), i*2);
          for (int i= 0; i< rack2.getSize(); i++)
               rack2.insert(new Record(), i);
          System.err.println("Rack one has " rack1.getNumberOfCDs() " records");
          System.err.println("Rack two has " rack2.getNumberOfCDs() " records");
          int moved= rack1.move(rack2);
          System.err.println(moved +" records were moved");
          System.err.println("Rack one has " rack1.getNumberOfCDs() " records");
          System.err.println("Rack two has " rack2.getNumberOfCDs() " records");

Similar Messages

  • How do i return nothing in a "public int getNothing()" method ?

    i'd like "getNothing" to return an int ONLY if "z" is true ... is that even possible ?
    code :
      public int getNothing() {
            boolean z= trueOrFalse();
            int i = generator.nextInt(10);
            if (z=true){           
                return i;
    Message was edited by:
    jeroenQuant

    but in this case it's kinda necessary ...It isn't possible, so it isn't necessary.
    If getNothing() returns an int within a certain range, then you could return an int outside this range if trueOrFalse() is false. For example getNothing() could return a positive int when the condition is true and a -1 otherwise. The caller could detect the out of range value and act appropriately.
    Another approach is to move the boolean test from the getNothing() method to its caller. Ie something like:public void test() {
        if(trueOrFalse()) {
            System.out.println(getNothing());
    public int getNothing() {
        return generator.nextInt(10);
    }

  • Difference between Public Void and Public Int

    I was wondering what the difference was between 'public void' and 'public int'?

    Yeah,
    Given package forumTest;
    public class ReturnVoid
         public int returnInt()
         public void returnVoid()
    }compiling using the 1.4.2 reference compiler produces the following result:
    $ javac -d classes/ src/forumTest/ReturnVoid.java
    src/forumTest/ReturnVoid.java:6: missing return statement
            ^
    1 error

  • Public int indexOf(int ch, int fromIdx) doesn't work for some decimal value

    I have tested two strings below. These two string are identical, except the first string has a char 'ƒ, which has a decimal value of 131. And the second string has a char 'À', which has a decimal value of 192. I am expecting the same output, which is 11, but I got -1 for the test I did using the first string. In the API for public int indexOf(int ch, int fromIndex), values of ch is in the range from 0 to 0xFFFF (inclusive). It is highly appreciated if anyone could provide any insights on why -1 returned when the first string is tested. Thank you in advance.
    String strHasDecimal131 = "Test value ƒ, it has a decimal value of 131";
    String strHasDecimal192 = "Test value À, it has a decimal value of 192";
    int badDecimal = 131;
    int idxBadDecimal = strHasDecimal131.indexOf( badDecimal, 0);
    System.out.println( "index of Bad Decimal: " + idxBadDecimal );
    The output is: index of Bad Decimal -1
    int badDecimal = 192;
    int idxBadDecimal = strHasDecimal192.indexOf( badDecimal, 0);
    System.out.println( "index of Bad Decimal: " + idxBadDecimal );
    The output is: index of Bad Decimal: 11

    Thank you everyone for your inputs. Following are the print statements and the output: for character 'ƒ' and ' À':
    System.out.println((int)'\u0083' + ", " + (int)'\u00C0' + " print decimal value" );
    Output: 131, 192 print decimal value
    System.out.println((char)'\u0083' + ", " + (char)'\u00C0' + " print character value" );
    Output: ?, À print character value
    According to Latin-1 Supplement table, the first char in the output would have the appearance of ƒ, instead it has the appearance of ?
    System.out.println( (int)'ƒ' + ", "+ (int)'À' + " print integer value");
    Output: 402, 192 print integer value
    I also have tried to print out the decimal value of following char: € &#65533; ‚ ƒ „ … † ‡, according to Latin-1 Supplement table, these char has decimal value of 128 through 135 and hex value 0x0080 through 0x0087. And the output from java println is: 8364 65533 8218 8222 8230 402 8224 8225.
    System.out.println((int)'€' + " " + (int)'&#65533;' + " " + (int)'‚' + " " +(int)'„' + " " + (int)'…' + " " +(int)'ƒ' + " " + (int)'†' + " " + (int)'‡' );
    As I did before, I print out character of decimal value of 128 through 135
    System.out.println((char)128 + " " + (char)129 + " " + (char)130 + " " +(char)131 + " " + (char)132 + " " +(char)133 + " " + (char)134 + " " + (char)135 );
    Output: ? ? ? ? ? ? ? ?
    Not sure why java prints character for decimal value of 128 through 159 differently from what appears in the Latin-1 Supplement table. Any of your inputs are appreciately.

  • Exchange 2003 Public folder move to exchange2010

    we have been running exchange 2010 and exchange 2003 for some time and now its time to remove exchange 2003 while its been running it hasn't been doing anything.
    Exchange 2003 is replicating already to exchange 2010 a while ago I did do a move replication (over a 2 months ago got side tracked)
    now under public folder instance on exchnge2003
    I just see one folder "Schedule + free Busy information -First Administrative Group"
    and when you look at replication status on exchange 2003 I see this
    PUBLIC FOLDER HIERARCHY                   12/08/2014 2 In Sync
    Schedule+ Free Busy Information- first                      2 both Modified
    System Configuration                             10/08/2012 2 local modified
    I need to get the information over to exchange 2010.
    Do I go with a move MoveAllReplicas.ps1 will this overwrite whats on 2010 ?
    What is the safest way for me to get this information over to exchange 2010 any suggestions?
    Thanks for your time

    Hi,
    Please check if the links below are helpful:
    http://technet.microsoft.com/en-us/library/bb331970(v=EXCHG.141).aspx
    http://exchangeserverpro.com/migrate-public-folders-from-exchange-2003-to-exchange-server-2010/
    Since this issue is more related to the Exchange side, I'd recommend you post your question to the Exchange forum:
    http://social.technet.microsoft.com/Forums/en-US/home?category=exchangeserver
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents,
    and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
    Thank you for your understanding.
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Method -help

    Hi!
    There are two classes: CDRack and Record(which is done).
    I have problems with methods
    -getNumberOfCDs()
    Should I write a new field numberOfCDs, or do I get it in other way?
    -ideas how to accomplish
    method move(CDRack anotherRack) ?
    thanks a lot!
    ps.How can I put Duke Dollars to my question? I`ve searched
    information but haven't found.
    Class CDRack represents collections of compact discs. Discs are located
    in the rack in slots numbered from zero upwards. The discs are
    represented by Record objects and empty slots by null values.
    public class CDRack extends Object {
      private Record[] collection;
      private int size;
      private Record record;
      private int slot;
    /** Creates a new, empty CD rack.
    Parameters:
    size - the size of the new rack, i.e. the number of slots it has */
        public CDRack(int size) {
          collection = new Record[size];
          this.size = size;
          this.slot = slot;
    Returns the size of the rack, i.e. the number of slots it has.
    Returns:
    the size of the rack
        public int getSize() {
          return this.size;
    /** Returns the number of CDs in the rack.
    Returns:
    the number of discs in the rack
        public int getNumberOfCDs() {
    Returns the cd in the given rack slot.
    Parameters:
    slot - a slot number
    Returns:
    the cd in the given slot or null if the slot is empty
        public Record getCD(int slot) {
          if (collection[slot].equals(null) )
             return null;
          else {
             record = collection[slot];
             return record;
    /** Inserts a cd in the given rack slot if the slot in question is empty.
    Parameters:
    disc - the cd to be added in the rack
    slot - the number of a (hopefully empty) slot
    Returns:
    a boolean value indicating if the insertion was successful. */
        public boolean insert(Record disc,
                              int slot) {
          if (collection[slot].equals(null)) {
             collection[slot] = record;
             return true;
          else
             return false;
    /** Removes a CD from the given rack slot.
    Parameters:
    slot - the slot to be emptied
    Returns:
    the removed cd or null if the given slot was empty */
        public Record remove(int slot) {
          if (collection[slot].equals(null))
             return null;
          else {
             record = collection[slot];
                collection[slot] = null;
                return record;
    /** Determines if the given disc object is stored in the rack.
    Parameters: disc - a disc to be located in the rack
    Returns:
    the slot number of the given cd if it is in the rack or a negative number if it is not */
        public int find(Record disc) {
          if (collection[slot].equals(null))
                 return -1;
          else {
             record = collection[slot];
             return slot;
    /** Inserts the given cd in the first empty rack slot (if there is even
    one empty slot in the rack).
    Parameters: disc - the disc to be added in the rack
    Returns:
    the number of the slot where the disc was added, or a negative number
    if the rack was already full */
        public int insert(Record disc) {
          if (collection[slot].equals(null)) {
             record = collection[slot];  
             return slot;
          else  
             return -1;
    /** Moves all the discs from the given cd rack to this rack. The cds from the
    other rack are inserted in the empty slots of this rack (in ascending numerical
    order of slot numbers) in the order in which they are located in the other rack.
    The moved discs are removed from their original rack. Even if there is not enough space
    for all the discs in this rack, as many cds are moved as possible.
    Parameters:
    anotherRack - another rack whose cds are to be moved into this one
    Returns:
    the number of cds moved from the other rack to this one */
        public int move(CDRack anotherRack) {
    In another class Record I have
    -constructor Record(String artist, String name, String category), which
    creates a new record with the given properties.
    and methods:
    -String getArtist() Returns the name of the artist.
    -String getCategory() Returns the category in which the recording has been pigeonholed.
    -String getName() Returns the name of the record

    public int getNumberOfCDs() {
        int count = 0;
        for (int c=0; c<collection.length; c++) {
           if (collection[c]!=null) {
              count++;
        return count;
    public int insert(Record disc) {
        for (int c=0; c<collection.length; c++) {
            if (collection[c]!=null) {
                collection[c] = disk;
                return c;
        return -1; // not enough place
    public int move(CDRack anotherRack) {
        for (int c=0; c<collection.length; c++) {
            if (collection[c]!=null) {
               if (anotherRack.insert(collection[c])<0) {
                   throw new RuntimeException("no more empty slot");
               } else {
                   collection[c] = null;
    }Btw, you don't really need such members as "slot", "record", "size".

  • Urgent Help Required for Connect Four Game

    Hi all,
    I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the game. I need to implement the hasWon() method for Horizontal win, Vertical win and Diagonal win. I also found some code examples on the net but I was unable to make it working. I have 5 classes and one interface which I m implementing. The main problem is how to implement the hasWon() method in the PlayGame class below with Horizontal, vertical and diagonal moves.
    Sorry there is so much code.
    This the interface I must implement, but now I am only implementing the int move() of this interface. I will implement the rest later after solving the winner problem with your help.
    Interface code..............
    interface Player {
    void init (Boolean color);
    String name ();
    int move ();
    void inform (int i);
    Player1 class......................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player1 implements Player
    public Player1()
    public int move()
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player1;
    System.out.println ("What is your Number, player 1?");
    player1 = scan.nextInt();
    System.out.println ("Hey number"+player1+" are you prepared to CONNECT FOUR");
    System.out.println();
    return player1;
    //Player.move();
    //return player1;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "Koonda";
    }//end player1 class
    Player2 class...........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player2 implements Player
    public int move()
    //int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    // cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
    //int num1, num2;
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player2;
    System.out.println ("What is your Number, player 2?");
    player2 = scan.nextInt();
    System.out.println ("Hey "+player2+" are you prepared to CONNECT FOUR");
    System.out.println();
    //return player1;
    return player2;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "malook";
    }//end player1 class
    PlayGame class which contains all the functionality.........................................................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class PlayGame
    //Player player1;
    //Player player2;
    int [][]ConnectFourArray;
    boolean status;
    int winner;
         int player1;
         int player2;
         public PlayGame()
              //this.player1 = player1;
              //this.player2 = player2;
         public void StartGame()
         try{
         // int X = 0, Y = 0;
         //int value;
         int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
         int[][] ConnectFourArray = new int[6][7];
         int num1, num2;
         for(int limit=21;limit!=0;limit--)
    BufferedReader selecter = new BufferedReader (new InputStreamReader(System.in));
    String column1;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=1;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=1;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=1;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=1;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=1;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=1;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=1;
    cup6=cup6-1;
    System.out.println();
    BufferedReader selecter2 = new BufferedReader (new InputStreamReader(System.in));
    String column2;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=2;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=2;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=2;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=2;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=2;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=2;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=2;
    cup6=cup6-1;
    System.out.println();
    System.out.println();
    catch (Exception E){
    System.out.println("Error with input");
    System.out.println("Would you like to play again");
    try{
    String value;
    BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
    // Scanner scan = new Scanner(System.in);
    System.out.println("Enter yes to play or no to quit");
    // value = scan.nextLine();
    // String value2;
    value = reader.readLine();
    //value2 = reader.readLine();
    if (value.equals("yes"))
    System.out.println("Start again");
    StartGame(); // calling the StartGame method to play a game once more
    else if (value.equals("no"))
    System.out.println("No more games to play");
    // System.exit(0);
    else
    System.exit(0);
    System.out.println();
    catch (Exception e){
    System.out.println("Error with input");
    finally
    System.out.println(" playing done");
    //StartGame();
    //check for horizontal win
    public int hasWon()
    int status = 0;
    for (int row=0; row<6; row++)
    for (int col=0; col<4; col++)
    if (ConnectFourArray[col][row] != 0 &&
    ConnectFourArray[col][row] == ConnectFourArray[col+1][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+2][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+3][row])
    //status = true;//int winner;
    if(status == player1)
    System.out.println("Player 1 is the winner");
    else if(status == player2)
    System.out.println("Player 2 is the winner" );
    }//end inner for loop
    }// end outer for loop
    } // end method Winner
    return status;
    }//end class
    ClassConnectFour which designs the board........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class ClassConnectFour
         //Player player1;
         //Player player2;
         public ClassConnectFour()
              //this.player1 = player1;
    public void DrawBoard()
    int[][] ConnectFourArray = new int[6][7] ;
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    }//end class
    TestConnetFour class which uses most of the above class..................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class TestConnectFour
    public static void main(String[] args)
    ClassConnectFour cf = new ClassConnectFour();
    cf.DrawBoard();
    Player1 player1 = new Player1();
    Player2 player2 = new Player2();
    player1.move();
    player2.move();
    System.out.println("Number 1 belongs to player " + player1.name());
    System.out.println("Number 2 belongs to player " + player2.name());
    PlayGame pg = new PlayGame();
    pg.StartGame();
    pg.hasWon();
    //pg.Play();
    //System.out.println(player.name());
    //System.out.println(player2.name());
    }// end main
    }//end class
    I am sorry for all this junk code but I only understand it this way. Your urgent help is required. Looking forward to your reply.
    Thanks in advance.
    Koonda
    //

    Hi,
    Thanks for your help but I really don't understand the table lookup algorithm. Could you please send me some code to implement that.
    I will send you the formatted code as well
    Thanks for your help.
    looking forward to your reply.
    Koonda
    Hi all,
    I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the game. I need to implement the hasWon() method for Horizontal win, Vertical win and Diagonal win. I also found some code examples on the net but I was unable to make it working. I have 5 classes and one interface which I m implementing. The main problem is how to implement the hasWon() method in the PlayGame class below with Horizontal, vertical and diagonal moves.
    Sorry there is so much code.
    This the interface I must implement, but now I am only implementing the int move() of this interface. I will implement the rest later after solving the winner problem with your help.
    Interface code..............
    interface Player {
    void init (Boolean color);
    String name ();
    int move ();
    void inform (int i);
    Player1 class......................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player1 implements Player
    public Player1()
    public int move()
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player1;
    System.out.println ("What is your Number, player 1?");
    player1 = scan.nextInt();
    System.out.println ("Hey number"+player1+" are you prepared to CONNECT FOUR");
    System.out.println();
    return player1;
    //Player.move();
    //return player1;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "Koonda";
    }//end player1 class
    Player2 class...........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player2 implements Player
    public int move()
    //int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    // cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
    //int num1, num2;
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player2;
    System.out.println ("What is your Number, player 2?");
    player2 = scan.nextInt();
    System.out.println ("Hey "+player2+" are you prepared to CONNECT FOUR");
    System.out.println();
    //return player1;
    return player2;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "malook";
    }//end player1 class
    PlayGame class which contains all the functionality.........................................................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class PlayGame
    //Player player1;
    //Player player2;
    int [][]ConnectFourArray;
    boolean status;
    int winner;
    int player1;
    int player2;
    public PlayGame()
    //this.player1 = player1;
    //this.player2 = player2;
    public void StartGame()
    try{
    // int X = 0, Y = 0;
    //int value;
    int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
    int[][] ConnectFourArray = new int[6][7];
    int num1, num2;
    for(int limit=21;limit!=0;limit--)
    BufferedReader selecter = new BufferedReader (new InputStreamReader(System.in));
    String column1;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=1;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=1;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=1;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=1;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=1;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=1;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=1;
    cup6=cup6-1;
    System.out.println();
    BufferedReader selecter2 = new BufferedReader (new InputStreamReader(System.in));
    String column2;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=2;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=2;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=2;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=2;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=2;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=2;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=2;
    cup6=cup6-1;
    System.out.println();
    System.out.println();
    catch (Exception E){
    System.out.println("Error with input");
    System.out.println("Would you like to play again");
    try{
    String value;
    BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
    // Scanner scan = new Scanner(System.in);
    System.out.println("Enter yes to play or no to quit");
    // value = scan.nextLine();
    // String value2;
    value = reader.readLine();
    //value2 = reader.readLine();
    if (value.equals("yes"))
    System.out.println("Start again");
    StartGame(); // calling the StartGame method to play a game once more
    else if (value.equals("no"))
    System.out.println("No more games to play");
    // System.exit(0);
    else
    System.exit(0);
    System.out.println();
    catch (Exception e){
    System.out.println("Error with input");
    finally
    System.out.println(" playing done");
    //StartGame();
    //check for horizontal win
    public int hasWon()
    int status = 0;
    for (int row=0; row<6; row++)
    for (int col=0; col<4; col++)
    if (ConnectFourArray[col][row] != 0 &&
    ConnectFourArray[col][row] == ConnectFourArray[col+1][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+2][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+3][row])
    //status = true;//int winner;
    if(status == player1)
    System.out.println("Player 1 is the winner");
    else if(status == player2)
    System.out.println("Player 2 is the winner" );
    }//end inner for loop
    }// end outer for loop
    } // end method Winner
    return status;
    }//end class
    ClassConnectFour which designs the board........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class ClassConnectFour
    //Player player1;
    //Player player2;
    public ClassConnectFour()
    //this.player1 = player1;
    public void DrawBoard()
    int[][] ConnectFourArray = new int[6][7] ;
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    }//end class
    TestConnetFour class which uses most of the above class..................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class TestConnectFour
    public static void main(String[] args)
    ClassConnectFour cf = new ClassConnectFour();
    cf.DrawBoard();
    Player1 player1 = new Player1();
    Player2 player2 = new Player2();
    player1.move();
    player2.move();
    System.out.println("Number 1 belongs to player " + player1.name());
    System.out.println("Number 2 belongs to player " + player2.name());
    PlayGame pg = new PlayGame();
    pg.StartGame();
    pg.hasWon();
    //pg.Play();
    //System.out.println(player.name());
    //System.out.println(player2.name());
    }// end main
    }//end classI am sorry for all this junk code but I only understand it this way. Your urgent help is required. Looking forward to your reply.
    Thanks in advance.
    Koonda

  • Reversi GUI question, A LOT of code in here!

    okay, so I've been working on his code for a long time. A REAL long time, working on it bit by bit, and all I got left is the Reversi's GUI. Basically I want to use the Jbutton and have x represent black and o represent white. I'm getting stuck on how to go about it. Any ideas?
    Here's alllll the code.
    package com.Ozo.games.reversi;
    * This utility class provides a number of static constants and
    * methods that provide abstractions for player colors and moves.
    * Colors and moves could be implemented as objects of separate
    * classes, but instead we represent them as integers and provide
    * the abstraction via these operations.
    public class Reversi {
         public static final int Black = 1;
         public static final int White = 2;
         public static final int Empty = 0;
          * Gives the color of a player's opponent.
          * @param color of this player.
          * @return color of the opponent.
         public static int playerOpposite(int color) {
              if (color == Black) return White;
              if (color == White) return Black;
              throw new Error("Player must be Black or White");
          * Compare two scores and determine whether the first is better than the second.
          * Better for black means more positive.  Better for white means more negative.
          * @param colorAsking
          * @param score1
          * @param score2
          * @return whether score1 is better than score2, as far as colorAsking is concerned.
         public static boolean isBetterScore(int colorAsking, int score1, int score2) {
              if (colorAsking == Black) return score1 > score2;
              if (colorAsking == White) return score1 < score2;
              throw new Error("Player must be Black or White");
          * Encode a move from this position as an integer.
          * A "pass" move is recorded as (-1,-1).
          * @param pos the board this move is for.
          * @param row the row at which the piece is placed.
          * @param col the column at which the piece is placed.
          * @return encoded move.
         public static int newMove(ReversiPosition pos, int row, int col) {
              return row * pos.ncols() + col;
          * A "pass" move.  I.e. no piece is placed.
         public static int newMovePass(ReversiPosition pos) {
              return newMove(pos, -1, -1);
          * Find the row of an encoded move.
          * @param pos the board this move is for.
          * @param move
          * @return the row.
         public static int moveRow(ReversiPosition pos, int move) {
              return move / pos.ncols();
          * Find the column of an encoded move.
          * @param pos the board this move is for.
          * @param move
          * @return the column.
         public static int moveCol(ReversiPosition pos, int move) {
              return move % pos.ncols();
    package com.Ozo.games.reversi;
    * Top-level driver for a Reversi game.
    public class ReversiGame {
         private ReversiPosition   _pos;
         private int               _toMoveColor;
         private ReversiTextIO     _userInterface;
         public ReversiGame(int nrows, int ncols) {
              _pos           = new ReversiPosition(nrows, ncols);
              _toMoveColor   = Reversi.Black;
              _userInterface = null;
              ReversiRules.setStartingPosition(_pos);
         public void setUserInterface(ReversiTextIO ui) {
              _userInterface = ui;
         public ReversiPosition currentPosition() { return _pos; }
         public int             toMoveColor()     { return _toMoveColor; }
         public void getHumanMoveAndApplyIt() {
              if (ReversiRules.countLegalMoves(_pos, _toMoveColor) != 0) {
                   int move = _userInterface.getMove(_pos, _toMoveColor);
                   _pos.applyMove(move, _toMoveColor);
              else
                   _userInterface.message("You have no move.  I get another turn.");
              _toMoveColor = Reversi.playerOpposite(_toMoveColor);
         public void getComputerMoveAndApplyIt() {
              if (ReversiRules.countLegalMoves(_pos, _toMoveColor) != 0) {
                   int move = ReversiStrategy.findBestMove(_pos, _toMoveColor);
                   _pos.applyMove(move, _toMoveColor);
              else
                   _userInterface.message("I have no move.  You get another turn.");
              _toMoveColor = Reversi.playerOpposite(_toMoveColor);
         public void play() {
              _userInterface.output(_pos);
              for (;;) {
                   if (ReversiRules.isGameOver(_pos, _toMoveColor)) { gameOverMessage(); break; }
                   getHumanMoveAndApplyIt();
                   _userInterface.output(_pos);
                   if (ReversiRules.isGameOver(_pos, _toMoveColor)) { gameOverMessage(); break; }
                   getComputerMoveAndApplyIt();
                   _userInterface.output(_pos);
         public void gameOverMessage() {
              _userInterface.message("Game over...");
              int winner = ReversiRules.winningColor(_pos, _toMoveColor);
              if      (winner == Reversi.Black) _userInterface.message("Black wins.");
              else if (winner == Reversi.White) _userInterface.message("White wins.");
              else    _userInterface.message("Draw.");
    package com.Ozo.games.reversi;
    * The main class to start a Reversi game as an application.
    public class ReversiMain {
         public static void main(String[] args) {
              ReversiGame   game = new ReversiGame(8, 8);
              ReversiTextIO tui  = new ReversiTextIO(System.in, System.out);
              game.setUserInterface(tui);
              game.play();
    }

    package com.Ozo.games.reversi;
    * This class provides all of the intelligence for a program to play Reversi.
    * It contains all the knowledge of play strategy.  (The knowledge of the rules
    * is maintained by the ReversiRules class.)
    * The principal method is findBestMove, which does an exhaustive search a number
    * of plys deep, and then applies a hueristic position evaluation function.
    public class ReversiStrategy {
         private static int PlysToTry = 6;
          * Find the best move for the player of the given color.
          * If there is no move, then return "pass".
          * @param pos the position to be evaluated.
          * @param toMoveColor the color of player to move.
          * @param plysRemaining the depth to examine (must be >= 1).
          * @return the best move within the default horizon.
         public static int findBestMove(ReversiPosition pos, int toMoveColor) {
              return findBestMove(pos, toMoveColor, PlysToTry).move;
          * This class is used to return a pair of values:  the best move and the score it achieves
          * after the number of plys remaining are played.
         public static class BestMove {
              public int move;
              public int score;
              public BestMove(int m, int s) { move = m; score = s; }
          * Find the best move for the player of the given color within
          * the given number of plys.
          * @param pos the position to be evaluated.
          * @param toMoveColor the color of player to move.
          * @param plysRemaining the depth to examine (must be >= 1).
          * @return a BestMove object returning the best move found and the score it achieves.
         public static BestMove findBestMove(ReversiPosition pos, int toMoveColor, int plysRemaining) {
              if (plysRemaining < 1) throw new Error("findBestMove needs plysRemaining >= 1");
              // Generate the legal moves.  If there are none, then pass.
              int opponentColor = Reversi.playerOpposite(toMoveColor);
              int[] moves = ReversiRules.generateMoves(pos, toMoveColor);
              if (moves.length == 0) {
                   if (plysRemaining == 1)
                        return new BestMove(Reversi.newMovePass(pos), summaryScore(pos));
                   else
                        return findBestMove(pos, opponentColor, plysRemaining-1);
              // Try all the moves.  Re-use one position object to make the move.
              ReversiPosition afterMove = pos.copy();
              // Start with a hypothetical worst scenario and then look for what's better.
              afterMove.fill(opponentColor);
              int bestScore = 2*summaryScore(afterMove);  // Worse that the worst possible real score.
              int bestIndex = -1;
              for (int i = 0; i < moves.length; i++) {
                   pos.copyInto(afterMove);      // Re-use the position object.
                   afterMove.applyMove(moves, toMoveColor);
                   int thisScore = (plysRemaining == 1) ?
                        summaryScore(afterMove) :
                        findBestMove(afterMove, opponentColor, plysRemaining - 1).score;
                   if (Reversi.isBetterScore(toMoveColor, thisScore, bestScore)) {
                        bestScore = thisScore;
                        bestIndex = i;
              if (bestIndex == -1) System.out.println("Number of moves " + moves.length + " plys " + plysRemaining);
              return new BestMove(moves[bestIndex], bestScore);
         * Examine contents of square and return 1 for Black, -1 for White, 0 for Empty.
         * Useful in computing scores.
         * @param r row number.
         * @param c column number.
         * @return +1/-1/0
         private static int squareVal(ReversiPosition pos, int r, int c) {
              if (pos.getSquare(r, c) == Reversi.White) return -1;
              if (pos.getSquare(r, c) == Reversi.Black) return +1;
              return 0;
         * Count the number of black squares minus the number of white squares.
         * @return difference in number of black and white squares.
         public static int squareScore(ReversiPosition pos) {
              int nBminusW = 0;
              for (int r = 0; r < pos.nrows(); r++)
                   for (int c = 0; c < pos.ncols(); c++)
                        nBminusW += squareVal(pos, r, c);
              return nBminusW;
         * Count the number of black edge squares minus the number of white ones.
         * @return difference in number of black and white squares.
         public static int edgeScore(ReversiPosition pos) {
              int nBminusW = 0;
              // East and west edges.
              for (int r = 1; r < pos.nrows()-1; r++)
                   nBminusW += squareVal(pos, r, 0) + squareVal(pos, r, pos.ncols()-1);
              // North and south edges.
              for (int c = 1; c < pos.ncols()-1; c++)
                   nBminusW += squareVal(pos, 0, c) + squareVal(pos, pos.nrows()-1, c);
              return nBminusW;
         * Count the number of black corner squares minus the number of white ones.
         * @return difference in number of black and white squares.
         public static int cornerScore(ReversiPosition pos) {
              int rlast = pos.nrows()-1, clast = pos.ncols()-1;
              return squareVal(pos, 0, 0) + squareVal(pos, 0, clast) +
              squareVal(pos, rlast, 0) + squareVal(pos, rlast, clast);
         * Compute a heuristic score for a given position. The more positive,
         * the better for Black. Controlling corners is weighted most heavily,
         * folowed by sides, then regular squares. In principle a different weight
         * function should be used at the end of the game, since then it is really
         * the total number of squares that counts.
         * @param pos the position to be assessed.
         * @return the numerical score, with positive being good for Black, negative good for White.
         public static int summaryScore(ReversiPosition pos) {
                   return squareScore(pos) + 8*edgeScore(pos) + 20*cornerScore(pos);
    }Edited by: Oozaro on Nov 19, 2009 12:41 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Javax.transaction.RollbackException

    Please take few moments to look at this code. I can't see what I am doing wrong. Can you? it is about the RollbackException. the create method inserts a record in de database, but I am not sure if the container rolls it back, or may be the primary key class is not well implemented.
    Your help is very appreciated. I am stack here since 3 days ;(
    The create method in the Movie_LoanBean
    public Movie_LoanKey ejbCreate (int Member,int Movie,int copy_number,java.sql.Date DayDate_Loaned)
    throws CreateException {
    if (Member == 0 || Movie == 0 || copy_number == 0 || DayDate_Loaned == null ) {
    throw new CreateException(
    "Rerquired fields are not filled.");
    try {
    insertMovie_Loan(Member , Movie , copy_number , DayDate_Loaned );
    this.Member = Member;
    this.Movie = Movie;
    this.copy_number = copy_number;
    this.DayDate_Loaned = DayDate_Loaned;
    return new Movie_LoanKey(Member, Movie, copy_number, DayDate_Loaned);
    } catch (Exception e) {
    throw new CreateException (e.toString());
    private void insertMovie_Loan(int Member,int Movie,int copy_number,java.sql.Date DayDate_Loaned)
    throws SQLException {
    makeConnection();
    System.out.println("in insertMovie_Loan");
    String insertStatement = "INSERT INTO Movie_Loan2 VALUES(?, ?, ?, ?)";
    PreparedStatement prepStmt = con.prepareStatement(insertStatement);
    prepStmt.setInt(1, Member);
    prepStmt.setInt(2, Movie);
    prepStmt.setInt(3, copy_number);
    prepStmt.setDate(4, (java.sql.Date) DayDate_Loaned);
    prepStmt.executeUpdate();
    prepStmt.close();
    System.out.println("leaving insertMovie_Loan");
    releaseConnection();
    The primary key class
    public class Movie_LoanKey implements java.io.Serializable {
    public int Member;
    public int Movie;
    public int copy_number;
    public java.sql.Date DayDate_Loaned;
    public Movie_LoanKey() {}
    public Movie_LoanKey(int Member, int Movie, int copy_number, java.sql.Date DayDate_Loaned) {
    this.Member = Member;
    this.Movie = Movie;
    this.copy_number = copy_number;
    this.DayDate_Loaned = DayDate_Loaned;
    public int getMember() {
    return Member;
    public int getMovie() {
    return Movie;
    public int getcopy_number() {
    return copy_number;
    public java.sql.Date getDayDate_Loaned() {
    return DayDate_Loaned;
    public boolean equals (Object obj) {
    if ( obj == null || !( obj instanceof Movie_LoanKey ))
    return false;
    else if ( (((Movie_LoanKey) obj).Member == Member) && (((Movie_LoanKey) obj).Movie == Movie) && (((Movie_LoanKey) obj).copy_number == copy_number) && (((Movie_LoanKey) obj).DayDate_Loaned == DayDate_Loaned) )
    return true;
    else
    return false;
    public String toString() {
    return String.valueOf(Member) + String.valueOf(Movie) + String.valueOf(copy_number) + DayDate_Loaned.toString() ;
    public int hashCode() {
    String tmp0 = String.valueOf(Member) ;
    String tmp1 = String.valueOf(Movie) ;
    String tmp2 = String.valueOf(copy_number) ;
    String tmp3 = DayDate_Loaned.toString();
    return tmp0.concat(tmp1).concat(tmp2).concat(tmp3).hashCode();
    The client
    import java.util.*;
    import java.math.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    public class LoanClient {
    public static void main(String[] args) {
    try {
    Context initial = new InitialContext();
    Object objref = initial.lookup("java:comp/env/ejb/SimpleLoan");
    Movie_LoanHome home = (Movie_LoanHome) PortableRemoteObject.narrow(objref,
    Movie_LoanHome.class);
    java.sql.Date d1 = java.sql.Date.valueOf("04-01-05");
    Movie_Loan duke = home.create(1,3,4,d1);
    System.exit(0);
    } catch (Exception ex) {
    System.err.println("Caught an exception.");
    ex.printStackTrace();
    When I run this code I get the following error:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exce
    ption is:
    java.rmi.RemoteException: Transaction aborted; nested exception is: java
    x.transaction.RollbackException; nested exception is:
    javax.transaction.RollbackException
    at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.ja
    va:170)
    at javax.rmi.CORBA.Util.mapSystemException(Util.java:65)
    at MovieLoanHome_Stub.create(Unknown Source)
    at LoanClient.main(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:28
    5)
    at com.sun.enterprise.appclient.Main.<init>(Main.java:420)
    at com.sun.enterprise.appclient.Main.main(Main.java:92)
    Caused by: java.rmi.RemoteException: Transaction aborted; nested exception is: j
    avax.transaction.RollbackException; nested exception is:
    javax.transaction.RollbackException
    at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.ja
    va:213)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:79
    7)
    at com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocat
    ionHandler.java:194)

    It means that your code somewhere throws a system exception.
    Have you tried to debug you'r bean ? Run EJB server under an IDE with debugging capabilities (JBuilder, IDEA).
    This would speed up your development.
    Why do you use a BMP beans ? In this case CMP would work without any problems.

  • Connecting Classes

    Hello. I am trying to connect this class
    import java.awt.event.*;
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class Game extends Applet
        // instance variables - replace the example below with your own
        public int[][] board = new int[5][5];
        public int[] boardx = new int[5];
        public int[] boardy = new int[5];
        public int[] army = new int[4];
        public int actx = 0;
        public int acty = 0;
        public int paintx = 0;
        public int painty = 0;
        public GunMan[] guy = new GunMan[1];
    Called by the browser or applet viewer to inform this Applet 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()
            showStatus("Initstalizing");
            int i = 0;
            boolean doneinit = false;
            while(!doneinit)
                boardx[i] = i*50;
                boardy[i] = i*50;
                i++;
                if(i==4)
                    doneinit = true;
            guy[1].atx = boardx[1];
            guy[1].aty = boardy[4];
            doneinit = false;
            i = 0;
            int z = 0;
            while(!doneinit)
                board[i][z] = 0;
                i++;
                if(z == 4 && i == 4)
                    doneinit = true;
                    break;
                if(i == 4)
                    i = 0;
                    z++;
                showStatus("Done...");
            addMouseListener(new MouseListener() {
                    public void mouseExited(MouseEvent me) {};
                    public void mouseEntered(MouseEvent me) {};
                    public void mouseReleased(MouseEvent me) {};
                    public void mousePressed(MouseEvent me) {};
                    public void mouseClicked(MouseEvent me) {
                        paintx = me.getX();
                        painty = me.getY();
                        actx = -1;
                        for (int ii=0; ii<boardx.length-1; ii++) {
                            if((paintx >= boardx[ii]) && (paintx < boardx[ii+1]))
                                actx = ii+1;
                                break;
                        actx = (actx<0 ? boardx.length-1: actx);
                        acty = -1;
                        for (int ii=0; ii<boardy.length-1; ii++) {
                            if((painty >= boardy[ii]) && (painty < boardy[ii+1]))
                                acty = ii+1;
                                break;
                        acty = (acty<0 ? boardy.length-1: acty);
                        repaint();
            // provide any initialisation necessary for your Applet
        /** Paint method for applet.
    @param  g   the Graphics object for this applet*/
        public void paint(Graphics g)
            showStatus("Painting...");
            URL url = getCodeBase();
        Image gun = getImage(url, "pictures/gunman.jpg");
        Image plain = getImage(url, "pictures/plain.JPG");
        Image mountain = getImage(url, "pictures/mountain.jpg");
        Image crawler = getImage(url, "pictures/crawler.jpg");
            // simple text displayed on applet
            g.setColor(Color.white);
            g.fillRect(0, 0, 250, 250);
            g.setColor(Color.black);
            g.drawString(String.valueOf(actx), 300, 10);
            g.drawString(String.valueOf(acty), 320, 10);
            g.drawString(String.valueOf(paintx), 340, 10);
            g.drawString(String.valueOf(painty), 360, 10);
            g.drawImage(gun, guy[1].atx, guy[1].aty, this);
            int z = 0;
            int i = 0;
            boolean good = false;
            while(!good)
                g.drawString(String.valueOf(boardx), 300 +i*50, 30);
    g.drawString(String.valueOf(boardy[z]), 300+ i*50, 120);
    i++;
    z++;
    if(z == 4 && i == 4)
    good = true;
    z = 0;
    i = 0;
    boolean doneinit = false;
    while(!doneinit)
    g.drawImage(plain, boardx[i], boardy[z], this);
    g.drawRect(boardx[i], boardy[z], 50, 50);
    i++;
    if(z == 4 && i == 4)
    doneinit = true;
    if(i == 4)
    i = 0;
    z++;
    showStatus("Done");
    With this onepublic class GunMan
    public boolean burn = false;
    public boolean dead = false;
    public int health = 10;
    public int atx;
    public int aty;
    public int move = 2;
    public void movement(int x, int y)
    int tox;
    int toy;
    int validmove = 0;
    if((x%50) == (0))
    tox = x;
    while((tox != atx) && (validmove <= move))
    if(tox <= atx)
    atx -= 50;
    validmove += 1;
    if(tox >= atx)
    atx += 50;
    validmove += 1;
    if((y%50) == (0))
    toy = y;
    while((toy != aty) && (validmove <= move))
    if(toy <= aty)
    aty -= 50;
    validmove += 1;
    if(toy >= aty)
    aty += 50;
    validmove += 1;
    public void initSpace(int xstart, int ystart)
    atx = xstart;
    aty = ystart;
    public void attacked(int damage)
    health -= damage;
    if(health <= 0)
    dead = true;
    I want to be able to call certain things from the GunMan class, but when I run it in the applet viewer, it says "Start: Applet Not Initialized"
    What is wrong?
    Is there something I have to implement or import?
    Or is there something totally different than what I am thinking of?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I want to be able to call certain things from the GunMan class,But you don't. So it's irrelevant to the following question:
    but when I run it in the applet viewer, it says "Start: Applet Not Initialized"... unless you're trying to run the GunMan class in the applet viewer. If you are, then don't, because it isn't an applet. If you're actually trying to run the Game class in the applet viewer, then look in its Java console to see what exceptions the init() method is throwing.

  • Balls don't move in bouncing balls game.Please Help !?

    I want to repaint the canvas panel in this bouncing balls game, but i do something wrong i don't know what, and the JPanel doesn't repaint?
    The first class defines a BALL as a THREAD
    If anyone knows how to correct the code please to write....
    package ****;
    //THE FIRST CLASS
    class CollideBall extends Thread{
        int width, height;
        public static final int diameter=15;
        //coordinates and value of increment
        double x, y, xinc, yinc, coll_x, coll_y;
        boolean collide;
        Color color;
        Rectangle r;
        bold BouncingBalls balls; //A REFERENCE TO SECOND CLASS
        //the constructor
        public CollideBall(int w, int h, int x, int y, double xinc, double yinc, Color c, BouncingBalls balls) {
            width=w;
            height=h;
            this.x=x;
            this.y=y;
            this.xinc=xinc;
            this.yinc=yinc;
            this.balls=balls;
            color=c;
            r=new Rectangle(150,80,130,90);
        public double getCenterX() {return x+diameter/2;}
        public double getCenterY() {return y+diameter/2;}
        public void move() {
            if (collide) {
            x+=xinc;
            y+=yinc;
            //when the ball bumps against a boundary, it bounces off
            //bounce off the obstacle
        public void hit(CollideBall b) {
            if(!collide) {
                coll_x=b.getCenterX();
                coll_y=b.getCenterY();
                collide=true;
        public void paint(Graphics gr) {
            Graphics g = gr;
            g.setColor(color);
            //the coordinates in fillOval have to be int, so we cast
            //explicitly from double to int
            g.fillOval((int)x,(int)y,diameter,diameter);
            g.setColor(Color.white);
            g.drawArc((int)x,(int)y,diameter,diameter,45,180);
            g.setColor(Color.darkGray);
            g.drawArc((int)x,(int)y,diameter,diameter,225,180);
            g.dispose(); ////////
        ///// Here is the buggy code/////
        public void run() {
            while(true) {
                try {Thread.sleep(15);} catch (Exception e) { }
                synchronized(balls)
                    move();
                    balls.repairCollisions(this);
                paint(balls.gBuffer);
                balls.canvas.repaint();
    //THE SECOND CLASS
    public class BouncingBalls extends JFrame{
        public Graphics gBuffer;
        public BufferedImage buffer;
        private Obstacle o;
        private List<CollideBall> balls=new ArrayList();
        private static final int SPEED_MIN = 0;
        private static final int SPEED_MAX = 15;
        private static final int SPEED_INIT = 3;
        private static final int INIT_X = 30;
        private static final int INIT_Y = 30;
        private JSlider slider;
        private ChangeListener listener;
        private MouseListener mlistener;
        private int speedToSet = SPEED_INIT;
        public JPanel canvas;
        private JPanel p;
        public BouncingBalls() {
            super("****");
            setSize(800, 600);
            p = new JPanel();
            Container contentPane = getContentPane();
            final BouncingBalls xxxx=this;
            o=new Obstacle(150,80,130,90);
            buffer=new BufferedImage(getSize().width, getSize().height, BufferedImage.TYPE_INT_RGB);
            gBuffer=buffer.getGraphics();
            //JPanel canvas start
            canvas = new JPanel() {
                final int w=getSize().width-5;
                final int h=getSize().height-5;
                @Override
                public void update(Graphics g)
                   paintComponent(g);
                @Override
                public void paintComponent(Graphics g) {
                    super.paintComponent(g);
                    gBuffer.setColor(Color.ORANGE);
                    gBuffer.fillRect(0,0,getSize().width,getSize().height);
                    gBuffer.draw3DRect(5,5,getSize().width-10,getSize().height-10,false);
                    //paint the obstacle rectangle
                    o.paint(gBuffer);
                    g.drawImage(buffer,0,0, null);
                    //gBuffer.dispose();
            };//JPanel canvas end
            addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
            addButton(p, "Start", new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    CollideBall b = new CollideBall(canvas.getSize().width,canvas.getSize().height
                            ,INIT_X,INIT_Y,speedToSet,speedToSet,Color.BLUE,xxxx);
                    balls.add(b);
                    b.start();
            contentPane.add(canvas, "Center");
            contentPane.add(p, "South");
        public void addButton(Container c, String title, ActionListener a) {
            JButton b = new JButton(title);
            c.add(b);
            b.addActionListener(a);
        public boolean collide(CollideBall b1, CollideBall b2) {
            double wx=b1.getCenterX()-b2.getCenterX();
            double wy=b1.getCenterY()-b2.getCenterY();
            //we calculate the distance between the centers two
            //colliding balls (theorem of Pythagoras)
            double distance=Math.sqrt(wx*wx+wy*wy);
            if(distance<b1.diameter)
                return true;
            return false;
        synchronized void repairCollisions(CollideBall a) {
            for (CollideBall x:balls) if (x!=a && collide(x,a)) {
                x.hit(a);
                a.hit(x);
        public static void main(String[] args) {
            JFrame frame = new BouncingBalls();
            frame.setVisible(true);
    }  This code draws only the first position of the ball:
    http://img267.imageshack.us/my.php?image=51649094by6.jpg

    I'm trying to draw everything first to a buffer:
    buffer=new BufferedImage(getSize().width, getSize().height, BufferedImage.TYPE_INT_RGB);
    gBuffer=buffer.getGraphics();
    The buffer is for one JPanel and then i want to draw this buffer every time when balls change their possitions(collide or just move).
    The logic is something like this:
    startButton -> (ball.start() and add ball to List<balls>),
    ball.start() -> ball.run() -> (move allballs, paint to buffer and show buffer)
    In the first class:
    BouncingBalls balls; //A REFERENCE TO SECOND CLASS
    In the second class:
    private List<CollideBall> balls=new ArrayList();
    the tames are the same but this isn't an error.
    Edited by: vigour on Feb 14, 2008 7:57 AM

  • Need help making ball move and bounce off of sides of JPanel

    I'm currently working on a program that creates a ball of random color. I'm trying to make the ball move around the JPanel it is contained in and if it hits a wall it should bounce off of it. I have been able to draw the ball and make it fill with a random color. However, I cannot get it to move around and bounce off the walls. Below is the code for the class that creates the ball. Should I possible be using multithreads? As part of the project requirements I will need to utilizes threads and include a runnable. However, I wanted to get it working with one first and than add to it as the final product needs to include new balls being added with each mouse click. Any help would be appreciated.
    Thanks
    import java.awt.Color;
    import java.awt.Graphics;
    import javax.swing.JPanel;
    public class Ball extends JPanel{
        Graphics g;
        int rval; // red color value
        int gval; // green color value
        int bval; // blue color value
        private int x = 1;
        private int y = 1;
        private int dx = 2;
        private int dy = 2;
        public void paintComponent(Graphics g){
            for(int counter = 0; counter < 100; counter++){
                // randomly chooses red, green and blue values changing color of ball each time
                rval = (int)Math.floor(Math.random() * 256);
                gval = (int)Math.floor(Math.random() * 256);
                bval = (int)Math.floor(Math.random() * 256);
                super.paintComponent(g);
                g.drawOval(0,0,30,30);   // draws circle
                g.setColor(new Color(rval,gval,bval)); // takes random numbers from above and creates RGB color value to be displayed
                g.fillOval(x,y,30,30); // adds color to circle
                move(g);
        } // end paintComponent
        public void move(Graphics g){
            g.fillOval(x, y, 30, 30);
            x += dx;
            y += dy;
            if(x < 0){
                x = 0;
                dx = -dx;
            if (x + 30 >= 400) {
                x = 400 - 30;
                dx = -dx;
            if (y < 0) {
                y = 0;
                dy = -dy;
            if (y + 30 >= 400) {
                y = 400 - 30;
                dy = -dy;
            g.fillOval(x, y, 30, 30);
            g.dispose();
    } // end Ball class

    Create a bounding box using the size of the panel. Each time you move the ball, check that it's still inside the box. If it isn't, then change it's direction. You know where the ball is, (x, y), so just compare those values to the boundary values.

  • Getting objects to move between PCs

    After CS 150, I find myself back in the world of Java. I recently learned a neat language called Processing (a.k.a. Proce55ing), and I am one of the coders (and am way rusty to be of much use at this point) for a really cool project.
    I'm wondering if I can nag you with some questions on java.net.*. I need to get some objects passed around between 3 PCs. I need to know about latency issues. Basically, we've got Java doing OpenGL graphics on 6 projectors powered by 3 computers. Imagine each PC having a really wide screen... when a autonomous creature gets to the edge of one PC, it needs to continue its thang on the next PC... move fluidly.
    I've checked out some Java.net.* sample code on sun's site. Specifically their KnockKnock Server. However, its multithread support is for interacting with clients on a one-on-one basis... not like a chat-room style environment. So, I don't even have any sample code for a ultra-basic Java Chat Room.... nor do I know how to pass anything but a string to the server, or to the client.
    There are ways to use my limited knowledge to do what I want to do... just pass a string, and have the server store that into a variable which is accessible by every server thread. Then, create a loop in main that keeps searching through that array of strings to pass them off to the PC... the string would have the coordinate information of the autonomous creature, and create a new one of that object with those Vec3f point. However, latency is a key issue, and it would be easiest if I could just pass an object to the server (in this case: a SimpleVehicle) along with an intended target computer, and then that computer would get that vehicle to add to its array of SimpleVehicles. The important thing is speed, so it might be best to have every computer have a client<->server connection with each other... I get utterly baffled reading the Java Docs. But, I seem to understand code when I see it (I can only reverse engineer). I especially understand the KnockKnock Server and MultiClient code on the Sun's Java Networking Tutorial.
    Any pointers to which methods I need to learn (I already realize I'm going to need to downcast the SimpleVehicle object back into a SimpleVehicle after it gets sent). Thanks a million.

    Ok, try this.
    The simplistic application sends colored balls between instances of itself which can be on any machine on your network.
    As a ball reaches the left side of the window it is in, it gets sent to the machine on it's left (if any), likewise if it reaches the right side of the window it gets sent to the machine on it's right. If there is no machine on the side the ball is trying to go, it rebounds within the window it is in.
    So, a simple test is to run three instances on the same machine, one is regarded as one the left on as on the right and one as in the middle
    To start the one on the left:
    java Ziniman1 8000 -right localhost:8001
    To start the one in the middle:
    java Ziniman1 8001 -left localhost:8000 -right localhost:8002
    To start the one on the right:
    java Ziniman1 8002 -left localhost:8001
    Note: You need to start these pretty quickly one after the other or the socket creation will time out. I'll leave that to you to fix ;)
    Once the apps are running, move them so they are next to each other, left to right (the port numbers used as the server port are in the JFrame title).
    To get create a ball, just click on one of the white panels, use the radio buttons at the bottom to change size/color/direction of the new balls.
    Once you've got the hang of the thing, try moving some instances to other machnes.
    Enjoy!
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class Ziniman1
         static final String LEFT= "Left";
         static final String RIGHT= "Right";
         static class Ball
              implements Serializable
              public int x= -1;
              public int y;
              public int size= 10;
              private Color mColor;
              public Ball(Color color) { mColor= color; }
              public Ball(Color color, int y) { mColor= color; this.y= y; }
              public Color getColor() { return mColor; }
              public String toString() { return "(" +x +"," +y +") x " +size; }
         static interface DirectionalListener
              public void left(Ball ball);
              public void right(Ball ball);
         static class Directional
              private DirectionalListener mListener= null;
              public final void setListener(DirectionalListener listener) {
                   mListener= listener;
              protected final void fireLeft(Ball ball)
                   if (mListener != null)
                        mListener.left(ball);
              protected final void fireRight(Ball ball)
                   if (mListener != null)
                        mListener.right(ball);
         static class Server
              extends Directional
              public Server(final int port)
                   new Thread() {
                        public void run() {
                             try {
                                  ServerSocket listenSocket= new ServerSocket(port);
                                  System.err.println("Server listening on port " +port);
                                  while (true)
                                       connect(listenSocket.accept());
                             catch (Exception e) {
                                  e.printStackTrace();
                   }.start();
              private synchronized void connect(final Socket socket)
                   Thread thread= new Thread() {
                        public void run() {
                             try {
                                  ObjectInputStream is=
                                       new ObjectInputStream(socket.getInputStream());
                                  while (true) {
                                       String side= (String) is.readObject();
                                       Ball ball= (Ball) is.readObject();
                                       if (side.equals(RIGHT))
                                            fireLeft(ball);
                                       else
                                            fireRight(ball);
                             catch (Exception e) {
                                  e.printStackTrace();
                   thread.setDaemon(true);
                   thread.start();
         static class Client
              private ObjectOutputStream mOs;
              private String mSide;
              public Client(String host, int port, String side)
                   throws Exception
                   mSide= side;
                   Socket socket= new Socket(host, port);
                   mOs= new ObjectOutputStream(socket.getOutputStream());
                   System.err.println(
                        mSide +" client connected to " +host +":" +port);
              private void send(Ball ball)
                   try {
                        mOs.writeObject(mSide);
                        mOs.writeObject(ball);
                   catch (Exception e) {
                        e.printStackTrace();
         static abstract class BallPanel
              extends JPanel
              public void paint(Graphics g)
                   g.setColor(Color.WHITE);
                   g.fillRect(0, 0, getSize().width, getSize().height);
                   Iterator balls= getBalls();
                   while (balls.hasNext()) {
                        Ball ball= (Ball) balls.next();
                        g.setColor(ball.getColor());
                        g.fillOval(ball.x, ball.y, ball.size, ball.size);
              public Dimension getPreferredSize() {
                   return new Dimension(300, 240);
              public abstract Iterator getBalls();
         static class Gui
              extends Directional
              private Runnable mUpdater= new Runnable() {
                   public void run() { mBallPanel.repaint(); }
              private ArrayList mLeft= new ArrayList();
              private ArrayList mRight= new ArrayList();
              private ArrayList mBalls= new ArrayList();
              private BallPanel mBallPanel= new BallPanel() {
                   public Iterator getBalls() {
                        return mBalls.iterator();
              public Gui(String title)
                   final JRadioButton red= new JRadioButton("Red");
                   final JRadioButton green= new JRadioButton("Green");
                   final JRadioButton blue= new JRadioButton("Blue");
                   ButtonGroup group= new ButtonGroup();
                   group.add(red);
                   group.add(blue);
                   group.add(green);
                   final JRadioButton large= new JRadioButton("Large");
                   final JRadioButton small= new JRadioButton("Small");
                   group= new ButtonGroup();
                   group.add(large);
                   group.add(small);
                   final JRadioButton left= new JRadioButton("Left");
                   final JRadioButton right= new JRadioButton("Right");
                   group= new ButtonGroup();
                   group.add(left);
                   group.add(right);
                   red.setSelected(true);
                   small.setSelected(true);
                   right.setSelected(true);
                   mBallPanel.addMouseListener(new MouseAdapter() {
                        public void mousePressed(MouseEvent e) {
                             Ball ball= new Ball(
                                  red.isSelected() ? Color. RED :
                                  blue.isSelected() ? Color.BLUE : Color.GREEN);
                             ball.x= e.getX();
                             ball.y= e.getY();
                             ball.size= large.isSelected() ? 20 : 10;
                             if (left.isSelected())
                                  left(ball);
                             else
                                  right(ball);
                   JPanel panel= new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4));
                   panel.add(red);
                   panel.add(blue);
                   panel.add(green);
                   panel.add(large);
                   panel.add(small);
                   panel.add(left);
                   panel.add(right);
                   JFrame frame= new JFrame(title);
                   frame.getContentPane().add(mBallPanel, BorderLayout.CENTER);
                   frame.getContentPane().add(panel, BorderLayout.SOUTH);
                   frame.pack();
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.setVisible(true);
              public synchronized void move(int delta)
                   Iterator left= mLeft.iterator();
                   while (left.hasNext()) {
                        Ball ball= (Ball) left.next();
                        ball.x -= delta;
                        if (ball.x <= 0) {
                             left.remove();
                             mBalls.remove(ball);
                             fireLeft(ball);
                   Iterator right= mRight.iterator();
                   while (right.hasNext()) {
                        Ball ball= (Ball) right.next();
                        ball.x += delta;
                        if (ball.x >= (mBallPanel.getSize().width -ball.size)) {
                             right.remove();
                             mBalls.remove(ball);
                             fireRight(ball);
                   SwingUtilities.invokeLater(mUpdater);
              public synchronized void left(Ball ball)
                   mLeft.add(ball);
                   mBalls.add(ball);
                   if (ball.x < 0)
                        ball.x= mBallPanel.getSize().width -(ball.size/2);
                   SwingUtilities.invokeLater(mUpdater);
              public synchronized void right(Ball ball)
                   mRight.add(ball);
                   mBalls.add(ball);
                   if (ball.x < 0)
                        ball.x= ball.size/2;
                   SwingUtilities.invokeLater(mUpdater);
         static class Controller
              public Controller(
                   final Gui gui, final Server server,
                   final Client left, final Client right)
                   gui.setListener(new DirectionalListener() {
                        // Ball reached the left
                        public void left(Ball ball)
                             ball.x= -1;
                             if (left == null)
                                  gui.right(ball);
                             else
                                  left.send(ball);
                        // Ball reached the right
                        public void right(Ball ball)
                             ball.x= -1;
                             if (right == null)
                                  gui.left(ball);
                             else
                                  right.send(ball);
                   server.setListener(new DirectionalListener() {
                        // Ball came from the left
                        public void left(Ball ball) {
                             gui.right(ball);
                        // Ball came from the right
                        public void right(Ball ball) {
                             gui.left(ball);
                   Thread thread= new Thread() {
                        public void run() {
                             while (true) {
                                  try { sleep(100); }
                                  catch (InterruptedException e) { }
                                  gui.move(10);
                   thread.setDaemon(true);
                   thread.start();
         private static final String USAGE=
              "Usage: java Ziniman1 " +
              "<server port> [-left <host:port>] [-right <host:port>]";
            public static void main(String[] argv)
              throws Exception
              if (argv.length < 1)
                   barf();
              int leftPort= -1;
              int rightPort= -1;
              String leftHost= "localhost";
              String rightHost= "localhost";
              int serverPort= Integer.parseInt(argv[0]);
              for (int i= 1; i< argv.length; i += 2) {
                   if (argv.equals("-left")) {
                        if (argv.length == i+1)
                             barf();
                        String url= argv[i+1];
                        if (url.indexOf(":") < 0)
                             barf();
                        leftHost= url.substring(0, url.indexOf(":"));
                        leftPort= Integer.parseInt(url.substring(url.indexOf(":")+1));
                   else if (argv[i].equals("-right")) {
                        if (argv.length == i+1)
                             barf();
                        String url= argv[i+1];
                        if (url.indexOf(":") < 0)
                             barf();
                        rightHost= url.substring(0, url.indexOf(":"));
                        rightPort= Integer.parseInt(url.substring(url.indexOf(":")+1));
              new Controller(
                   new Gui("Balls @ " +serverPort),
                   new Server(serverPort),
                   leftPort > 0 ? new Client(leftHost, leftPort, LEFT) : null,
                   rightPort > 0 ? new Client(rightHost, rightPort, RIGHT) : null);
         private static void barf()
              System.err.println(USAGE);
              System.exit(-1);

  • How to  move items from one JList to other

    Can u pls help me out to implement this(I m using Netbeans 5.5):
    I want to move items from one JList to other thru a ADD button placed between JLists, I am able to add element on Right side JList but as soon as compiler encounter removeElementAt() it throws Array Index Out of Bound Exception
    and if I use
    removeElement() it removes all items from left side JList and returns value false.
    Pls have a look at this code:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
    Object selItem = jList1.getSelectedValue();
    int selIndex = jList1.getSelectedIndex();
    DefaultListModel model = new DefaultListModel();
    jList2.setModel(model);
    model.addElement(selItem);
    DefaultListModel modelr = new DefaultListModel();
    jList1.setModel(modelr);
    flag = modelr.removeElement(selItem);
    //modelr.removeElementAt(selIndex);
    System.out.println(flag);
    }

    hi Rodney_McKay,
    Thanks for valuable time but my problem is as it is, pls have a look what I have done and what more can b done in this direction.
    Here is the code:
    import javax.swing.DefaultListModel;
    import javax.swing.JList;
    public class twoList extends javax.swing.JFrame {
    /** Creates new form twoList */
    public twoList() {
    initComponents();
    //The code shown below is automatically generated and we can�t edit this code
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jList1 = new javax.swing.JList();
    jButton1 = new javax.swing.JButton();
    jScrollPane2 = new javax.swing.JScrollPane();
    jList2 = new javax.swing.JList();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jList1.setModel(new javax.swing.AbstractListModel() {
    String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
    public int getSize() { return strings.length; }
    public Object getElementAt(int i) { return strings[i]; }
    jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
    public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
    jList1ValueChanged(evt);
    jScrollPane1.setViewportView(jList1);
    jButton1.setText("ADD>>");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    jScrollPane2.setViewportView(jList2);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(31, 31, 31)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jButton1)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(78, Short.MAX_VALUE))
    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jScrollPane1, jScrollPane2});
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(62, 62, 62)
    .addComponent(jButton1))
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
    .addContainerGap(159, Short.MAX_VALUE))
    layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jScrollPane1, jScrollPane2});
    pack();
    }// </editor-fold>
    //automatic code ends here
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
            jList1 = new JList(new DefaultListModel());
            jList2 = new JList(new DefaultListModel());
             Object selItem = jList1.getSelectedValue();
             System.out.println(selItem);
            ((DefaultListModel) jList1.getModel()).removeElement(selItem);
            ((DefaultListModel) jList2.getModel()).addElement(selItem);
    //Now trying with this code it is neither adding or removing and the value �null� is coming in �selItem� .It may be bcoz JList and Jlist are already instantiated in automatic code. So, I tried this:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
             Object selItem = jList1.getSelectedValue();
             System.out.println(selItem);
            ((DefaultListModel) jList1.getModel()).removeElement(selItem);
            ((DefaultListModel) jList2.getModel()).addElement(selItem);
    //Now with this as soon as I click on �jButton1�, it is throwing this error:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: twoList$1 cannot be cast to javax.swing.DefaultListModel
            at twoList.jButton1ActionPerformed(twoList.java:105)
            at twoList.access$100(twoList.java:13)
            at twoList$3.actionPerformed(twoList.java:50)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6038)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
            at java.awt.Component.processEvent(Component.java:5803)
            at java.awt.Container.processEvent(Container.java:2058)
            at java.awt.Component.dispatchEventImpl(Component.java:4410)
            at java.awt.Container.dispatchEventImpl(Container.java:2116)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
            at java.awt.Container.dispatchEventImpl(Container.java:2102)
            at java.awt.Window.dispatchEventImpl(Window.java:2429)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

  • The book who I selected doesn't move to the right in CheckedListBox and the reason is that I can't make an return.his code is good just for first user who I selected

    Imprumut = loan
    I have 6 tables: 
    I have one combobox(from where I select utilizatori(users)) and 2 CheckedListBox(Between first box and second box I have 2 buttons:imprumuta(loan) and restituie(return))
    This c# code works just for first user: Utilizator, but something's not good. When I add new utilizator(user) and select it,  the loan will be add in my SQL DataBase, but... the book who I selected doesn't move to the right in CheckedListBox and the reason
    is that I can't make an return
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using MySql.Data.MySqlClient;
    namespace proiect
        public partial class Imprumut : Form
            MySqlConnection con = new MySqlConnection("DataSource=localhost;UserID=root;database=biblio1");
            //stabilim conexiunea
            MySqlCommand comUser;//interogarea pe baza careia umplem comboBox
            MySqlDataAdapter adaptu;
            DataTable userT = new DataTable();
            MySqlCommand cmdCarti;//interogarea pe baza careia umplem checkListBox
            MySqlDataAdapter adaptCarti;
            DataTable CartiTabel = new DataTable();
            MySqlCommand cmdCartiImprumutate;//interogarea pe baza careia umplem checkListBox
            MySqlDataAdapter adaptCartiImprumutate;
            DataTable CartiImprumutateTabel = new DataTable();
            public int UserId
                get
                    return Convert.ToInt32(user.SelectedValue.ToString());
            void Completez_Combo_User()
                try
                    comUser = new MySqlCommand("SELECT n.userid, CONCAT(n.UserName) as UserN FROM users n left join userroles us on n.userid=us.userid left join roles r on r.roleid=us.roleid WHERE r.roleid='3'",
    con);
                    adaptu = new MySqlDataAdapter(comUser);
                    adaptu.Fill(userT);
                    user.Items.Clear();
                    user.DataSource = userT;
                    //DataTable din care sunt preluate datele pentru ComboBox user
                    user.ValueMember = "UserID";
                    //Valoarea din coloana UserID nu se afiseaza in combobox
                    user.DisplayMember = "UserN";
                    //Eelementele afisate in combobox, preluate din concatenarea mai multor coloane
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
            void Completez_CheckList_Carti()
                try
                    cmdCarti = new MySqlCommand("SELECT BookID, CONCAT(title, ' ', ISBN,' ',author)as date_carte FROM books WHERE NumberLeft > 0 ORDER BY BookID", con);
                    adaptCarti = new MySqlDataAdapter(cmdCarti);
                    adaptCarti.Fill(CartiTabel);
                    imp.Items.Clear();
                    //carti.DataSource=null;
                    imp.DataSource = CartiTabel;
                    //DataTable din care sunt preluate datele pentru ComboBox carte
                    imp.ValueMember = "BookID";
                    //Valoarea din coloana BookID nu se afiseaza in combobox
                    imp.DisplayMember = "date_carte";
                    //Eelementele afisate in combobox, preluate din concatenarea mai multor coloane
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
                void Completez_CheckList_Cartires()
                    try
                        cmdCartiImprumutate = new MySqlCommand(string.Format("SELECT b.BookID, CONCAT(title, ' ', ISBN,' ',author) as date_carte FROM books b inner join userbooks ub on ub.bookid = b.bookid
    WHERE ub.userid = {0} ORDER BY BookID", UserId), con);
                        adaptCartiImprumutate = new MySqlDataAdapter(cmdCartiImprumutate);
                        adaptCartiImprumutate.Fill(CartiImprumutateTabel);
                        res.Items.Clear();
                        //carti.DataSource=null;
                        res.DataSource = CartiImprumutateTabel;
                        //DataTable din care sunt preluate datele pentru ComboBox carte
                        res.ValueMember = "BookID";
                        //Valoarea din coloana BookID nu se afiseaza in combobox
                        res.DisplayMember = "date_carte";
                        //Eelementele afisate in combobox, preluate din concatenarea mai multor coloane
                    catch (Exception ex)
                        MessageBox.Show(ex.Message);
            void Inregistrez_imprumut_in_BD()
                int useridu = Convert.ToInt32(user.SelectedValue.ToString()); //useridu = id book
                int bookidi;
                try
                    DateTime azi = System.DateTime.Now; //  Data imprumutului
                    DateTime atunci = termenul.Value;   //  Data restituirii
                    MySqlTransaction tranzactie = con.BeginTransaction();
                    MySqlCommand adaugImpr = new MySqlCommand("INSERT INTO bookshistory(UserID, BookID,BorrowDate) VALUES(@UserID, @BookID, CAST(@BorrowDate as datetime))", con);
                    MySqlCommand scadCarti = new MySqlCommand("UPDATE books SET numberleft=numberleft-1 WHERE bookid=@bookid", con);
                    MySqlCommand adauga_userbooks = new MySqlCommand("INSERT INTO userbooks(userId,bookID)VALUES(@userID,@bookID)", con);
                    adauga_userbooks.Transaction = tranzactie;
                    adaugImpr.Transaction = tranzactie;
                    scadCarti.Transaction = tranzactie;
                    try
                        foreach (int i in imp.CheckedIndices)
                            imp.SelectedIndex = i;
                            bookidi = Convert.ToInt32(imp.SelectedValue.ToString());
                            MessageBox.Show(bookidi.ToString());
                                     //bookidi va fi id-ul cartea bifata, pe rand din checklistBox
                                     //Inregistrez in tabela imprumut
                            adaugImpr.Parameters.AddWithValue("@UserID", useridu);
                            adaugImpr.Parameters.AddWithValue("@BookID", bookidi);
                            adaugImpr.Parameters.AddWithValue("@BorrowDate", azi);
                            adaugImpr.ExecuteNonQuery();
                            adaugImpr.Parameters.Clear();
                            adauga_userbooks.Parameters.AddWithValue("@userID", useridu);
                            adauga_userbooks.Parameters.AddWithValue("@bookID", bookidi);
                            adauga_userbooks.ExecuteNonQuery();
                            adauga_userbooks.Parameters.Clear();
                                    //Scad numarl de carti disponibile pentru cartea imprumutat
                            scadCarti.Parameters.AddWithValue("@bookid", bookidi);
                            scadCarti.ExecuteNonQuery();
                            scadCarti.Parameters.Clear();
                        tranzactie.Commit();
                    catch (Exception ex)
                        tranzactie.Rollback();
                        string message = ex.Message;
                        if (ex.Message.ToLower().Contains("duplicate entry"))
                            message = "Una dintre carti mai exista deja";
                        MessageBox.Show(message);
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
            void Inregistrez_restituire_in_BD()
                int useridu = Convert.ToInt32(user.SelectedValue.ToString()); //useridu = id book
                int bookidi;
                try
                    DateTime azi = System.DateTime.Now; //  Data imprumutului
                    DateTime atunci = termenul.Value;   //  Data restituirii
                    MySqlTransaction tranzactie = con.BeginTransaction();
                    MySqlCommand modificIstoric = new MySqlCommand("UPDATE bookshistory SET returndate = @returnDate WHERE userID = @userID AND bookID = @bookID", con);
                    MySqlCommand adaugCarti = new MySqlCommand("UPDATE books SET numberleft = numberleft + 1 WHERE bookID = @bookID", con);
                    MySqlCommand sterge_userbooks = new MySqlCommand("DELETE  FROM userbooks WHERE userID = @userID AND bookID = @bookID", con);
                    sterge_userbooks.Transaction = tranzactie;
                    modificIstoric.Transaction = tranzactie;
                    adaugCarti.Transaction = tranzactie;
                    try
                        foreach (int i in res.CheckedIndices)
                            res.SelectedIndex = i;
                            bookidi = Convert.ToInt32(res.SelectedValue.ToString());
                            MessageBox.Show(bookidi.ToString());
                            //bookidi va fi id-ul cartea bifata, pe rand din checklistBox
                            //Inregistrez in tabela imprumut
                            modificIstoric.Parameters.AddWithValue("@UserID", useridu);
                            modificIstoric.Parameters.AddWithValue("@BookID", bookidi);
                            modificIstoric.Parameters.AddWithValue("@returnDate", termenul.Value);
                            modificIstoric.ExecuteNonQuery();
                            modificIstoric.Parameters.Clear();
                            sterge_userbooks.Parameters.AddWithValue("@UserID", useridu);
                            sterge_userbooks.Parameters.AddWithValue("@BookID", bookidi);
                            sterge_userbooks.ExecuteNonQuery();
                            sterge_userbooks.Parameters.Clear();
                            //Scad numarl de carti disponibile pentru cartea imprumutat
                            //adaugCarti.Parameters.AddWithValue("@bookid", bookidi);
                            adaugCarti.Parameters.AddWithValue("@bookid", bookidi);
                            adaugCarti.ExecuteNonQuery();
                            adaugCarti.Parameters.Clear();
                        tranzactie.Commit();
                    catch (Exception ex)
                        tranzactie.Rollback();
                        MessageBox.Show(ex.Message);
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
            public Imprumut()
                InitializeComponent();
                try
                    con.Open();
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
                Completez_Combo_User();
                Completez_CheckList_Carti();
                Completez_CheckList_Cartires();
                //selecteaza_carti_utilizator();
                //  Initializez termenul din dateTimePicker la data de peste 15 zile fata de data sistemului
                termenul.Value = System.DateTime.Now.AddDays(15);
            private void imprumuta_Click(object sender, EventArgs e)
                Confirmare c = new Confirmare("Confirmati imprumutul?");
                DialogResult dr = c.ShowDialog();
                if (dr == DialogResult.Yes)
                    try
                        Inregistrez_imprumut_in_BD();
                        MessageBox.Show("Imprumutul a fost inregistrat");
                        //Dupa inregistrarea imprumutului o parte din carti nu mai sunt disponibile pentru imprumut
                        //Reincarc in CheckList cu Carti noua lista cu carti ramase dupa imprumut
                        //Pentru asta "resetez" datele din dataTable cartiT (sursa pentru carti.DataSource)
                        CartiTabel.Clear();
                        adaptCarti.Fill(CartiTabel);
                        CartiImprumutateTabel.Clear();
                        adaptCartiImprumutate.Fill(CartiImprumutateTabel);
                    catch (Exception ex)
                        MessageBox.Show(ex.Message);
                if (dr == DialogResult.No)
                    MessageBox.Show("Imprumutul NU a fost inregistrat");
                    imp.ClearSelected();
                    //deselecteaza cartea selectat
                    foreach (int i in imp.CheckedIndices)
                        imp.SetItemChecked(i, false);
                    //debifeaza cartile bifate
                //if (imp.CheckedItems.Count > 0)
                //    //res.Items.Clear();
                //    foreach (string str in imp.CheckedItems)
                //        res.Items.Add(str);//adauga in partea cealalta, imprumuta
                //    while (imp.CheckedItems.Count > 0)
                //        imp.Items.Remove(imp.CheckedItems[0]);
            private void restituie_Click(object sender, EventArgs e)
                Confirmare r = new Confirmare("Confirmati restituirea?");
                DialogResult dr = r.ShowDialog();
                if (dr == DialogResult.Yes)
                    try
                        Inregistrez_restituire_in_BD();
                        MessageBox.Show("Restituirea a fost inregistrata");
                        //Dupa inregistrarea imprumutului o parte din carti nu mai sunt disponibile pentru imprumut
                        //Reincarc in CheckList cu Carti noua lista cu carti ramase dupa imprumut
                        //Pentru asta "resetez" datele din dataTable cartiT (sursa pentru carti.DataSource)
                        CartiTabel.Clear();
                        adaptCarti.Fill(CartiTabel);
                        CartiImprumutateTabel.Clear();
                        adaptCartiImprumutate.Fill(CartiImprumutateTabel);
                    catch (Exception ex)
                        MessageBox.Show(ex.Message);
                if (dr == DialogResult.No)
                    MessageBox.Show("Restituirea NU a fost inregistrata");
                    res.ClearSelected();
                    //deselecteaza cartea selectat
                    foreach (int i in imp.CheckedIndices)
                        res.SetItemChecked(i, false);
                    //debifeaza cartile bifate
                if (res.CheckedItems.Count > 0)
                    foreach (string str in res.CheckedItems)
                        imp.Items.Add(str);
                    while (res.CheckedItems.Count > 0)
                        res.Items.Remove(res.CheckedItems[0]);
            private void button2_Click(object sender, EventArgs e)
                con.Close();
                this.Close();
            //private void selecteaza_carti_utilizator()
            //    res.Items.Clear();
            //    MySqlCommand selectcart = new MySqlCommand("select title from books,userbooks where userbooks.userid='" + user.SelectedValue.ToString() + "' and userbooks.bookid=books.bookid", con);
            //    MySqlDataReader reader = selectcart.ExecuteReader();
            //    try
            //        while(reader.Read())
            //            res.Items.Add(reader["title"]);
            //    catch(Exception ex)
            //        MessageBox.Show(ex.Message);
            //    finally
            //        reader.Close();

    Hello Vincenzzo,
    This issue seems to be a window form UI implemented related issue, for this i suggest that you could ask it to the windows form forum:
    http://social.msdn.microsoft.com/Forums/windows/en-US/home?forum=winforms
    The current forum you posted to is used to discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Cursor style doesn't work on web forms

    Hi All, I have a FORM (6i) from which I run the report by clicking a button . I used to set_application_property to set cursor style to BUSY untill I get report output . It works in client/server but doesn't work in Web . Can I set this in any other

  • Import oracle apps dump into oracle database

    Dears, Is it possible to import the dump taken form oracle apps to oracle 11g. If it is possible could anybody list down the steps. Thanks Janani.C

  • Audio files condensing in .oam publishing for use in Wordpress?

    Is the new media folder that contains the audio files in Edge condensed when you publish as an .oam? When I add the .oam to my Wordpress using the Edge Suite plugin the audio does not work.

  • Help: Loading custom JCShell plugin

    Hi, when I try to register a custom JCShell plugin. I get the following error: cm>  /applet Nickname   AID                              Plugin cm         A000000003000000                 com.ibm.jc.tools.CardManagerPlugin eclipse    00000000         

  • JSP taglib prefix issue

    Placing the prefix before the URI as shown below works when deploying to Tomcat <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> but does not work for OC4J. For OC4J , placing the prefix after URI works , but will not work unde