Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 5:18 pm

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Sun May 16, 2010 4:26 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Okay I've continued at this for hours, I can't get it to find the button! My project is due tomorrow and I only have a few hours left to get it finished and I haven't even scratched the surface of the UI part. Any ways, here is the code:

Code:
<textures file="countries.png" format="RGBA">
        <texture name="-countries.background.highlight" x="0" y="0" width="68" height="36"/>
    </textures>

    <textures file="countries.png" format="RGBA">
        <select name="countries.background">
            <alias ref="-countries.background.highlight" if="armed ^ selected"/>
            <texture x="0" y="0" width="68" height="36"/>
        </select>
    </textures>


For the theme file.

Code:
package com.adrian.spanish;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import de.matthiasmann.twl.GUI;
import de.matthiasmann.twl.Widget;
import de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer;
import de.matthiasmann.twl.theme.ThemeManager;
import de.matthiasmann.twl.ToggleButton;


public class MatchingStateOne extends BasicGameState{

   public ToggleButton country = new ToggleButton();
   public MatchingStateOne(int stateID) {
      this.stateID = stateID;
   }

   @Override
   public int getID() {
      // TODO Auto-generated method stub
      return stateID;
   }
   public void loadStuff() throws IOException {
      country.setTheme("countries.background");
   }
   public void init(GameContainer container, StateBasedGame game)
   throws SlickException {
      try {
         loadStuff();
      } catch (IOException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
      }
      // construct & configure root widget
      root = new Widget();
      root.setTheme("");
      root.add(country);
      // save Slick's GL state while loading the theme
      GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
      try {
         lwjglRenderer = new LWJGLRenderer();
         //theme = ThemeManager.createThemeManager(Thread.currentThread().getContextClassLoader()
         //              .getResource("./gui/simple.xml"), lwjglRenderer);
         File file = new File("theme/simple.xml");
         theme = ThemeManager.createThemeManager(file.toURL(),lwjglRenderer);
         gui = new GUI(root, lwjglRenderer);
         gui.applyTheme(theme);
         gui.setBackground(theme.getImageNoWarning("image"));
         
   
      } catch (LWJGLException e) {
         e.printStackTrace();
      } catch(IOException e){
         e.printStackTrace();
      } finally {
         // restore Slick's GL state
         GL11.glPopAttrib();
      }

      // connect input
      twlInputAdapter = new TWLInputAdapter(gui, container.getInput());
      container.getInput().addPrimaryListener(twlInputAdapter);

   }

   public void render(GameContainer container, StateBasedGame game, Graphics g)
   throws SlickException {
      twlInputAdapter.render();

   }

   public void update(GameContainer container, StateBasedGame game, int delta)
   throws SlickException {
      twlInputAdapter.update();

   }

   public Rectangle newRect(float x, float y, float width, float height) {
      return new Rectangle(x, y, width, height);
   }

   public void addToMap() {
      for(int i = 0; i < countries.length; i++) {
         map.put(countries[i], capitals[i]);
      }
   }

   /*instance variables*/
   private Map<String, String> map = new HashMap<String, String>();
   private String[] countries = {"Spain", "Equatorial","Mexico",
         "Guatemala","Honduras","El Salvador","Nicaragua","Costa Rica",
         "Panama", "Cuba", "Dominican Republic",
         "Puerto Rico", "Venezuela", "Colombia", "Ecuador",
         "Peru", "Paraguay", "Chile", "Argentina", "Uruguay"};
   private String[] capitals = {"Madrid", "Malabo", "Mexico City",
         "Guatemala City", "Tegucigalpa",
         "San Salvador", "Managua", "San José",
         "Panama City", "Havana", "Santo Domingo",
         "San Juan", "Caracas", "Bogotá", "Quito",
         "Lima", "Asunción", "Santiago", "Buenos Aires", "Montevideo"};


   /*Instance variables*/
   private int stateID;
   /* Max of 20 buttons or add more to the arrays */
   private LWJGLRenderer lwjglRenderer;
   private ThemeManager theme;
   private GUI gui;
   private Widget root = new Widget();
   private TWLInputAdapter twlInputAdapter;

}


I'm extremely new to TWL and by what I've read, the select tag (more specific the name part of it) is what the method searches for (countries.background) and for some reason it gives me this:

