亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? datecombobox.java

?? 更方便的SWING
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * PSwing Utilities -- Nifty Swing Widgets
 * Copyright (C) 2002  Pallas Technology
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * Pallas Technology
 * 1170 HOWELL MILL RD NW
 * SUITE 306
 * ATLANTA GEORGIA 30318
 * 
 * PHONE 404.983.0623
 * EMAIL info@pallastechnology.com
 * 
 * www.pallastechnology.com
 **************************************************************************
 * $Archive: SwingTools$
 * $FileName: DateComboBox.java$
 * $FileID: 8$
 *
 * Last change:
 * $AuthorName: Rob MacGrogan$
 * $Date: 2/27/03 6:37 PM$
 * $VerID: 80$
 * $Comment: Strip off the time component of date. $
 **************************************************************************/
//////////////////////////////////////////////////////////////
// DateComboBox.java
//////////////////////////////////////////////////////////////

package com.pallas.swing.date;

import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.ComboBoxUI;
import javax.swing.plaf.basic.ComboPopup;
import javax.swing.plaf.metal.MetalComboBoxUI;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.text.Document;

import com.sun.java.swing.plaf.motif.MotifComboBoxUI;
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI;

//////////////////////////////////////////////////////////////

/**
 * Title:   $FileName: DateComboBox.java$
 * @version $VerNum: 10$
 * @author $AuthorName: Rob MacGrogan$<br><br>
 * 
 * $Description: A date control that pops up a calendar.$<br>
 * $KeyWordsOff: $<br><br>
 * 
 * 
 * A date control that pops up a calendar. Derived from code posted at
 * http://softwaredev.earthweb.com/java/article/0,,12082_735291,00.html by
 * Paul Book.<br><br>
 * 
 * Works under java 1.3 and 1.4.1. A bug in 1.4.0 causes very odd behavior
 * under Windows LAF, but should work fine under other LAFs.
 */
public class DateComboBox extends JComboBox {

  //Used only for display.
  protected SimpleDateFormat dateFormat = new SimpleDateFormat("MMM d, yyyy");

  //Used for formatting what user types.
  private ArrayList formats = new ArrayList();

  /**
   * Defaults to null. And MMM d, yyyy pattern.
   */
  public DateComboBox() {
    super();
    initializeComponent();
  }

  /**
   * Sets initial date of combo box. Defaults pattern to MMM d, yyyy.
   */
  public DateComboBox(java.util.Date date) {
    super();
    initializeComponent();
    setDate(date);
  }

  public DateComboBox(java.util.Date date, String pattern) {
    super();
    initializeComponent();
    setDateFormat(pattern);
    setDate(date);
  }

  public DateComboBox(String pattern) {
    super();
    initializeComponent();
    setDateFormat(pattern);
  }

  public void setName(String s) {
    super.setName(s);
    getEditor().getEditorComponent().setName(s + "-- editor");
  }

  DateFormat getFormat() {
    return dateFormat;
  }

  public void addFormat(DateFormat format){
    formats.add(format);
  }

  public void addFormat(String format){
    formats.add(new SimpleDateFormat(format));
  }

  /**
   * Initializes the DateComboBox.
   */
  private void initializeComponent() {
    super.setEditable(true);

    JTextField field = (JTextField) getEditor().getEditorComponent();
    field.addFocusListener(new DateFocusListener(this));
    //setCalendarIcon();
  }
  
  /**
   * Attempts to parse sDate to a date using all available date formats.
   */
  java.util.Date parseDateString(String sDate)
          throws ParseException{
    java.util.Date value = null;
    //Now try all remaining formats.
    Iterator itr = formats.iterator();
    while(itr.hasNext()){
      DateFormat format = (DateFormat)itr.next();
      try{
        value = format.parse(sDate);
        //if we get here we got a value, so break.
        break;
      }
      catch (ParseException ex2){
        //just don't break.
      }
    }
    if (value == null){
      throw new ParseException("Can't format string " + sDate + " into a date.", 0);
    }
    return value;
  }

