[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Rearrange button order

Posted on 2012-03-30
3
Medium Priority
?
277 Views
Last Modified: 2012-08-14
how can i rewrite this code so it displays the buttons in the roulette table order

Roulette table

for( count=0; count < buttons.length; count++){
            buttons[count] = new JButton(btnNames[count]);
            final String text =   buttons[count].getText();
            buttons[count].addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e)
                    {
                        setbetOn(text);
                    }
                });
            i++;
            buttons[count].setForeground(Color.WHITE);
            buttons[count].setBackground(Color.BLACK);

            betField.add(buttons[count]);
        }

Open in new window

0
Comment
Question by:jillette
  • 3
3 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 37788022
Your prder in dpendent on the order of integers in the array btnNmaes that we declare at the top

So if you say:

String [] btnNames  = {"36", "0", "2,", "4", "8","33"}

tha would be the order of your buttons (sorry dont rememeber how theye are on the roulette)
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37788034
You also should take into account which layout you are using and how it populates.

If you just use FlowLayout() it will populate them in the order you area adding
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37788045
GridLayout will populate first line , then second line , etc.

see empample for GrdidLayout(3,2) here:
http://java.comsci.us/examples/awt/GridLayout.html
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 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