Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

help with setting up a swing components

Posted on 2006-07-23
7
Medium Priority
?
204 Views
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

cheers
zolf
0
Comment
Question by:zolf
  • 5
  • 2
7 Comments
 
LVL 86

Expert Comment

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

Author Comment

by:zolf
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());
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17162592
Yes, you can. If you do that after retrieval, you can determine the rows and columns too
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 86

Accepted Solution

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

Author Comment

by:zolf
ID: 17162608

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

Expert Comment

by:CEHJ
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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17162622
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

876 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