Results 1 to 4 of 4
  1. #1
    felito is offline Member
    Join Date
    Nov 2010
    Posts
    48
    Rep Power
    0

    Default simple question vector

    hi guys,

    why the first code doesn't replace the second? i want create an array of buttons where only thing that change is the btnX ---(the name of each button)

    ...


    Java Code:
    		
    		JButton[] btn=new JButton[10]; // ten is an example
    		for(int i=0;i<10;i++)
    	        btn[i]=new JButton("New");
    
    
    
    JButton btn1 = new JButton("New");
    JButton btn2 = new JButton("New");
    thanks

  2. #2
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    11

    Default

    Quote Originally Posted by felito View Post
    hi guys,

    why the first code doesn't replace the second? i want create an array of buttons where only thing that change is the btnX ---(the name of each button)
    That's not how arrays work. What are you trying to accomplish? You may not really want an array of JButton objects.

    -Gary-

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,313
    Blog Entries
    1
    Rep Power
    32

  4. #4
    felito is offline Member
    Join Date
    Nov 2010
    Posts
    48
    Rep Power
    0

    Default

    the problem is that i I was not calling the correct position vector

    Solved with btn[1], btn[2], ...

    thanks for your rime

Similar Threads

  1. simple question about servlets
    By kulangotski in forum Java Servlet
    Replies: 2
    Last Post: 01-06-2011, 09:50 AM
  2. very simple Question
    By arsenal4ever_11 in forum NetBeans
    Replies: 2
    Last Post: 05-27-2010, 08:51 PM
  3. some simple question?
    By jperson in forum New To Java
    Replies: 4
    Last Post: 05-03-2010, 05:32 PM
  4. Simple Question
    By barusk in forum Networking
    Replies: 13
    Last Post: 03-04-2009, 07:33 PM
  5. Probably a really simple question...
    By ibanez270dx in forum New To Java
    Replies: 0
    Last Post: 11-16-2007, 01:27 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
  •