Results 1 to 2 of 2
  1. #1
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default using J-classes or extend them ?

    Hi

    As I'm teaching myself the art of GUI using swing , I usually find two manners for using the swing J componnets: I'm new in Java , so I'm not quite realize the differnences between them - can you help me?


    1: just use them, make Jframe and JPanel and Jbuttons and add them ext..

    2: extend - I saw in some example that instead of create JPanel , a new calss is created by extending the JPAnel class: (for example)
    Java Code:
    class ButtonPanel extends JPanel
    3: implement them ( mainly for actionlistener) - for example
    Java Code:
    class Lnr_3 implements ActionListener {			
    			 Lnr_3 ()
    			 {	
    				 //constructor			}
    					
    			public void actionPerformed(ActionEvent e) {
    // the method itself....
    							}// end of actionPerf
    
    		}

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

    Default

    These classes are no different from other classes, and you use them in the way that works best in the situation at hand.

    Having said that, I sense that with OOP programming in general, there has been a trend recently to avoid extending by inheritance and instead trying to extend more by composition, and this trend can be seen with Swing code as well.

Similar Threads

  1. Help with classes
    By gnarly hogie in forum New To Java
    Replies: 14
    Last Post: 10-10-2008, 02:29 PM
  2. Get name of available classes
    By escuja in forum CLDC and MIDP
    Replies: 0
    Last Post: 07-26-2008, 12:03 PM
  3. How to extend Messages Component
    By Jothi in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 05-20-2008, 08:50 AM
  4. Help with classes
    By freswood in forum New To Java
    Replies: 5
    Last Post: 04-21-2008, 03:28 PM
  5. When do we use inner classes?
    By cruxblack in forum New To Java
    Replies: 5
    Last Post: 08-10-2007, 05:00 PM

Posting Permissions

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