Code:
Could not find theme: countries.background
java.lang.IllegalArgumentException: child widget already in tree
   at de.matthiasmann.twl.Widget.insertChild(Widget.java:1088)
   at de.matthiasmann.twl.Widget.add(Widget.java:1066)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:65)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:164)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)


Also, there is nothing wrong with the loading of the xml file because the TWL background loads fine referencing to a select tag.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 5:02 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1189
Ok, I find it very difficult to help you as you only posted parts of files without any line number reference.

For the theme file part you posted - it does not contain any theme elements, only textures.

Why do you create the root Widget several times?

Could it be that init() is called more then once? this could explain the "java.lang.IllegalArgumentException: child widget already in tree" exception as the ToggleButton 'country' is created only once.
And a dot in the theme name (in your loadStuff method) is invalid.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 5:10 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Here is the whole theme file, its just based upon the simple.xml one.


http://lwjgl.pastebin.com/mNVZEfq2


Also, I believe the init method is only called once. Thanks for your reply.


Edit: Removed the dot, and renamed it to find just "countries." But it still cannot find it. I'll continue analyzing the code because I'm relatively new to xml.

Edit: Added new link, should be fine now.


Last edited by Zombiedevice on Sun May 16, 2010 5:19 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 5:17 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1189
You only added textures/images - Widget reference theme elements in the xml.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 5:28 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Ok I'll edit it than.


Well, after editing it I now get this:

Code:
java.io.IOException: while parsing Theme XML: file:/F:/workspace/Spanish/theme/simple.xml
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:228)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:146)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:130)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:58)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)
Caused by: org.xmlpull.v1.XmlPullParserException: missing 'name' on 'textures' (position: START_TAG seen ...-defaults">\r\n        <textures file="countries.png" format="RGBA">... @868:54)
   at de.matthiasmann.twl.utils.XMLParser.missingAttribute(XMLParser.java:307)
   at de.matthiasmann.twl.utils.XMLParser.getAttributeNotNull(XMLParser.java:197)
   at de.matthiasmann.twl.theme.ThemeManager.parseTheme(ThemeManager.java:401)
   at de.matthiasmann.twl.theme.ThemeManager.parseTheme(ThemeManager.java:409)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:251)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:223)
   ... 8 more
java.lang.NullPointerException: gui
   at com.adrian.spanish.TWLInputAdapter.<init>(TWLInputAdapter.java:55)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:74)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)

Code:

        <theme name="country" ref="-defaults">
        <textures file="countries.png" format="RGBA">
        <texture name="-countries.background.highlight" x="0" y="0" width="68" height="36"/>
    </textures>

    <textures file="countries.png" format="RGBA">
        <select name="countries">
            <alias ref="-countries.background.highlight" if="armed ^ selected"/>
            <texture x="0" y="0" width="68" height="36"/>
        </select>
       
    </textures>
     </theme>


And if I put a name tag on textures I get this:

Code:

java.io.IOException: while parsing Theme XML: file:/F:/workspace/Spanish/theme/simple.xml
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:228)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:146)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:130)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:58)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)
Caused by: org.xmlpull.v1.XmlPullParserException: Unexpected 'textures' (position: START_TAG seen ...\n        <textures name="jeff" file="countries.png" format="RGBA">... @868:66)
   at de.matthiasmann.twl.utils.XMLParser.unexpected(XMLParser.java:271)
   at de.matthiasmann.twl.theme.ThemeManager.parseTheme(ThemeManager.java:413)
   at de.matthiasmann.twl.theme.ThemeManager.parseTheme(ThemeManager.java:409)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:251)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:223)
   ... 8 more
java.lang.NullPointerException: gui
   at com.adrian.spanish.TWLInputAdapter.<init>(TWLInputAdapter.java:55)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:74)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)


Most of the time I can fix errors on my own, but not if they come from another programming language.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 6:24 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Still getting the same error, I've never been this frustrated with any thing in my life! I've been working on how to add a button for 6 HOURS.

These errors don't make any since, it says I'm missing a name on textures, than I add a name and than it says unexpected textures. Grr.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 7:11 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
If someone could please help that would be great, EXTREMELY short on time.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 7:15 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Now, I'm getting this...


