Re: getting the color of the button
On 17 =D7=99=D7=95=D7=9C=D7=99, 14:06, Roedy Green <see_webs...@mindprod.co=
m.invalid>
wrote:
On Thu, 16 Jul 2009 12:12:46 -0700 (PDT), thread <yaniv...@gmail.com>
wrote, quoted or indirectly quoted someone who said :
i'm trying to get indication of the button object i'm using but
besides having for every button text and used this indication in the
performedevent method i cannot find another way
is it posible to indicate the button object by ID or color?
There two main ways to hide such information in a JButton object.
setName and setActionCommand
seehttp://mindprod.com/jgloss/jbutton.html
--
Roedy Green Canadian Mind Productshttp://mindprod.com
"For reason that have a lot to do with US Government bureaucracy, we sett=
led on the one issue everyone could agree on, which was weapons of mass des=
truction."
~ Paul Wolfowitz 2003-06, explaining how the Bush administration sold the=
Iraq war to a gullible public.
how can i initialize and activate this class in the main menu or in
the class of the DrawApp:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
abstract public class ColorButton extends Frame
implements ActionListener,MouseListener,MouseMotionListener
{
Button
black_button,blue_button,cyan_button,darkGray_button,gray_button,green_butt=
on,lightGray_button,magenta_button,orange_button,pink_button,red_button,whi=
te_button,yellow_button;
public ColorButton()
{
black_button = new Button("");
black_button.setBackground(Color.black);
blue_button = new Button("");
blue_button.setBackground(Color.blue);
cyan_button = new Button("");
cyan_button.setBackground(Color.cyan);
darkGray_button = new Button("");
darkGray_button.setBackground(Color.darkGray);
gray_button = new Button("");
gray_button.setBackground(Color.gray);
green_button = new Button("");
green_button.setBackground(Color.green);
lightGray_button = new Button("");
lightGray_button.setBackground(Color.lightGray);
magenta_button = new Button("");
magenta_button.setBackground(Color.magenta);
orange_button = new Button("");
orange_button.setBackground(Color.orange);
pink_button = new Button("");
pink_button.setBackground(Color.pink);
red_button = new Button("");
red_button.setBackground(Color.red);
white_button = new Button("");
white_button.setBackground(Color.white);
yellow_button = new Button("");
yellow_button.setBackground(Color.yellow);
add(black_button);
add(blue_button);
add(cyan_button);
add(darkGray_button);
add(gray_button);
add(green_button);
add(lightGray_button);
add(magenta_button);
add(orange_button);
add(pink_button);
add(red_button);
add(white_button);
add(yellow_button);
}
}