help with setting up a swing components

Posted on 2006-07-23
Last Modified: 2010-03-31

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

Question by:zolf
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 86

Expert Comment

ID: 17162584
Just create a List of JButton. Add to it as you retrieve results

Author Comment

ID: 17162588

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

Panel pKey = new Panel();
pKey.setLayout(new GridLayout());
LVL 86

Expert Comment

ID: 17162592
Yes, you can. If you do that after retrieval, you can determine the rows and columns too
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 86

Accepted Solution

CEHJ earned 250 total points
ID: 17162600
Actually to avoid two iterations, you can call setColumns on the GridLayout, having retrieved the number of columns from DatabaseMetaData

Author Comment

ID: 17162608

how do i add the data to the JButton and then add the button on the panel??
LVL 86

Expert Comment

ID: 17162614
>>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
LVL 86

Expert Comment

ID: 17162622

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question