Results 1 to 10 of 10
- 07-06-2011, 06:09 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
GUI frustrations - using Eclipse and now Windows Builder
Ok, so I have read a book on Java programming and gone through many tutorials on the language through websites and youtube. Now I just want to make a simple game to get started, no serious graphics or anything.
I have been at it for days and am about to give up on Java. The GUI is impossible to program. Examples from websites don't seem to even work. For example just trying to get a jpg to show on a jpanel. I got this code snipet:
ImageIcon image = new ImageIcon("image.jpeg");
jpanel.add(image, BorderLayout.North);
but the add method does not work, some error about image not being a component.
Eventually I did get it to work, using a jlabel instead.
Now I am working on getting my buttons to show where I want them to. I do not just want a layout manager to slap them up, I want very precise control of where they appear.
To help, I even tried using google's Window Builder. But it is seems overly cumbersome. Additionally, I have not successfully added the images to my project (it shows up there, but when linked to jlabel they dont show up) so I have to use a file system path which of course is useless when I try to share this application.
So here are my questions:
Why does it have to be so difficult to create a simple GUI?
Is Java a useable language for this type of project? I want to have a background image and then place buttons and other images on top of it. For example one large 1024X768 image that is the size of my application, an other image of my "hero" and then a semi-transparent red rectangle over it which covers it up more and more as he takes damage.
And what am I doing wrong?!
thanks!
- 07-07-2011, 05:54 AM #2
Member
- Join Date
- Jul 2011
- Posts
- 5
- Rep Power
- 0
Java is tough to use. If you are new to coding I would suggest trying an easier language like DarkBasic.
- 07-07-2011, 06:31 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Java is not really that tough, just move slowly, learn to walk before you run, check out the tutorials, here is a link.
Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)
Don't use a GUI builder and use the layout manager, you can still get precise positing with layout managers, it will just take a minimal amount of logic/planning. At first swing is challenging, but it's not so bad.Last edited by sunde887; 07-07-2011 at 08:20 AM. Reason: Ninja editing
- 07-07-2011, 08:15 AM #4
- 07-07-2011, 08:19 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Ugh, even as I was typing that I noticed I had it backwards and yet I still managed to mess it up. Ninja editing above post.
- 07-07-2011, 10:55 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
These two things are not entirely compatible. If you let a layout manager do the laying out then it's a lot easier. So by insisting on the first thing you are preventing the second.
That should be quite easy using overriding whichever paint method it is you're supposed to override, at least for that image of your hero. Just draw the hero and blit the red overlay over the top, then draw that to whataver component this appears on.
Note, Java is not a plug and play language. You do have to learn it. And learning by doing a Swing application really isn't a good idea as Swing employs a whole load of concepts that build on the basics. Start with a simple text version of your game. If you build it correctly you can even use much of the same code against a later Swing front end.
- 07-07-2011, 05:54 PM #7
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
Thanks everyone for the replies. I am following the tutorials provided by sunde. I had already visited several of those links. I have also read the book Head First Java. Its in trying to get things to look stylish, rather than business like that I run into troubles.
At this point I think I will just have it look like a business application rather than a game. I am excited about working on game logic rather than perfecting the layout.
At times it really felt like I was trying to remove a jammed spoon from a running garbage disposal: a painful process, the end results wasn't pretty and afterwards I had to wonder if it was all just a bad idea.
- 07-07-2011, 05:58 PM #8
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
- 07-07-2011, 11:04 PM #9
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
sunde887, I have gone through those excellent tutorials all the way up to having a mouselook scrolling tile thing, the last one. I hope TheNewBoston gets back to it at some point, but the forums painted a bleak picture.
I have started using netbeans and I have a working prototype at this point. I am just using jprogressbars for health bars at this point.
The designer is most helpful and more intuitive (for a beginner at least) than window builder. Looking through the automagically generated code, I really don't see anything new besides the .addGap method. This is good because I obviously want to be able to understand my own code.
I finally feel like I am back to programming, thanks everyone for the advice!
- 07-08-2011, 09:56 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Eclipse IDE Swing Builder
By chyrl in forum Advanced JavaReplies: 6Last Post: 08-19-2010, 02:36 PM -
Under windows, java2d applet is working in eclipse but not in web browser
By tametick in forum Java AppletsReplies: 1Last Post: 08-19-2010, 12:47 PM -
run a new java gui in windows XP (using eclipse SDK to create gui)
By sivan in forum New To JavaReplies: 1Last Post: 05-18-2010, 09:42 AM -
Eclipse debug not working on Windows Vista
By mathew.vinay in forum EclipseReplies: 5Last Post: 04-04-2009, 01:06 PM -
Eclipse GUI Builder
By elebal in forum EclipseReplies: 1Last Post: 10-23-2008, 11:38 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote


Bookmarks