Solved

help with setting up a swing components

Posted on 2006-07-23
7
198 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 86

Accepted Solution

by:
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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 79
advertisement module in core php 4 159
Java Server Faces parameter pass? 6 48
how to see all occupied ports on windows 10 laptop 15 59
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now