Joined: Fri Nov 12, 2010 6:13 am Posts: 1 Has thanked: 1 time Have thanks: 0 time
How do i instantiate a class in my gui code? For example i have a pay class that will be used in my gui code, how do i implement it?
Thanks
msi_333
Question subject: Re: instantiating classes
Posted: Fri Nov 12, 2010 10:23 am
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2279 Location: Earth Has thanked: 39 time Have thanks: 61 time
all datatypes in java are classes and can be up casted to root class OBJECT .You can extend GUI classes ( like JFrame ,JPanel , JButton ) lets say MyFrame (Which extends JFrame) and use an object instance from your class inside it .
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
For this message the author msi_333 has received gratitude : ruthie
isuru
Question subject: Re: instantiating classes
Posted: Thu Nov 18, 2010 12:09 pm
Joined: Thu Nov 18, 2010 11:56 am Posts: 49 Has thanked: 0 time Have thanks: 15 time
When a number of objects are created from the same class blueprint, they each have their own distinct copies of instance variables. In the case of the Bicycle class, the instance variables are cadence, gear, and speed. Each Bicycle object has its own values for these variables, stored in different memory locations.
Use of the static keyword to create fields and methods that belong to the class, rather than to an instance of the class.
You can extend JFrame by,
public class MyFrame extends JFrame { //Your code }
_________________ Coding my life with Java, PHP, JavaScript, and Python
For this message the author isuru has received gratitude : msi_333