Tabnine Logo
DateChooserPanel
Code IndexAdd Tabnine to your IDE (free)

How to use
DateChooserPanel
in
org.jfree.ui

Best Java code snippets using org.jfree.ui.DateChooserPanel (Showing top 20 results out of 315)

origin: jfree/jcommon

/**
 * Defines the color for the buttons representing the current month.
 *
 * @param chosenMonthButtonColor the color for the current month.
 */
public void setChosenMonthButtonColor(final Color chosenMonthButtonColor) {
  if (chosenMonthButtonColor == null) {
    throw new NullPointerException("UIColor must not be null.");
  }
  final Color oldValue = this.chosenMonthButtonColor;
  this.chosenMonthButtonColor = chosenMonthButtonColor;
  refreshButtons();
  firePropertyChange("chosenMonthButtonColor", oldValue, 
      chosenMonthButtonColor);
}
origin: jfree/jcommon

/**
 * Update the button labels and colors to reflect date selection.
 */
private void refreshButtons() {
  final Calendar c = getFirstVisibleDate();
  for (int i = 0; i < 42; i++) {
    final JButton b = this.buttons[i];
    b.setText(Integer.toString(c.get(Calendar.DATE)));
    b.setBackground(getButtonColor(c));
    c.add(Calendar.DATE, 1);
  }
}
origin: jfree/jcommon

  /**
   * Sets the range of years available for selection.
   * 
   * @param yearSelectionRange  the range.
   */
  public void setYearSelectionRange(final int yearSelectionRange) {
    final int oldYearSelectionRange = this.yearSelectionRange;
    this.yearSelectionRange = yearSelectionRange;
    refreshYearSelector();
    firePropertyChange("yearSelectionRange", oldYearSelectionRange, 
        yearSelectionRange);
  }
}
origin: jfree/jcommon

/**
 * Constructs a new date chooser panel.
 *
 * @param calendar     the calendar controlling the date.
 * @param controlPanel a flag that indicates whether or not the 'today' 
 *                     button should appear on the panel.
 */
public DateChooserPanel(final Calendar calendar, 
            final boolean controlPanel) {
  super(new BorderLayout());
  this.chosenDateButtonColor = UIManager.getColor("textHighlight");
  this.chosenMonthButtonColor = UIManager.getColor("control");
  this.chosenOtherButtonColor = UIManager.getColor("controlShadow");
  // the default date is today...
  this.chosenDate = calendar;
  this.firstDayOfWeek = calendar.getFirstDayOfWeek();
  this.WEEK_DAYS = new int[7];
  for (int i = 0; i < 7; i++) {
    this.WEEK_DAYS[i] = ((this.firstDayOfWeek + i - 1) % 7) + 1;
  }
  add(constructSelectionPanel(), BorderLayout.NORTH);
  add(getCalendarPanel(), BorderLayout.CENTER);
  if (controlPanel) {
    add(constructControlPanel(), BorderLayout.SOUTH);
  }
  setDate(calendar.getTime());
}
origin: jfree/jcommon

this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
    maxDayOfMonth));
refreshButtons();
  this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
    maxDayOfMonth));
  refreshYearSelector();
  refreshButtons();
setDate(new Date());
final Calendar cal = getFirstVisibleDate();
cal.add(Calendar.DATE, i);
setDate(cal.getTime());
origin: jfree/jcommon

/**
 * Changes the contents of the year selection JComboBox to reflect the 
 * chosen date and the year range.
 */
private void refreshYearSelector() {
  if (!this.refreshing) {
    this.refreshing = true;
    this.yearSelector.removeAllItems();
    final Integer[] years = getYears(this.chosenDate.get(
        Calendar.YEAR));
    for (int i = 0; i < years.length; i++) {
      this.yearSelector.addItem(years[i]);
    }
    this.yearSelector.setSelectedItem(new Integer(this.chosenDate.get(
        Calendar.YEAR)));
    this.refreshing = false;
  }
}
origin: jfree/jcommon

/**
 * Returns the first date that is visible in the grid.  This should always 
 * be in the month preceding the month of the selected date.
 *
 * @return the date.
 */
private Calendar getFirstVisibleDate() {
  final Calendar c = Calendar.getInstance();
  c.set(this.chosenDate.get(Calendar.YEAR), this.chosenDate.get(
      Calendar.MONTH), 1);
  c.add(Calendar.DATE, -1);
  while (c.get(Calendar.DAY_OF_WEEK) != getFirstDayOfWeek()) {
    c.add(Calendar.DATE, -1);
  }
  return c;
}
origin: org.jfree/com.springsource.org.jfree

