FileDocCategorySizeDatePackage
DirectionPanel.javaAPI DocExample7903Tue Jun 29 07:21:12 BST 1999None

DirectionPanel

public class DirectionPanel extends JPanel
version
1.6 08/26/98
author
Jeff Dinkins
author
Brian Beck

Fields Summary
private ButtonGroup
group
public static ImageIcon
bl_dot
public static ImageIcon
bldn_dot
public static ImageIcon
bm_dot
public static ImageIcon
bmdn_dot
public static ImageIcon
br_dot
public static ImageIcon
brdn_dot
public static ImageIcon
c_dot
public static ImageIcon
cdn_dot
public static ImageIcon
ml_dot
public static ImageIcon
mldn_dot
public static ImageIcon
mr_dot
public static ImageIcon
mrdn_dot
public static ImageIcon
tl_dot
public static ImageIcon
tldn_dot
public static ImageIcon
tm_dot
public static ImageIcon
tmdn_dot
public static ImageIcon
tr_dot
public static ImageIcon
trdn_dot
Constructors Summary
public DirectionPanel(boolean enable, String selection, ActionListener l)

	setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	setAlignmentY(TOP_ALIGNMENT);
	setAlignmentX(LEFT_ALIGNMENT);

	Box firstThree = Box.createHorizontalBox();
	Box secondThree = Box.createHorizontalBox();
	Box thirdThree = Box.createHorizontalBox();

	if(!enable) {
	    selection = "None";
	}

        group = new ButtonGroup();
	DirectionButton b;
	b = (DirectionButton) firstThree.add(new DirectionButton(  tl_dot, tldn_dot, "NW", "Sets the orientation to the North-West", l, group, selection.equals("NW")));
	b.setEnabled(enable);
	b = (DirectionButton) firstThree.add(new DirectionButton(  tm_dot, tmdn_dot, "N",  "Sets the orientation to the North", l, group, selection.equals("N")));
	b.setEnabled(enable);
	b = (DirectionButton) firstThree.add(new DirectionButton(  tr_dot, trdn_dot, "NE", "Sets the orientation to the North-East", l, group, selection.equals("NE")));
	b.setEnabled(enable);
	b = (DirectionButton) secondThree.add(new DirectionButton( ml_dot, mldn_dot, "W", "Sets the orientation to the West", l, group, selection.equals("W")));
	b.setEnabled(enable);
	b = (DirectionButton) secondThree.add(new DirectionButton( c_dot,  cdn_dot,  "C", "Sets the orientation to the Center", l, group, selection.equals("C")));
	b.setEnabled(enable);
	b = (DirectionButton) secondThree.add(new DirectionButton( mr_dot, mrdn_dot, "E", "Sets the orientation to the East", l, group, selection.equals("E")));
	b.setEnabled(enable);
	b = (DirectionButton) thirdThree.add(new DirectionButton(  bl_dot, bldn_dot, "SW", "Sets the orientation to the South-West", l, group, selection.equals("SW")));
	b.setEnabled(enable);
	b = (DirectionButton) thirdThree.add(new DirectionButton(  bm_dot, bmdn_dot, "S", "Sets the orientation to the South", l, group, selection.equals("S")));
	b.setEnabled(enable);
	b = (DirectionButton) thirdThree.add(new DirectionButton(  br_dot, brdn_dot, "SE", "Sets the orientation to the South-East", l, group, selection.equals("SE")));
	b.setEnabled(enable);

	add(firstThree);
	add(secondThree);
	add(thirdThree);	
    
Methods Summary
public java.lang.StringgetSelection()

        return group.getSelection().getActionCommand();
    
public voidsetSelection(java.lang.String selection)

        Enumeration e = group.getElements();
        while( e.hasMoreElements() ) {
            JRadioButton b = (JRadioButton)e.nextElement();
            if( b.getActionCommand().equals(selection) ) {
               b.setSelected(true);
            }
        }