• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

help with setting up a swing components


hello there,

i want to develop a panel in which i will fill it with JButtons.the number of buttons will depend on the number of data in the db.i want to know how can i get started with this thing.

please help

cheers
zolf
0
zolf
Asked:
zolf
  • 5
  • 2
1 Solution
 
CEHJCommented:
Just create a List of JButton. Add to it as you retrieve results
0
 
zolfAuthor Commented:

can you give me some code example please.
do i need to use something like this

Panel pKey = new Panel();
pKey.setLayout(new GridLayout());
0
 
CEHJCommented:
Yes, you can. If you do that after retrieval, you can determine the rows and columns too
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
CEHJCommented:
Actually to avoid two iterations, you can call setColumns on the GridLayout, having retrieved the number of columns from DatabaseMetaData
0
 
zolfAuthor Commented:

how do i add the data to the JButton and then add the button on the panel??
0
 
CEHJCommented:
>>how do i add the data to the JButton

You need to tell me more about what's required. You probably need to do

JButton b = new JButton(rs.getString("SomeColumn"));
buttons.add(b); // add to List
0
 
CEHJCommented:
:-)
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now