Creating main menu without swing?

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 1095 Views - Last Post: 27 July 2011 - 05:46 PM Rate Topic: -----

#1 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 11

Creating main menu without swing?

Posted 26 July 2011 - 03:29 PM

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
Is This A Good Question/Topic? 0
  • +

Replies To: Creating main menu without swing?

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9029
  • View blog
  • Posts: 33,497
  • Joined: 27-December 08

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.
Was This Post Helpful? 1
  • +
  • -

#3 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 11

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?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9029
  • View blog
  • Posts: 33,497
  • Joined: 27-December 08

Re: Creating main menu without swing?

Posted 26 July 2011 - 04:53 PM

Link: http://slick.javaunl...4edd310aa989367
Was This Post Helpful? 0
  • +
  • -

#5 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 11

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 ?
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9029
  • View blog
  • Posts: 33,497
  • Joined: 27-December 08

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.
Was This Post Helpful? 0
  • +
  • -

#7 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 11

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?
Was This Post Helpful? 0
  • +
  • -

#8 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9029
  • View blog
  • Posts: 33,497
  • Joined: 27-December 08

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.
Was This Post Helpful? 0
  • +
  • -

#9 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 11

Re: Creating main menu without swing?

Posted 26 July 2011 - 05:22 PM

Alright thanks for the advice.
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8020
  • View blog
  • Posts: 31,127
  • Joined: 06-March 08

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 ?
Was This Post Helpful? 0
  • +
  • -

#11 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 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:
    	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;


View Postpbl, 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

Was This Post Helpful? 0
  • +
  • -

#12 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8020
  • View blog
  • Posts: 31,127
  • Joined: 06-March 08

Re: Creating main menu without swing?

Posted 26 July 2011 - 05:38 PM

Obviously your newGame button is not initialized
And why static ???
Was This Post Helpful? 1
  • +
  • -

#13 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 11

Re: Creating main menu without swing?

Posted 26 July 2011 - 06:22 PM

View Postpbl, on 27 July 2011 - 12:38 AM, said:

Obviously your newGame button is not initialized
And why static ???


When i first wrote it i got error it saying i can fix it by changin to static.
Was This Post Helpful? 0
  • +
  • -

#14 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9029
  • View blog
  • Posts: 33,497
  • Joined: 27-December 08

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.
Was This Post Helpful? 1
  • +
  • -

#15 TheCompBoy  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 21-April 11

Re: Creating main menu without swing?

Posted 27 July 2011 - 01:15 PM

Alright thanks, I will remember this..
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2