Solved

Rearrange button order

Posted on 2012-03-30
3
274 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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

691 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