Code:
java.io.IOException: while parsing Theme XML: file:/F:/workspace/Spanish/theme/simple.xml
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:228)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:146)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:130)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:58)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)
Caused by: org.xmlpull.v1.XmlPullParserException: Unable to load texture: countries.png (position: START_TAG seen ...hbutton.background.highlight" x="0" y="0" width="38" height="60"/>... @13:91) caused by: java.lang.IllegalArgumentException: height
   at de.matthiasmann.twl.utils.XMLParser.error(XMLParser.java:267)
   at de.matthiasmann.twl.theme.ImageManager.parseTextures(ImageManager.java:147)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:240)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:223)
   ... 8 more
Caused by: java.lang.IllegalArgumentException: height
   at de.matthiasmann.twl.renderer.lwjgl.LWJGLTexture.getImage(LWJGLTexture.java:209)
   at de.matthiasmann.twl.theme.ImageManager.createImage(ImageManager.java:572)
   at de.matthiasmann.twl.theme.ImageManager.parseTexture(ImageManager.java:295)
   at de.matthiasmann.twl.theme.ImageManager.parseImageDelegate(ImageManager.java:217)
   at de.matthiasmann.twl.theme.ImageManager.parseImageNoCond(ImageManager.java:192)
   at de.matthiasmann.twl.theme.ImageManager.parseImage(ImageManager.java:179)
   at de.matthiasmann.twl.theme.ImageManager.parseTextures(ImageManager.java:136)
   ... 10 more
java.lang.NullPointerException: gui
   at com.adrian.spanish.TWLInputAdapter.<init>(TWLInputAdapter.java:55)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:74)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)



Here is my xml file:

http://lwjgl.pastebin.com/tvha2C0n


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 7:20 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Nvm, back to the old drawing board.


Still getting this:

Code:
java.io.IOException: while parsing Theme XML: file:/F:/workspace/Spanish/theme/simple.xml
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:228)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:146)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:130)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:58)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)
Caused by: org.xmlpull.v1.XmlPullParserException: missing 'name' on 'textures' (position: START_TAG seen ...>\r\n        \r\n        <textures file="countries.png" format="RGBA">... @966:54)
   at de.matthiasmann.twl.utils.XMLParser.missingAttribute(XMLParser.java:307)
   at de.matthiasmann.twl.utils.XMLParser.getAttributeNotNull(XMLParser.java:197)
   at de.matthiasmann.twl.theme.ThemeManager.parseTheme(ThemeManager.java:401)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:251)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:223)
   ... 8 more
java.lang.NullPointerException: gui
   at com.adrian.spanish.TWLInputAdapter.<init>(TWLInputAdapter.java:55)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:74)
   at com.adrian.spanish.SpanishGameMain.initStatesList(SpanishGameMain.java:31)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:157)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 7:28 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1189
Ok, <textures> is a top level element - you can't put it inside another <textures>. Check the TWL Theme File Format spec.

And again - you need a <theme name="countries" ref="ToggleButton"/> somewhere if you want to use setTheme("countries") in your code.

Take a look at the simple examples - like GameUIDemo or ChatDemo

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 7:47 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
But I don't have a ToggleButton theme and no clue how to make one. So it just gives me yet another exception. My project is due tomorrow and I can't even get a button to work, fml. I might have to just do it the hard way because it doesn't look like I'll be able to do it with this library in like 20 minutes because thats all I have left to work on it.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2010 8:47 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
The easiest way to get started I've found is to take a current working theme and modify it.

The simple.xml works good if you need standard windows/widgets.
The gamegui.xml (in the examples) is good if you want a couple buttons.

In regards to init, it does gets called more than once; specially in state based game ( at least once when you load it and at least once when you enter it ). I had that problem with your project. A quick way around not adding TWL root more than once is just something like this:

if (root != null) { return; }

Quote:
But I don't have a ToggleButton theme and no clue how to make one. So it just gives me yet another exception


Check the simple.xml or gamegui.xml. It will show up as something like:

<theme="togglebutton"


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2010 5:26 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Oh wow, Matthias that is why I was so confused. I had already understood the theme file structure, but the child already in the tree thing really confused me.

I thought init was being called more than once, thanks for the fix :).


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2010 6:32 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
I'm still having trouble with this, but I've fixed a lot of the things that you've told me Matthias and I'm still getting this:

