Wednesday, 29 May 2013

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: 



No comments:

Post a Comment