Results 1 to 3 of 3
  1. #1
    billycro is offline Member
    Join Date
    Sep 2010
    Posts
    9
    Rep Power
    0

    Lightbulb Home-Made GUI Object

    :confused: Okay so lets say I have the class Combatant. Combatant is made up of a bunch of stats, hp, def, atk, blah blah blah.

    I want a gui component that can represent this object, but only one instance. Like it's a combo of a bunch of jlabels. Would extending this class to a JPanel and then adding that panel to that of the Jframe i'm working with be the solution?

    ex.
    public class Combatant extends JPanel{
    JLabel nameLabel,otherLabels;
    //=new labelss and that stuff
    public Combatant(){
    add(nameLabel);
    //add the other stuff
    }
    }

    public class Runner{
    p. s. v. main(String[] args){
    //init a jframe
    //init a jpanel
    panel.add(new Combatant());
    }
    }

    something like this should give the desired effect

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    It could work, but as they say, the devil's in the details. I recommend that you split the problem up and first create a non-GUI Combatant and in this class try to encapsulate the behaviors and states of a Combatant. After that's done, then consider creating a GUI "view" of the non-GUI object. The fun is really in the experimenting and seeing how it can all possibly fit together.

    Best of luck!

  3. #3
    billycro is offline Member
    Join Date
    Sep 2010
    Posts
    9
    Rep Power
    0

    Default

    well thanks i suppose i'll have to see how this goes in class tomorrow, i'll give the deets of how that all turns out. but if there is an exact solution it would be good =]

Similar Threads

  1. Replies: 2
    Last Post: 06-30-2010, 08:19 AM
  2. what made paintComponent() method to be called twice??
    By Y. Progammer in forum New To Java
    Replies: 5
    Last Post: 02-21-2010, 11:19 PM
  3. No class made
    By ChuckLS in forum New To Java
    Replies: 1
    Last Post: 04-28-2009, 05:54 PM
  4. Replies: 2
    Last Post: 03-22-2009, 07:43 PM
  5. Make money from home, Home Typing Data Entry Partnerships
    By arturmoniswork in forum Reviews / Advertising
    Replies: 0
    Last Post: 12-30-2008, 06:55 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
  •