Wednesday, 29 May 2013

UH OH (big one)

I asked Ryk about the JLayeredPanes about the movement of monopoly. And he wasn't sure, so he called Justin over. Justin looked through every inch of the code, and couldn't find anything wrong. It still looks like this: 


Tell me, Harry, what exactly is the function of a rubber duck continued.


This is what I have in my program when I create the JLabel. And nowhere, do I say that I am putting it in the centre. 
      
 Object[] possibleValues = { "Dragooon, The Great", "Aslan", "Bilbo", "Luna Lovegood" , "Sherlock Holmes"};
       Object selectedValue = JOptionPane.showInputDialog(frame, "What character would you like to be? ", "Character", JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
       
       if (selectedValue.equals("Dragooon, The Great"))
       { 
          characterUser = new JLabel(new ImageIcon("C"+1+".png"));
          if (tracing) System.out.println("Dragoon the Great: " + characterUser);
       } //end of if statement
       
       else if (selectedValue.equals("Aslan"))
       {
           characterUser = new JLabel(new ImageIcon("C"+2+".png"));
           if (tracing) System.out.println("Aslan: " + characterUser);
       } //end of else if statement
       
       else if (selectedValue.equals("Bilbo"))
       { 
           characterUser = new JLabel(new ImageIcon("C"+3+".png"));
           if (tracing) System.out.println("Bilbo: " + characterUser);
       } //end of if statement
       
       else if (selectedValue.equals("Luna Lovegood"))
       {
            characterUser = new JLabel(new ImageIcon("C"+4+".png"));
            if (tracing) System.out.println("Luna Lovegood: " + characterUser);
       } //end of else if statement
       
       else if (selectedValue.equals("Sherlock Holmes"))
       {
            characterUser = new JLabel(new ImageIcon("C"+5+".png"));
            if (tracing) System.out.println("Sherlock Holmes: " + characterUser);
       } //end of if statement

So in the method that I add the picture to the frame (it is also in the last post), this is what pops up instead: 



Tell me, Harry, what exactly is the function of a rubber duck?

Siriusly! I'm getting distracted by that :) 

Anyways, I tried to add the pawns to my board, but it added *IN THE MIDDLE* instead of on the board! I even changed the coordinates from (2, 48) to (100, 100) and it didn't change a thing! I'm even adding it in the NORTH panel and it still shows up in the middle! DARRNIT! Something's gone entirely wrong o-O 

SHEEESH! I set these locations: 1458 , 575 and IT STILL DISPLAYS IN THE MIDDLE! 

I don't want to bother Ryk about it, but this is getting so freaken annoying! 

I even have this as tracing: 


if (tracing) 
        {
            System.out.println("Character in location before adding: " + characterUser.getLocation());
            System.out.println("Character in layer before adding: " +north.getLayer(characterUser));
            System.out.println("Character in index before adding: " +north.getIndexOf(characterUser));
            System.out.println("Character's position before adding: " +characterUser.getLocation());
        } //end of if statement

And this is what outputs (which is also correct!) 


Character in location creating pane: java.awt.Point[x=0,y=0]
Character in location before adding: java.awt.Point[x=1458,y=575]
Character in layer before adding: 3
Character in index before adding: -1
Character's position before adding: java.awt.Point[x=1458,y=575]
Character in location after adding: java.awt.Point[x=1458,y=575]
BUILD SUCCESSFUL (total time: 7 seconds)

Originally, I set the position to (0, 0). And then I set it to 1458, 575; and all the other ones are correct, but it still show up in the middle. 

This is so irritating! It really shouldn't be that freaken hard! UGHHHH! 

I wonder if it has something to do with the coordinates of the JLabel rather than the pane because when i use mouseClicked, it gives the coordinates on the JLabel rather than the pane in general. BUT THAT DOESN'T EXPLAIN WHY THE BLOODY HELL IT IS IN THE MIDDLE! 

EEEEEEEEEEEEEEK! I'm taking a break from CS right now >_< It's not making any sense. And I can't do anything about the program when I'm freaking out about it. So, whatevers! Be back in an hour -_- 

Hello, again.


Hi...

So I'm going back to trying to program the pawns again. I don't really know how to set the location (although I tried to use setBounds..and the icon didn't even show up). 

Eeeeeeeeeeeeeeeeeeeeeeeeeek. Time to look at the Java API's again :) 

 Oiiikay! This is super weird: 

I've set the user's character at position (2, 48) which is the (hopefully is) the coordinate of the startAdventure square. Only program is, that it isn't showing up. It might be because of the JLayeredPane? This is going to be a loooooooong day...