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
Solved

Rearrange button order

Posted on 2012-03-30
3
266 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 500 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

791 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