Slick Forums
http://slick.ninjacave.com/forum/

Weird ByteBuffer Error through TextureLoader...
http://slick.ninjacave.com/forum/viewtopic.php?f=1&t=5510
Page 1 of 1

Author:  Squeakbox [ Wed Sep 12, 2012 1:15 pm ]
Post subject:  Weird ByteBuffer Error through TextureLoader...

I made a custom-made text box for inputs, which works like entering text into a forum field. I can backspace, delete, type, etc... However, there's an issue when I call .setText(String) of my custom-made text field, and try to "delete" any of the letters already there. For the one field, I put "username" for obvious reasons.

If I type in a letter before erasing, it works fine, but if I erase what characters "exist", or rather, the ones that aren't empty spaces, then it crashes.

Anywho, down the line, this code gives me the following error from my LetterList class:

letterTex = TextureLoader.getTexture("PNG",letterFile,true);
(letterTex is a Texture object)
[exception]
-----------------------------------------------------------------------------------------------------
Exception in thread "main" java.lang.IllegalArgumentException: Buffer size <= 0
at java.io.BufferedInputStream.<init>(BufferedInputStream.java:193)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:53)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:277)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:231)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:184)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:64)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:37)
at LetterList.letterSearch(LetterList.java:285)
at GameInputBox.drawTypedWord(GameInputBox.java:472)
at GameInputBox.draw(GameInputBox.java:226)
at IntroWindow.<init>(IntroWindow.java:221)
at MainControl.setMainState(MainControl.java:40)
at ConnectionTester.<init>(ConnectionTester.java:107)
at MainControl.setMainState(MainControl.java:31)
at MainControl.<init>(MainControl.java:13)
at MainControl.main(MainControl.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
-----------------------------------------------------------------------------------------------------
[/exception]
I've been digging and digging, and nothing seems off about my code. So I don't get it.

Here's the setText(String) method if it helps any:
-----------------------------------------------------------------------------------------------------
Code:
public void setText(String text) {
        if (text.length() > maxLetters) {
            try {
                throw new TextLengthException(maxLetters);
            } catch (TextLengthException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                System.exit(-1);
            }   // try - catch TextLengthException
        } else if (text.length() < maxLetters) {
            // save entry size
            entryLength = text.length();

            // create extra letters
            addExtras = new char[maxLetters-text.length()-1];
            // append letters to text
            for (int i = 0; i < addExtras.length; ++i) {
                addExtras[i] = 'ΒΆ';
            }   // for loop

            // add to text
            text = text + String.valueOf(addExtras);
        }   // else - if
        else
            entryLength = text.length();

        // finally save to array
        saveEntry = text.toCharArray();
        storeText();    // stores the created text to showText for visual display
    }   // setText(String)

-----------------------------------------------------------------------------------------------------

The byte buffer size returns to 0 after the first letters are created, but when I delete a letter without typing one first, for some reason, the byte buffer at 0 returns an exception.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/