Spinner.java :  » App » learnandroid » com » lgnortel » network » networkview » Android Open Source

Android Open Source » App » learnandroid 
learnandroid » com » lgnortel » network » networkview » Spinner.java
package com.lgnortel.network.networkview;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicArrowButton;

/**
 * Copyright (c) 2008 LG-Nortel, Inc. All Rights Reserved.
 * 
 * CONFIDENTIALITY AND LIMITED USE: This software, including any software of <br>
 * third parties embodied herein, contains code, information, data and concepts <br>
 * which are confidential and/or proprietary to LG-Nortel and such third <br>
 * parties. This software is licensed for use solely in accordance with the <br>
 * terms and conditions of the applicable license agreement with LG-Nortel or <br>
 * its authorized distributor, and not for any other use or purpose. No <br>
 * redistribution of this software by any party is permitted. <br>
 * 
 * Title: CommonTableCellRenderer.java<br>
 * Description: <br>
 * Copyright: Copyright(c) 2008 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * 
 * Title: Spinner.java<br>
 * Description: <br>
 * Copyright: Copyright(c) 2008 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * 
 * @author JungGu Lee
 * @version 0.1
 * @created 2009. 1. 21.
 * @modified 2009. 1. 21.
 * @product EFA R4.0 EMS
 * @sw_block
 */

public class Spinner extends JPanel {
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  private int m_orientation = SwingConstants.VERTICAL;
  public BasicArrowButton m_incrementButton;
  public BasicArrowButton m_decrementButton;

  /**
   * Constructor of this class
   */
  public Spinner() {
    createComponents();
  }

  /**
   * Constructor of this class
   */
  public Spinner(int orientation) {
    m_orientation = orientation;
    createComponents();
  }

  /**
   * set enable increment button and decrement button
   */
  public void setEnabled(boolean enable) {
    m_incrementButton.setEnabled(enable);
    m_decrementButton.setEnabled(enable);
  }

  /**
   * check enable or not
   */
  public boolean isEnabled() {
    return (m_incrementButton.isEnabled() && m_decrementButton.isEnabled());
  }

  /**
   * create component
   */
  protected void createComponents() {
    if (m_orientation == SwingConstants.VERTICAL) {
      setLayout(new GridLayout(2, 1));
      m_incrementButton = new BasicArrowButton(SwingConstants.NORTH, UIManager.getColor("control"), UIManager.getColor("controlShadow"), Color.BLACK, UIManager.getColor("controlLtHighlight"));
      m_decrementButton = new BasicArrowButton(SwingConstants.SOUTH, UIManager.getColor("control"), UIManager.getColor("controlShadow"), Color.BLACK, UIManager.getColor("controlLtHighlight"));
      add(m_incrementButton);
      add(m_decrementButton);
    } else if (m_orientation == SwingConstants.HORIZONTAL) {
      setLayout(new GridLayout(1, 2));
      m_incrementButton = new BasicArrowButton(SwingConstants.EAST, UIManager.getColor("control"), UIManager.getColor("controlShadow"), Color.BLACK, UIManager.getColor("controlLtHighlight"));
      m_decrementButton = new BasicArrowButton(SwingConstants.WEST, UIManager.getColor("control"), UIManager.getColor("controlShadow"), Color.BLACK, UIManager.getColor("controlLtHighlight"));
      add(m_decrementButton);
      add(m_incrementButton);
    }
  }

  /**
   * get increment
   * @return
   */
  public JButton getIncrementButton() {
    return (m_incrementButton);
  }

  /**
   * get decrement
   * @return
   */
  public JButton getDecrementButton() {
    return (m_decrementButton);
  }
}
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.