DCheckPanel.java :  » Database-ORM » tro-community-7.2-1 » jtaDiscRack » presentation » dpanels » Java Open Source

Java Open Source » Database ORM » tro community 7.2 1 
tro community 7.2 1 » jtaDiscRack » presentation » dpanels » DCheckPanel.java
package jtaDiscRack.presentation.dpanels;

import jtaDiscRack.presentation.delements.*;

import javax.swing.*;
import java.awt.*;

/**
 * Creates a panel with check button.
 *
 * @author Sasa Bojanic
 * @version 1.0
 */
public class DCheckPanel extends DPanel {

   private JCheckBox jcb;

   public DCheckPanel (DSimpleElement myOwner) {

      super(myOwner,2,"",false,false);

      JLabel jl=new JLabel(myOwner.toName()+": ");
      jl.setAlignmentX(Component.LEFT_ALIGNMENT);
      jl.setAlignmentY(Component.TOP_ALIGNMENT);
      jl.setHorizontalAlignment(SwingConstants.RIGHT);

      jcb=new JCheckBox();
      if (myOwner.toValue()!=null && myOwner.toValue() instanceof Boolean) {
         jcb.setSelected(((Boolean)myOwner.toValue()).booleanValue());
      }
      jcb.setAlignmentX(Component.LEFT_ALIGNMENT);
      jcb.setAlignmentY(Component.TOP_ALIGNMENT);
      jcb.setMinimumSize(new Dimension(textFieldDimension));
      jcb.setMaximumSize(new Dimension(textFieldDimension));
      jcb.setPreferredSize(new Dimension(textFieldDimension));

      add(Box.createHorizontalGlue());
      add(jl);
      add(jcb);
   }

   public JCheckBox getCheckBox () {
      return jcb;
   }

   public void setElements () {
      getOwner().setValue(new Boolean(jcb.isSelected()));
   }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.