/**
 * Returns the button color according to the specified date.
 *
 * @param theDate the date.
 * @return the color.
 */
private Color getButtonColor(final Calendar theDate) {
  if (equalDates(theDate, this.chosenDate)) {
    return this.chosenDateButtonColor;
  }
  else if (theDate.get(Calendar.MONTH) == this.chosenDate.get(
      Calendar.MONTH)) {
    return this.chosenMonthButtonColor;
  }
  else {
    return this.chosenOtherButtonColor;
  }
}
origin: org.jfree/jcommon

/**
 * Constructs a new date chooser panel.
 *
 * @param calendar     the calendar controlling the date.
 * @param controlPanel a flag that indicates whether or not the 'today' 
 *                     button should appear on the panel.
 */
public DateChooserPanel(final Calendar calendar, 
            final boolean controlPanel) {
  super(new BorderLayout());
  this.chosenDateButtonColor = UIManager.getColor("textHighlight");
  this.chosenMonthButtonColor = UIManager.getColor("control");
  this.chosenOtherButtonColor = UIManager.getColor("controlShadow");
  // the default date is today...
  this.chosenDate = calendar;
  this.firstDayOfWeek = calendar.getFirstDayOfWeek();
  this.WEEK_DAYS = new int[7];
  for (int i = 0; i < 7; i++) {
    this.WEEK_DAYS[i] = ((this.firstDayOfWeek + i - 1) % 7) + 1;
  }
  add(constructSelectionPanel(), BorderLayout.NORTH);
  add(getCalendarPanel(), BorderLayout.CENTER);
  if (controlPanel) {
    add(constructControlPanel(), BorderLayout.SOUTH);
  }
  setDate(calendar.getTime());
}
origin: org.jfree/jcommon

this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
    maxDayOfMonth));
refreshButtons();
  this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
    maxDayOfMonth));
  refreshYearSelector();
  refreshButtons();
setDate(new Date());
final Calendar cal = getFirstVisibleDate();
cal.add(Calendar.DATE, i);
setDate(cal.getTime());
origin: org.jfree/jcommon

  /**
   * Sets the range of years available for selection.
   * 
   * @param yearSelectionRange  the range.
   */
  public void setYearSelectionRange(final int yearSelectionRange) {
    final int oldYearSelectionRange = this.yearSelectionRange;
    this.yearSelectionRange = yearSelectionRange;
    refreshYearSelector();
    firePropertyChange("yearSelectionRange", oldYearSelectionRange, 
        yearSelectionRange);
  }
}
origin: org.jfree/com.springsource.org.jfree

/**
 * Changes the contents of the year selection JComboBox to reflect the 
 * chosen date and the year range.
 */
private void refreshYearSelector() {
  if (!this.refreshing) {
    this.refreshing = true;
    this.yearSelector.removeAllItems();
    final Integer[] years = getYears(this.chosenDate.get(
        Calendar.YEAR));
    for (int i = 0; i < years.length; i++) {
      this.yearSelector.addItem(years[i]);
    }
    this.yearSelector.setSelectedItem(new Integer(this.chosenDate.get(
        Calendar.YEAR)));
    this.refreshing = false;
  }
}
origin: org.jfree/com.springsource.org.jfree

/**
 * Returns the first date that is visible in the grid.  This should always 
 * be in the month preceding the month of the selected date.
 *
 * @return the date.
 */
private Calendar getFirstVisibleDate() {
  final Calendar c = Calendar.getInstance();
  c.set(this.chosenDate.get(Calendar.YEAR), this.chosenDate.get(
      Calendar.MONTH), 1);
  c.add(Calendar.DATE, -1);
  while (c.get(Calendar.DAY_OF_WEEK) != getFirstDayOfWeek()) {
    c.add(Calendar.DATE, -1);
  }
  return c;
}
origin: jfree/jcommon

/**
 * Returns the button color according to the specified date.
 *
 * @param theDate the date.
 * @return the color.
 */
private Color getButtonColor(final Calendar theDate) {
  if (equalDates(theDate, this.chosenDate)) {
    return this.chosenDateButtonColor;
  }
  else if (theDate.get(Calendar.MONTH) == this.chosenDate.get(
      Calendar.MONTH)) {
    return this.chosenMonthButtonColor;
  }
  else {
    return this.chosenOtherButtonColor;
  }
}
origin: org.jfree/com.springsource.org.jfree

/**
 * Constructs a new date chooser panel.
 *
 * @param calendar     the calendar controlling the date.
 * @param controlPanel a flag that indicates whether or not the 'today' 
 *                     button should appear on the panel.
 */
