Hello guys
I now whant to make a main menu for my game..
Problem is that the library i'm using is not working too well with swing..
So.. instead of swing what should i use?
Library is called : Slick 2D
22 Replies - 1095 Views - Last Post: 27 July 2011 - 05:46 PM
Replies To: Creating main menu without swing?
#2
Re: Creating main menu without swing?
Posted 26 July 2011 - 04:48 PM
You're going to have to be more specific. Not working how?
Also, from looking at Slick2D's forums, you can use CanvasGameContainer to hold your Swing elements.
Also, from looking at Slick2D's forums, you can use CanvasGameContainer to hold your Swing elements.
#3
Re: Creating main menu without swing?
Posted 26 July 2011 - 04:53 PM
Oh... I will look into it, Also can you link me to that thread?
#4
Re: Creating main menu without swing?
Posted 26 July 2011 - 04:53 PM
#5
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:02 PM
But if you check the class AppGameContainer here : http://slick.cokeandcode.com/javadoc/
Is there no way i can just add a button to that ?
Is there no way i can just add a button to that ?
#6
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:09 PM
I'm honestly not familiar with that library at all. We don't have the best support with all the third party APIs, so I'm not sure how to advise you with your Slick2D.
#7
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:17 PM
Hmm Alright.. But it my situiatoin what would you do? Any advice or tips?
#8
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:20 PM
I probably would have started with Swing to begin with, or found a library that I could evaluate would suit my needs. And if it didn't work, then I would change libraries. Since I separate my GUI from my program state/data, I would be able to salvage a lot of code and just have to deal with redoing some of the UI components.
#9
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:22 PM
Alright thanks for the advice.
#10
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:23 PM
Which features of Slick2D do you use that are not available within Swing ?
#11
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:34 PM
I tried adding a swing JFrame to my application here is the error:
Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
at galactic.adventures.Galacticadventures.main(Galacticadventures.java:54)
Here is the code:
And here is the variables that i create with the class:
Am sorry but i realy do not know thats just the answear i got on their forum when i asked..
Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
at galactic.adventures.Galacticadventures.main(Galacticadventures.java:54)
Here is the code:
JFrame frame = new JFrame("Galactic Adventures");
frame.setSize(800, 800);
Container content = frame.getContentPane();
content.setLayout(new FlowLayout());
content.add(newGame);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
And here is the variables that i create with the class:
JFrame frame; static JButton newGame;
pbl, on 27 July 2011 - 12:23 AM, said:
Which features of Slick2D do you use that are not available within Swing ?
Am sorry but i realy do not know thats just the answear i got on their forum when i asked..
This post has been edited by TheCompBoy: 26 July 2011 - 05:35 PM
#12
Re: Creating main menu without swing?
Posted 26 July 2011 - 05:38 PM
Obviously your newGame button is not initialized
And why static ???
And why static ???
#13
Re: Creating main menu without swing?
Posted 26 July 2011 - 06:22 PM
#14
Re: Creating main menu without swing?
Posted 26 July 2011 - 06:24 PM
I'm betting the error was something like "non-static variable cannot be referenced from static context." When working with OOP, don't make something static unless you understand why it should be static. Chances are, if a static element is accessing a non-static element, making the non-static element static is the quick and dirty fix.
#15
Re: Creating main menu without swing?
Posted 27 July 2011 - 01:15 PM
Alright thanks, I will remember this..
|
|

New Topic/Question
Reply



MultiQuote







|