Results 1 to 3 of 3
Thread: Home-Made GUI Object
- 09-21-2010, 12:28 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 9
- Rep Power
- 0
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
-
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!
- 09-21-2010, 01:06 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 9
- Rep Power
- 0
Similar Threads
-
How do I run a java program that I made off of my desktop?
By Chris Rice in forum New To JavaReplies: 2Last Post: 06-30-2010, 07:19 AM -
what made paintComponent() method to be called twice??
By Y. Progammer in forum New To JavaReplies: 5Last Post: 02-21-2010, 10:19 PM -
No class made
By ChuckLS in forum New To JavaReplies: 1Last Post: 04-28-2009, 04:54 PM -
how to run my java program made in netbeans to another PC?
By kwink in forum AWT / SwingReplies: 2Last Post: 03-22-2009, 06:43 PM -
Make money from home, Home Typing Data Entry Partnerships
By arturmoniswork in forum Reviews / AdvertisingReplies: 0Last Post: 12-30-2008, 05:55 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks