FileDocCategorySizeDatePackage
DirectionPanel.javaAPI DocSun JDK 1.4.2 Example7511Thu May 12 00:35:28 BST 2005None

DirectionPanel

public class DirectionPanel extends JPanel
version
1.5 01/23/03
author
Jeff Dinkins
author
Chester Rose
author
Brian Beck

Fields Summary
private ButtonGroup
group
public ImageIcon
bl_dot
public ImageIcon
bldn_dot
public ImageIcon
bm_dot
public ImageIcon
bmdn_dot
public ImageIcon
br_dot
public ImageIcon
brdn_dot
public ImageIcon
c_dot
public ImageIcon
cdn_dot
public ImageIcon
ml_dot
public ImageIcon
mldn_dot
public ImageIcon
mr_dot
public ImageIcon
mrdn_dot
public ImageIcon
tl_dot
public ImageIcon
tldn_dot
public ImageIcon
tm_dot
public ImageIcon
tmdn_dot
public ImageIcon
tr_dot
public 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 javax.swing.ImageIconloadImageIcon(java.lang.String filename, java.lang.String description)

    
          
	String path = "/resources/images/buttons/" + filename;
	return new ImageIcon(getClass().getResource(path), description);
    
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);
            }
        }