  private void setCalendarIcon() {
    Component[] components = getComponents();
    for (int i = 0; i < components.length; i++) {
      if (components[i] instanceof JButton) {
        JButton btn = (JButton) components[i];
        ActionListener[] listeners = btn.getActionListeners();
        JButton calButton = new JButton(getButtonIcon());
        for (int j = 0; j < listeners.length; j++) {
          calButton.addActionListener(listeners[i]);
        }
        remove(btn);
        add(calButton);
        //btn.setIcon(getButtonIcon());
        break;
      }
    }

  }

  private Icon getButtonIcon() {
    java.net.URL imageURL = DateComboBox.class.getResource("calendar.gif");
    Image img = Toolkit.getDefaultToolkit().getImage(imageURL);
    Icon ic = new ImageIcon(img);
    return ic;
  }

  /**
   * This method does nothing. DateComboBox is always editable.
   */
  public void setEditable(boolean editable) {
    //Do nothing.
  }

  public void setDateFormat(SimpleDateFormat dateFormat) {
    this.dateFormat = dateFormat;
  }

  public void setDateFormat(String pattern) {
    dateFormat = new SimpleDateFormat(pattern);
  }

  /**
   * Returns a new Date with the same calendar date as the Date passed in, 
   * but with the time changed to 12:00 AM.
   */
  public static java.util.Date stripTime(java.util.Date dt){
    java.util.Date dtStripped = null;
    Calendar cal = Calendar.getInstance();
    cal.setTime(dt);
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);
    int day = cal.get(Calendar.DAY_OF_MONTH);
    
    Calendar calStripped = Calendar.getInstance();
    calStripped.clear();
    calStripped.set(year, month, day);
    
