array of buttons .. wut do u thik right?

here is the code i tried to create a bunch of JButtons in the frame ..

wut is between the comments wut i tried and didn't work for me ..

wut is my mistake .. please clearly explain to me .. oh by the way i don't want in my application to set a listener for my buttons ..

i just want to show it ..

regards

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

publicclass buttonsextends JFrame

{

publicfinalint w = 200;

publicfinalint h = 200;

JFrame frm =new JFrame();

//JButton [] set = new JButton (10);

public buttons ()

{

/*for (int i = 0; i=set.length();i++)

{

set.add(i);

}*/

//frm.add(set);

frm.setSize(200,200);

frm.setVisible(true);

}

publicstaticvoid main(String[]args)

{

new buttons();

}

}

[1776 byte] By [DaVeeCka] at [2007-11-26 12:30:51]
# 1
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
kablaira at 2007-7-7 15:42:05 > top of Java-index,Java Essentials,New To Java...
# 2

If you don't want the buttons to do anything, what's the point of having them? Maybe you want labels instead, they are used for displaying text with no interaction.

As far as your code, you need to look at this tutorial:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/index.html

specifically the part about arrays.

//JButton [] set = new JButton (10);

JButton[] set = new JButton[10];

public buttons ()

{

/*for (int i = 0; i=set.length();i++)

{

set.add(i);

}*/

for (int i = 0; i=set.length; i++) {

set[i] = new JButton("whatever text you want");

}

hunter9000a at 2007-7-7 15:42:05 > top of Java-index,Java Essentials,New To Java...
# 3
> If you don't want the buttons > to do anything, what's the point > of having them?You can click on them. ;-)OP, you need to use the for loop to add the buttons to the frame.
CaptainMorgan08a at 2007-7-7 15:42:05 > top of Java-index,Java Essentials,New To Java...
# 4
If it wasn't clear enough the link was provided because you're not even remotely close to using arrays correctly. You haven't initialized the elements, you're calling methods that don't exist and evidently have no knowledge of the syntax.
kablaira at 2007-7-7 15:42:05 > top of Java-index,Java Essentials,New To Java...