public DateChooserPanel(final Calendar calendar, 
            final boolean controlPanel) {
  super(new BorderLayout());
  this.chosenDateButtonColor = UIManager.getColor("textHighlight");
  this.chosenMonthButtonColor = UIManager.getColor("control");
  this.chosenOtherButtonColor = UIManager.getColor("controlShadow");
  // the default date is today...
  this.chosenDate = calendar;
  this.firstDayOfWeek = calendar.getFirstDayOfWeek();
  this.WEEK_DAYS = new int[7];
  for (int i = 0; i < 7; i++) {
    this.WEEK_DAYS[i] = ((this.firstDayOfWeek + i - 1) % 7) + 1;
  }
  add(constructSelectionPanel(), BorderLayout.NORTH);
  add(getCalendarPanel(), BorderLayout.CENTER);
  if (controlPanel) {
    add(constructControlPanel(), BorderLayout.SOUTH);
  }
  setDate(calendar.getTime());
}
origin: org.jfree/com.springsource.org.jfree

this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
    maxDayOfMonth));
refreshButtons();
  this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
    maxDayOfMonth));
  refreshYearSelector();
  refreshButtons();
setDate(new Date());
final Calendar cal = getFirstVisibleDate();
cal.add(Calendar.DATE, i);
setDate(cal.getTime());
origin: org.jfree/jcommon

/**
 * Redefines the color for the buttons representing the other months.
 *
 * @param chosenOtherButtonColor a color.
 */
public void setChosenOtherButtonColor(final Color chosenOtherButtonColor) {
  if (chosenOtherButtonColor == null) {
    throw new NullPointerException("UIColor must not be null.");
  }
  final Color oldValue = this.chosenOtherButtonColor;
  this.chosenOtherButtonColor = chosenOtherButtonColor;
  refreshButtons();
  firePropertyChange("chosenOtherButtonColor", oldValue, 
      chosenOtherButtonColor);
}
origin: org.jfree/com.springsource.org.jfree

/**
 * Update the button labels and colors to reflect date selection.
 */
private void refreshButtons() {
  final Calendar c = getFirstVisibleDate();
  for (int i = 0; i < 42; i++) {
    final JButton b = this.buttons[i];
    b.setText(Integer.toString(c.get(Calendar.DATE)));
    b.setBackground(getButtonColor(c));
    c.add(Calendar.DATE, 1);
  }
}
origin: org.jfree/com.springsource.org.jfree

  /**
   * Sets the range of years available for selection.
   * 
   * @param yearSelectionRange  the range.
   */
  public void setYearSelectionRange(final int yearSelectionRange) {
    final int oldYearSelectionRange = this.yearSelectionRange;
    this.yearSelectionRange = yearSelectionRange;
    refreshYearSelector();
    firePropertyChange("yearSelectionRange", oldYearSelectionRange, 
        yearSelectionRange);
  }
}
origin: org.jfree/jcommon

/**
 * Changes the contents of the year selection JComboBox to reflect the 
 * chosen date and the year range.
 */
private void refreshYearSelector() {
  if (!this.refreshing) {
    this.refreshing = true;
    this.yearSelector.removeAllItems();
    final Integer[] years = getYears(this.chosenDate.get(
        Calendar.YEAR));
    for (int i = 0; i < years.length; i++) {
      this.yearSelector.addItem(years[i]);
    }
    this.yearSelector.setSelectedItem(new Integer(this.chosenDate.get(
        Calendar.YEAR)));
    this.refreshing = false;
  }
}
org.jfree.uiDateChooserPanel

Javadoc

A panel that allows the user to select a date.

Most used methods

  • add
  • constructControlPanel
    Returns a panel that appears at the bottom of the calendar panel - contains a button for selecting t
  • constructSelectionPanel
    Constructs a panel containing two JComboBoxes (for the month and year) and a button (to reset the da
  • equalDates
    Returns true if the two dates are equal (time of day is ignored).
  • firePropertyChange
  • getButtonColor
    Returns the button color according to the specified date.
  • getCalendarPanel
    Returns a panel of buttons, each button representing a day in the month. This is a sub-component of
  • getFirstDayOfWeek
    Returns the first day of the week (controls the labels in the date panel).
  • getFirstVisibleDate
    Returns the first date that is visible in the grid. This should always be in the month preceding the
  • getYears
    Returns a vector of years preceding and following the specified year. The number of years preceding
  • refreshButtons
    Update the button labels and colors to reflect date selection.
  • refreshYearSelector
    Changes the contents of the year selection JComboBox to reflect the chosen date and the year range.
  • refreshButtons,
  • refreshYearSelector,
  • setDate,
  • <init>

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now