    return calStripped.getTime(); 
  }


  public void setDate(java.util.Date date) {
    if (date != null) {
      date = stripTime(date);
      CBDate cbDate = new CBDate();
      cbDate.setDate(date);
      cbDate.setFormat(dateFormat.toPattern());
      setSelectedItem(cbDate);
    }
    else {
      setSelectedItem(null);
    }
  }

  public java.util.Date getDate() {
    java.util.Date date = null;
    try {
      Object o = getSelectedItem();
      if (o instanceof CBDate) {
        CBDate cbDate = (CBDate) o;
        date = cbDate.getDate();
      }
      else {
        throw new java.text.ParseException("The value of the DateComboBox is not a Date.", 0);
      }
    }
    catch (ParseException ex) {
      date = null;
    }
    return date;
  }

  public void setSelectedItem(Object item) {
    // Could put extra logic here or in renderer when item is instanceof Date, Calendar, or String
    // Dont keep a list ... just the currently selected item
    removeAllItems(); // hides the popup if visible
    addItem(item);
    super.setSelectedItem(item);
  }

  public void updateUI() {
    ComboBoxUI cui = (ComboBoxUI) UIManager.getUI(this);
    if (cui instanceof MetalComboBoxUI) {
      cui = new MetalDateComboBoxUI();
    }
    else if (cui instanceof MotifComboBoxUI) {
      cui = new MotifDateComboBoxUI();
    }
    else if (cui instanceof WindowsComboBoxUI) {
      cui = new WindowsDateComboBoxUI();
    }
    setUI(cui);
    //super.updateUI();
    initializeComponent();
  }

  // Inner classes are used purely to keep DateComboBox component in one file
  //////////////////////////////////////////////////////////////
  // UI Inner classes -- one for each supported Look and Feel
  //////////////////////////////////////////////////////////////

  class MetalDateComboBoxUI extends MetalComboBoxUI {
    protected ComboPopup createPopup() {
      return new DatePopup((DateComboBox) comboBox);
    }
  }

  class WindowsDateComboBoxUI extends WindowsComboBoxUI {
    protected ComboPopup createPopup() {
      return new DatePopup((DateComboBox) comboBox);
    }
  }

  class MotifDateComboBoxUI extends MotifComboBoxUI {
    protected ComboPopup createPopup() {
      return new DatePopup((DateComboBox) comboBox);
    }
  }

  class CBDate {
    private java.util.Date date = null;
    private SimpleDateFormat format = null;

    public java.util.Date getDate() {
      return date;
    }
    public void setDate(java.util.Date dt) {
      date = dt;
    }
    public void setFormat(String s) {
      format = new SimpleDateFormat(s);
    }

    public String toString() {
      return format.format(date);
    }
  }

  //////////////////////////////////////////////////////////////
  // DatePopup inner class
  //////////////////////////////////////////////////////////////

  class DatePopup implements ComboPopup, MouseMotionListener, MouseListener, KeyListener, PopupMenuListener {

    protected DateComboBox comboBox;
    protected Calendar calendar;
    protected JPopupMenu popup;
    protected JLabel monthLabel;
    protected JPanel days = null;
    protected SimpleDateFormat monthFormat = new SimpleDateFormat("MMM yyyy");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕av资源一区| 亚洲欧洲国产日本综合| 亚洲国产高清aⅴ视频| 亚洲精品videosex极品| 经典三级一区二区| 国产美女精品一区二区三区| 极品美女销魂一区二区三区免费| 95精品视频在线| 久久久国产精品麻豆| 奇米影视7777精品一区二区| 色婷婷综合久久久久中文一区二区| 日韩视频免费观看高清完整版| 亚洲人成伊人成综合网小说| 国产一区二区三区免费在线观看| 欧美日韩美少妇| 亚洲免费观看高清在线观看| 成人精品视频网站| 精品国产3级a| 麻豆成人久久精品二区三区红| 欧美在线观看18| 亚洲老司机在线| 91猫先生在线| 亚洲欧洲韩国日本视频| av不卡在线观看| 一区在线中文字幕| 99久久综合色| 亚洲日本成人在线观看| 成人午夜免费电影| 国产精品热久久久久夜色精品三区 | 欧美极品美女视频| 黑人精品欧美一区二区蜜桃| 日韩午夜三级在线| 美国毛片一区二区三区| 91麻豆精品国产91久久久使用方法| 亚洲国产欧美在线| 91精品中文字幕一区二区三区| 亚洲一区二区三区四区不卡| 欧美日韩高清一区二区三区| 日韩中文字幕区一区有砖一区| 精品视频在线免费| 免费欧美在线视频| 久久久天堂av| 成人免费毛片a| 亚洲免费资源在线播放| 欧美性一区二区| 秋霞午夜av一区二区三区| 欧美一级日韩不卡播放免费| 国模大尺度一区二区三区| 中文字幕成人av| 99久精品国产| 亚洲二区在线观看| 日韩欧美你懂的| 波多野洁衣一区| 亚洲自拍与偷拍| 精品国产一区久久| 成人深夜视频在线观看| 亚洲一区二区三区四区在线免费观看| 在线电影一区二区三区| 精品一二线国产| 中文字幕佐山爱一区二区免费| 欧美欧美午夜aⅴ在线观看| 麻豆精品一区二区av白丝在线| 日本一区二区高清| 欧美日韩国产综合一区二区三区| 蜜桃久久久久久| 亚洲欧美日韩国产中文在线| 日韩色视频在线观看| 99久久综合色| 精品在线一区二区三区| 一个色综合av| 精品国产免费人成电影在线观看四季| 成人高清免费观看| 午夜久久久久久久久| 国产精品乱人伦| 日韩欧美亚洲一区二区| 色噜噜狠狠成人网p站| 国内精品嫩模私拍在线| 亚洲自拍与偷拍| 国产精品丝袜黑色高跟| 欧美大片日本大片免费观看| 日韩精品综合一本久道在线视频| jizz一区二区| 老司机精品视频在线| 一区二区三区四区av| 国产精品乱码一区二区三区软件| 欧美精品777| 91久久香蕉国产日韩欧美9色| 久久99国产精品免费| 亚洲妇熟xx妇色黄| 亚洲欧美自拍偷拍色图| 久久综合九色欧美综合狠狠| 91精品福利在线一区二区三区| 99天天综合性| 成人国产电影网| 国产真实乱子伦精品视频| 日韩影视精彩在线| 亚洲尤物在线视频观看| 国产精品国产自产拍高清av王其 | 国产精品久久久久9999吃药| 日韩视频免费观看高清在线视频| 欧美午夜精品久久久久久孕妇| 成人免费高清在线观看| 精品1区2区3区| 午夜电影久久久| 一个色在线综合| 玉米视频成人免费看| 亚洲私人影院在线观看| 日本欧美一区二区| 婷婷中文字幕一区三区| 亚洲1区2区3区4区| 婷婷中文字幕综合| 日韩精品一级中文字幕精品视频免费观看 | 成人免费毛片嘿嘿连载视频| 国产老肥熟一区二区三区| 九色综合狠狠综合久久| 久久99精品久久久久久| 六月丁香婷婷色狠狠久久| 久久福利视频一区二区| 久久成人av少妇免费| 韩国欧美一区二区| 国产精品资源站在线| 国产成人精品免费| 成人av在线播放网址| 91蜜桃在线免费视频| 欧美午夜精品电影| 91麻豆精品国产自产在线 | 日韩在线播放一区二区| 麻豆专区一区二区三区四区五区| 精品亚洲成a人| 国产成人免费高清| 一本大道av伊人久久综合| 在线视频欧美精品| 日韩欧美一级二级三级| 国产三级一区二区| 亚洲欧美视频一区| 日日夜夜精品视频天天综合网| 久久国产精品99久久久久久老狼 | 蜜臀久久99精品久久久久宅男| 精品一区二区在线看| 成人妖精视频yjsp地址| 欧美在线一二三四区| 日韩精品一区二区三区swag| 国产日产亚洲精品系列| 一区二区不卡在线播放 | 欧日韩精品视频| 在线91免费看| 国产欧美一区二区在线| 亚洲综合一区在线| 欧美系列一区二区| 日韩精品一区二区三区在线播放| 国产精品少妇自拍| 亚洲成人动漫一区| 丰满放荡岳乱妇91ww| 欧美猛男超大videosgay| xnxx国产精品| 亚洲一区二区三区四区中文字幕| 国产一区二区福利视频| 在线观看成人小视频| 国产亚洲一区二区在线观看| 亚洲一区二区三区小说| 国产成人av在线影院| 欧美二区三区91| 综合婷婷亚洲小说| 精品一区二区综合| 欧美日韩国产高清一区二区三区| 国产日本欧美一区二区| 蜜臀久久99精品久久久画质超高清| 成人黄色网址在线观看| 精品国产一区二区三区av性色| 伊人色综合久久天天| 国产成人免费视频一区| 欧美成人一区二区| 视频一区二区中文字幕| 99久久婷婷国产| 国产欧美一区视频| 国产在线精品免费| 精品电影一区二区| 免费观看91视频大全| 国产成人精品一区二区三区四区| 51精品秘密在线观看| 亚洲h动漫在线| 色先锋久久av资源部| 国产精品久久久99| 成人久久18免费网站麻豆| 久久久久久久久蜜桃| 精品在线一区二区三区| 欧美岛国在线观看| 精品一二三四区| 欧美成人伊人久久综合网| 蜜臀av一区二区三区| 777色狠狠一区二区三区| 五月天丁香久久| 欧美日韩五月天| 亚洲国产视频网站| 欧美日韩国产中文| 午夜激情综合网| 欧美一区二区日韩| 国产在线精品一区在线观看麻豆| 日韩欧美亚洲另类制服综合在线 | 欧美刺激午夜性久久久久久久|