0

I have 1 table in database

TableRoom
- NoRoom
- Status

and i have noroom
101,
102,
103,
104,
105,
201,
202,
203,
204,
205

My problem is how to call a database and specify the colors for the buttons. if the status of the room was filled with the buttons should be colored red, and if the status of the room was empty, the button should be green

JButton [] arr = new JButton[10];

.........

if(r.next()){

status = r.getString("status");

noRoom = r.getString("noRoom");

for(int i=0; i<10; i++){

if (arr[i].getActionCommand().equals(noRoom)){

r.beforeFirst();

while(r.next()){

arr[i].setBackground(Color.red);

}

s.close();

c.close();

} else {

arr[i].setBackground(Color.green);

}
2
Contributors
1
Reply
6
Views
2 Years
Discussion Span
Last Post by JamesCherrill
0

That logic looks suspicious!
Maybe something like this (in pseudocode) would work better

for each row in the result set {
   use the noRoom to find the corresponding button
   if status is "filled" set button red
   else set button green
} 

Edited by JamesCherrill

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.