Solved

Rearrange button order

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now