Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Strings in switch are not supported in source 1.5...

Threaded View

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Strings in switch are not supported in source 1.5...

    I am creating a checkers game and im trying to paint the board but it says the switch is using a string, but its actually not. Here is the code

    public void paintComponent(Graphics g) {


    for (int row = 0; row < 8; row++) {
    for (int col = 0; col < 8; col++) {
    if ( row % 2 == col % 2 )
    g.setColor(Color.LIGHT_GRAY);
    else
    g.setColor(Color.GRAY);
    g.fillRect(2 + col*20, 2 + row*20, 20, 20);
    switch (board.pieceAt(row,col)) {
    case CheckersData.RED:
    g.setColor(Color.RED);
    g.fillOval(4 + col*20, 4 + row*20, 15, 15);
    break;
    }
    }

    And this is the method it calls

    int pieceAt(int row, int col) {
    return board[row][col];
    }

    Any help would be much appreciated.
    Last edited by glennder; February 2nd, 2012 at 12:52 PM.


Similar Threads

  1. IF and SWITCH Statements: How and When to Use Them
    By snowguy13 in forum Java Programming Tutorials
    Replies: 2
    Last Post: January 11th, 2012, 10:46 AM
  2. Java Security Implementation for Plugin Supported Architecture
    By bgroenks96 in forum Java Theory & Questions
    Replies: 19
    Last Post: November 22nd, 2011, 04:13 PM
  3. IllegalArgumentException: Pan not supported
    By rtumatt in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: June 13th, 2010, 01:00 PM
  4. Switch Statment
    By 3XiLED in forum Java Theory & Questions
    Replies: 2
    Last Post: March 31st, 2010, 05:11 PM
  5. Jsp source not found
    By jadeite100 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 15th, 2010, 01:00 AM