⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jxmonthview.java

📁 java实现浏览器等本地桌面的功能
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     *     * @return Single character representation for the days of the week     */    public String[] getDaysOfTheWeek() {        String[] days = new String[DAYS_IN_WEEK];        System.arraycopy(_daysOfTheWeek, 0, days, 0, DAYS_IN_WEEK);        return days;    }    /**     * Gets what the first day of the week is; e.g.,     * <code>Calendar.SUNDAY</code> in the U.S., <code>Calendar.MONDAY</code>     * in France.     *     * @return int The first day of the week.     */    public int getFirstDayOfWeek() {        return _firstDayOfWeek;    }    /**     * Sets what the first day of the week is; e.g.,     * <code>Calendar.SUNDAY</code> in US, <code>Calendar.MONDAY</code>     * in France.     *     * @param firstDayOfWeek The first day of the week.     *     * @see java.util.Calendar     */    public void setFirstDayOfWeek(int firstDayOfWeek) {        if (firstDayOfWeek == _firstDayOfWeek) {            return;        }        _firstDayOfWeek = firstDayOfWeek;        _cal.setFirstDayOfWeek(_firstDayOfWeek);        repaint();    }    /**     * Gets the time zone.     *     * @return The <code>TimeZone</code> used by the <code>JXMonthView</code>.     */    public TimeZone getTimeZone() {        return _cal.getTimeZone();    }    /**     * Sets the time zone with the given time zone value.     *     * @param tz The <code>TimeZone</code>.     */    public void setTimeZone(TimeZone tz) {        _cal.setTimeZone(tz);    }    /**     * Returns true if anti-aliased text is enabled for this component, false     * otherwise.     *     * @return boolean <code>true</code> if anti-aliased text is enabled,     * <code>false</code> otherwise.     */    public boolean getAntialiased() {        return _antiAlias;    }    /**     * Turns on/off anti-aliased text for this component.     *     * @param antiAlias <code>true</code> for anti-aliased text,     * <code>false</code> to turn it off.     */    public void setAntialiased(boolean antiAlias) {        if (_antiAlias == antiAlias) {            return;        }        _antiAlias = antiAlias;        repaint();    }    /**    public void setDropShadowMask(int mask) {        _dropShadowMask = mask;        repaint();    }    */    /**     * Returns the selected background color.     *     * @return the selected background color.     */    public Color getSelectedBackground() {        return _selectedBackground;    }    /**     * Sets the selected background color to <code>c</code>.  The default color     * is <code>138, 173, 209 (Blue-ish)</code>     *     * @param c Selected background.     */    public void setSelectedBackground(Color c) {        _selectedBackground = c;    }    /**     * Returns the color used when painting the today background.     *     * @return Color Color     */    public Color getTodayBackground() {        return _todayBackgroundColor;    }    /**     * Sets the color used to draw the bounding box around today.  The default     * is the background of the <code>JXMonthView</code> component.     *      * @param c color to set     */    public void setTodayBackground(Color c) {        _todayBackgroundColor = c;        repaint();    }    /**     * Returns the color used to paint the month string background.     *     * @return Color Color.     */    public Color getMonthStringBackground() {        return _monthStringBackground;    }    /**     * Sets the color used to draw the background of the month string.  The     * default is <code>138, 173, 209 (Blue-ish)</code>.     *     * @param c color to set     */    public void setMonthStringBackground(Color c) {        _monthStringBackground = c;        repaint();    }    /**     * Returns the color used to paint the month string foreground.     *     * @return Color Color.     */    public Color getMonthStringForeground() {        return _monthStringForeground;    }    /**     * Sets the color used to draw the foreground of the month string.  The     * default is <code>Color.WHITE</code>.     *     * @param c color to set     */    public void setMonthStringForeground(Color c) {        _monthStringForeground = c;        repaint();    }    /**     * Sets the color used to draw the foreground of each day of the week. These     * are the titles     *     * @param c color to set     */    public void setDaysOfTheWeekForeground(Color c) {        _daysOfTheWeekForeground = c;        repaint();    }        /**     * @return Color Color     */    public Color getDaysOfTheWeekForeground() {        return _daysOfTheWeekForeground;    }    /**     * Set the color to be used for painting the specified day of the week.     * Acceptable values are Calendar.SUNDAY - Calendar.SATURDAY.     *     * @param dayOfWeek constant value defining the day of the week.     * @param c The color to be used for painting the numeric day of the week.     */    public void setDayForeground(int dayOfWeek, Color c) {        _dayToColorTable.put(dayOfWeek, c);    }    /**     * Return the color that should be used for painting the numerical day of the week.     *     * @param dayOfWeek The day of week to get the color for.     * @return The color to be used for painting the numeric day of the week.     *    If this was no color has yet been defined the component foreground color     *    will be returned.     */    public Color getDayForeground(int dayOfWeek) {        Color c;        c = (Color)_dayToColorTable.get(dayOfWeek);        if (c == null) {            c = getForeground();        }        return c;    }    /**     * Returns a copy of the insets used to paint the month string background.     *     * @return Insets Month string insets.     */    public Insets getMonthStringInsets() {        return (Insets)_monthStringInsets.clone();    }    /**     * Insets used to modify the width/height when painting the background     * of the month string area.     *     * @param insets Insets     */    public void setMonthStringInsets(Insets insets) {        if (insets == null) {            _monthStringInsets.top = 0;            _monthStringInsets.left = 0;            _monthStringInsets.bottom = 0;            _monthStringInsets.right = 0;        } else {            _monthStringInsets.top = insets.top;            _monthStringInsets.left = insets.left;            _monthStringInsets.bottom = insets.bottom;            _monthStringInsets.right = insets.right;        }        repaint();    }    /**     * Returns the preferred number of columns to paint calendars in.     *     * @return int Columns of calendars.     */    public int getPreferredCols() {        return _minCalCols;    }    /**     * The preferred number of columns to paint calendars.     *     * @param cols The number of columns of calendars.     */    public void setPreferredCols(int cols) {        if (cols <= 0) {            return;        }        _minCalCols = cols;        _dirty = true;        revalidate();        repaint();    }    /**     * Returns the preferred number of rows to paint calendars in.     *     * @return int Rows of calendars.     */    public int getPreferredRows() {        return _minCalRows;    }    /**     * Sets the preferred number of rows to paint calendars.     *     * @param rows The number of rows of calendars.     */    public void setPreferredRows(int rows) {        if (rows <= 0) {            return;        }        _minCalRows = rows;        _dirty = true;        revalidate();        repaint();    }    private void updateIfNecessary() {        if (_dirty) {            update();            _dirty = false;        }    }    /**     * Calculates size information necessary for laying out the month view.     */    private void update() {        // Loop through year and get largest representation of the month.        // Keep track of the longest month so we can loop through it to        // determine the width of a date box.        int currDays;        int longestMonth = 0;        int daysInLongestMonth = 0;        int currWidth;        int longestMonthWidth = 0;        // We use a bold font for figuring out size constraints since        // it's larger and flaggedDates will be noted in this style.        _derivedFont = getFont().deriveFont(Font.BOLD);        FontMetrics fm = getFontMetrics(_derivedFont);        _cal.set(Calendar.MONTH, _cal.getMinimum(Calendar.MONTH));        _cal.set(Calendar.DAY_OF_MONTH,                _cal.getActualMinimum(Calendar.DAY_OF_MONTH));        for (int i = 0; i < _cal.getMaximum(Calendar.MONTH); i++) {            currWidth = fm.stringWidth(_monthsOfTheYear[i]);            if (currWidth > longestMonthWidth) {                longestMonthWidth = currWidth;            }            currDays = _cal.getActualMaximum(Calendar.DAY_OF_MONTH);            if (currDays > daysInLongestMonth) {                longestMonth = _cal.get(Calendar.MONTH);                daysInLongestMonth = currDays;            }            _cal.add(Calendar.MONTH, 1);        }        // Loop through the days of the week and adjust the box width        // accordingly.        _boxHeight = fm.getHeight();        for (String dayOfTheWeek : _daysOfTheWeek) {            currWidth = fm.stringWidth(dayOfTheWeek);            if (currWidth > _boxWidth) {                _boxWidth = currWidth;            }        }        // Loop through longest month and get largest representation of the day        // of the month.        _cal.set(Calendar.MONTH, longestMonth);        _cal.set(Calendar.DAY_OF_MONTH,                _cal.getActualMinimum(Calendar.DAY_OF_MONTH));        for (int i = 0; i < daysInLongestMonth; i++) {            currWidth = fm.stringWidth(                    _dayOfMonthFormatter.format(_cal.getTime()));            if (currWidth > _boxWidth) {                _boxWidth = currWidth;            }            _cal.add(Calendar.DAY_OF_MONTH, 1);        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -