Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By Tolls

Thread: GUI frustrations - using Eclipse and now Windows Builder

  1. #1
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default 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!

  2. #2
    htuy is offline Member
    Join Date
    Jul 2011
    Posts
    5
    Rep Power
    0

    Default

    Java is tough to use. If you are new to coding I would suggest trying an easier language like DarkBasic.

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    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

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default

    Quote Originally Posted by sunde887 View Post
    Java is not really that tough, just move slowly, learn to run before you can walk, check out the tutorials
    Really?

    db

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    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.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default

    Quote Originally Posted by White Mountains View Post
    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.
    Why does it have to be so difficult to create a simple GUI?
    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.

    Quote Originally Posted by White Mountains View Post
    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!
    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.

  7. #7
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    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.

  8. #8
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

  9. #9
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    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!

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default

    One thing we always say here is do not use a GUI Builder until you know how to write Swing code well.
    You will have a hard time taking that Netbeans GUI and reworking it when (if) you eventually decide to do it properly.
    sunde887 likes this.

Similar Threads

  1. Eclipse IDE Swing Builder
    By chyrl in forum Advanced Java
    Replies: 6
    Last Post: 08-19-2010, 02:36 PM
  2. Replies: 1
    Last Post: 08-19-2010, 12:47 PM
  3. Replies: 1
    Last Post: 05-18-2010, 09:42 AM
  4. Eclipse debug not working on Windows Vista
    By mathew.vinay in forum Eclipse
    Replies: 5
    Last Post: 04-04-2009, 01:06 PM
  5. Eclipse GUI Builder
    By elebal in forum Eclipse
    Replies: 1
    Last Post: 10-23-2008, 11:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •