?
Solved

Rearrange button order

Posted on 2012-03-30
3
Medium Priority
?
275 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
[X]
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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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 different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

777 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