Here is the class:

Code:
package com.adrian.spanish;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import de.matthiasmann.twl.GUI;
import de.matthiasmann.twl.Widget;
import de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer;
import de.matthiasmann.twl.theme.ThemeManager;
import de.matthiasmann.twl.ToggleButton;


public class MatchingStateOne extends BasicGameState{

   public ToggleButton country = new ToggleButton();
   public MatchingStateOne(int stateID) {
      this.stateID = stateID;
   }

   @Override
   public int getID() {
      // TODO Auto-generated method stub
      return stateID;
   }
   public void loadStuff() throws IOException {
      country.setTheme("countries");
   }
   public void init(GameContainer container, StateBasedGame game)
   throws SlickException {

      // construct & configure root widget
      if (root == null) { //make sure the widget hasn't already been created
         root = new Widget();
         root.setTheme("");
         root.add(country);
         return; }
      // save Slick's GL state while loading the theme
      GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
      try {
         lwjglRenderer = new LWJGLRenderer();
         //theme = ThemeManager.createThemeManager(Thread.currentThread().getContextClassLoader()
         //              .getResource("./gui/simple.xml"), lwjglRenderer);
         File file = new File("theme/guiTheme.xml");
         theme = ThemeManager.createThemeManager(file.toURL(),lwjglRenderer);
         gui = new GUI(root, lwjglRenderer);
         gui.applyTheme(theme);
         gui.setBackground(theme.getImageNoWarning("image"));


      } catch (LWJGLException e) {
         e.printStackTrace();
      } catch(IOException e){
         e.printStackTrace();
      } finally {
         // restore Slick's GL state
         GL11.glPopAttrib();
      }
      try {
         loadStuff();
      } catch (IOException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
      }
      // connect input
      twlInputAdapter = new TWLInputAdapter(gui, container.getInput());
      container.getInput().addPrimaryListener(twlInputAdapter);

   }

   public void render(GameContainer container, StateBasedGame game, Graphics g)
   throws SlickException {
      twlInputAdapter.render();

   }

   public void update(GameContainer container, StateBasedGame game, int delta)
   throws SlickException {
      twlInputAdapter.update();

   }

   public Rectangle newRect(float x, float y, float width, float height) {
      return new Rectangle(x, y, width, height);
   }

   public void addToMap() {
      for(int i = 0; i < countries.length; i++) {
         map.put(countries[i], capitals[i]);
      }
   }

   /*instance variables*/
   private Map<String, String> map = new HashMap<String, String>();
   private String[] countries = {"Spain", "Equatorial","Mexico",
         "Guatemala","Honduras","El Salvador","Nicaragua","Costa Rica",
         "Panama", "Cuba", "Dominican Republic",
         "Puerto Rico", "Venezuela", "Colombia", "Ecuador",
         "Peru", "Paraguay", "Chile", "Argentina", "Uruguay"};
   private String[] capitals = {"Madrid", "Malabo", "Mexico City",
         "Guatemala City", "Tegucigalpa",
         "San Salvador", "Managua", "San José",
         "Panama City", "Havana", "Santo Domingo",
         "San Juan", "Caracas", "Bogotá", "Quito",
         "Lima", "Asunción", "Santiago", "Buenos Aires", "Montevideo"};


   /*Instance variables*/
   private int stateID;
   /* Max of 20 buttons or add more to the arrays */
   private LWJGLRenderer lwjglRenderer;
   private ThemeManager theme;
   private GUI gui;
   private Widget root = new Widget();
   private TWLInputAdapter twlInputAdapter;

}


Here is the error:

Code:
Could not find theme: widget
java.lang.IllegalArgumentException: child widget already in tree
   at de.matthiasmann.twl.Widget.insertChild(Widget.java:1088)
   at de.matthiasmann.twl.GUI.<init>(GUI.java:156)
   at com.adrian.spanish.MatchingStateOne.init(MatchingStateOne.java:56)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:164)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:42)


And here is the xml file I'm using:
http://lwjgl.pastebin.com/AWnqPzVE


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2010 6:39 pm 
Offline

Joined: Wed Mar 31, 2010 6:22 pm
Posts: 55
Wait I have it now! I accidently initiated the widget object in the instance variable declaration as well. DUH!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group