• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

buttons

 
jake bellhorn
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


how do i add as many buttons as i want, whats a simple way of adding extra buttons?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jake bellhorn:
...how do i add as many buttons as i want, whats a simple way of adding extra buttons?

Something like this...?
 
jake bellhorn
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where would i put that in the code though
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try thinking it through...

One way to do this is to have a class with an instance variable called "buttons" (which references an array of JButtons) and an instance method called "makeButtons" (which takes an int value, instantiates the array to that size, and fills it with new JButton references).

So where would you put an instance variable and an instance method?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic