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

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
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 46
How  Can  I  resolve   this  Error "java.sql.SQLException: Invalid column index" 4 49
web application structure 18 100
tomcat startup error 5 102
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

839 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