当前位置: 首页>>代码示例>>Java>>正文


Java JXMonthView类代码示例

本文整理汇总了Java中org.jdesktop.swingx.JXMonthView的典型用法代码示例。如果您正苦于以下问题:Java JXMonthView类的具体用法?Java JXMonthView怎么用?Java JXMonthView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JXMonthView类属于org.jdesktop.swingx包,在下文中一共展示了JXMonthView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addBasicDefaults

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void addBasicDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
    super.addBasicDefaults(addon, defaults);
    
    defaults.add(JXMonthView.uiClassID, "org.jdesktop.swingx.plaf.basic.BasicMonthViewUI");
    defaults.add("JXMonthView.background", new ColorUIResource(Color.WHITE));
    defaults.add("JXMonthView.monthStringBackground", new ColorUIResource(138, 173, 209));
    defaults.add("JXMonthView.monthStringForeground", new ColorUIResource(68, 68, 68));
    defaults.add("JXMonthView.daysOfTheWeekForeground", new ColorUIResource(68, 68, 68));
    defaults.add("JXMonthView.weekOfTheYearForeground", new ColorUIResource(68, 68, 68));
    defaults.add("JXMonthView.unselectableDayForeground", new ColorUIResource(Color.RED));
    defaults.add("JXMonthView.selectedBackground", new ColorUIResource(197, 220, 240));
    defaults.add("JXMonthView.flaggedDayForeground", new ColorUIResource(Color.RED));
    defaults.add("JXMonthView.leadingDayForeground", new ColorUIResource(Color.LIGHT_GRAY));
    defaults.add("JXMonthView.trailingDayForeground", new ColorUIResource(Color.LIGHT_GRAY));
    defaults.add("JXMonthView.font", UIManagerExt.getSafeFont("Button.font",
                    new FontUIResource("Dialog", Font.PLAIN, 12)));
    defaults.add("JXMonthView.monthDownFileName",
            LookAndFeel.makeIcon(MonthViewAddon.class, "basic/resources/month-down.png"));
    defaults.add("JXMonthView.monthUpFileName",
            LookAndFeel.makeIcon(MonthViewAddon.class, "basic/resources/month-up.png"));
    defaults.add("JXMonthView.boxPaddingX", 3);
    defaults.add("JXMonthView.boxPaddingY", 3);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:MonthViewAddon.java

示例2: installUI

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * Installs the component as appropriate for the current lf.
 * 
 * PENDING JW: clarify sequence of installXX methods. 
 */
@Override
public void installUI(JComponent c) {
    monthView = (JXMonthView)c;
    monthView.setLayout(createLayoutManager());
    
    // PENDING JW: move to installDefaults or installComponents?
    installRenderingHandler();
    
    installDefaults();
    installDelegate();
    installKeyboardActions();
    installComponents();
    updateLocale(false);
    updateZoomable();
    installListeners();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:22,代码来源:BasicMonthViewUI.java

示例3: updateLocale

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * Updates internal state according to monthView's locale. Revalidates the
 * monthView if the boolean parameter is true.
 * 
 * @param revalidate a boolean indicating whether the monthView should be 
 * revalidated after the change.
 */
protected void updateLocale(boolean revalidate) {
    Locale locale = monthView.getLocale();
    if (getRenderingHandler() != null) {
        getRenderingHandler().setLocale(locale);
    }

    // fixed JW: respect property in UIManager if available
    // PENDING JW: what to do if weekdays had been set
    // with JXMonthView method? how to detect?
    daysOfTheWeek = (String[]) UIManager.get("JXMonthView.daysOfTheWeek");

    if (daysOfTheWeek == null) {
        daysOfTheWeek = new String[7];
        String[] dateFormatSymbols = DateFormatSymbols.getInstance(locale)
                .getShortWeekdays();
        daysOfTheWeek = new String[JXMonthView.DAYS_IN_WEEK];
        for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
            daysOfTheWeek[i - 1] = dateFormatSymbols[i];
        }
    }
    if (revalidate) {
        monthView.invalidate();
        monthView.validate();
    }
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:33,代码来源:BasicMonthViewUI.java

示例4: getMonthGridPosition

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * Returns the logical grid position of the month containing the given date.
 * The Point's x value is the column in the grid of months, the y value
 * is the row in the grid of months.
 * 
 * Mapping Date to logical grid position, this is the reverse of getMonth(int, int).
 * 
 * @param date the Date to return the bounds for. Must not be null.
 * @return the postion of the month that contains the given date or null if not visible.
 * 
 * @see #getMonth(int, int)
 * @see #getMonthBounds(int, int)
 */
protected Point getMonthGridPosition(Date date) {
    if (!isVisible(date)) return null;
    // start of grid
    Calendar calendar = getCalendar();
    int firstMonth = calendar.get(Calendar.MONTH);
    int firstYear = calendar.get(Calendar.YEAR);
    
    // 
    calendar.setTime(date);
    int month = calendar.get(Calendar.MONTH);
    int year = calendar.get(Calendar.YEAR);
    
    int diffMonths = month - firstMonth
        + ((year - firstYear) * JXMonthView.MONTHS_IN_YEAR);
    
    int row = diffMonths / calendarColumnCount;
    int column = diffMonths % calendarColumnCount;

    return new Point(column, row);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:34,代码来源:BasicMonthViewUI.java

示例5: traverse

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
private void traverse(int action) {
    Date oldStart = monthView.isSelectionEmpty() ? 
            monthView.getToday() : monthView.getFirstSelectionDate();
    Calendar cal = getCalendar(oldStart);
    switch (action) {
        case SELECT_PREVIOUS_DAY:
            cal.add(Calendar.DAY_OF_MONTH, -1);
            break;
        case SELECT_NEXT_DAY:
            cal.add(Calendar.DAY_OF_MONTH, 1);
            break;
        case SELECT_DAY_PREVIOUS_WEEK:
            cal.add(Calendar.DAY_OF_MONTH, -JXMonthView.DAYS_IN_WEEK);
            break;
        case SELECT_DAY_NEXT_WEEK:
            cal.add(Calendar.DAY_OF_MONTH, JXMonthView.DAYS_IN_WEEK);
            break;
    }

    Date newStartDate = cal.getTime();
    if (!newStartDate.equals(oldStart)) {
        monthView.setSelectionInterval(newStartDate, newStartDate);
        monthView.ensureDateVisible(newStartDate);
    }
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:BasicMonthViewUI.java

示例6: mouseDragged

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
@Override
public void mouseDragged(MouseEvent ev) {
    if (!datePicker.isEnabled() || !datePicker.isEditable()) {
        return;
    }

    _forwardReleaseEvent = true;

    if (!popup.isShowing()) {
        return;
    }

    // Retarget mouse event to the month view.
    JXMonthView monthView = datePicker.getMonthView();
    ev = SwingUtilities.convertMouseEvent(popupButton, ev, monthView);
    monthView.dispatchEvent(ev);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:18,代码来源:BasicDatePickerUI.java

示例7: testLocaleByProviderMonthRendering

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
@Test
public void testLocaleByProviderMonthRendering() {
    Locale serbianLatin = getLocal("sh");
    if (serbianLatin == null) {
        LOG.fine("can't run, no service provider for serbian latin" );
        return;
    }
    JXMonthView monthView = new JXMonthView();
    monthView.setLocale(serbianLatin);
    Calendar calendar = monthView.getCalendar();
    int month = calendar.get(Calendar.MONTH);
    BasicMonthViewUI ui = (BasicMonthViewUI) monthView.getUI();
    CalendarRenderingHandler handler = ui.getRenderingHandler();
    JComponent component = handler.prepareRenderingComponent(monthView, 
            calendar, CalendarState.TITLE);
    
    String[] monthNames = DateFormatSymbols.getInstance(monthView.getLocale()).getMonths();
    String title = ((JLabel) component).getText();
    assertTrue("name must be taken from Locale, expected: " + monthNames[month] + " was: " + title, 
            title.startsWith(monthNames[month]));
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:BasicMonthViewUITest.java

示例8: testZoomableCustomHeader

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * Issue #77-swingx: support year-wise navigation.
 * Alleviate the problem by allowing custom calendar headers.
 * 
 * Here: test that the monthViewUI uses the custom header if available.
 */
@Test
public void testZoomableCustomHeader() {
    UIManager.put(CalendarHeaderHandler.uiControllerID, "org.jdesktop.swingx.plaf.basic.SpinningCalendarHeaderHandler");
    JXMonthView monthView = new JXMonthView();
    monthView.setZoomable(true);
    // digging into internals
    Container header = (Container) monthView.getComponent(0);
    if (header instanceof CellRendererPane) {
        header = (Container) monthView.getComponent(1);
    }
    try {
        assertTrue("expected SpinningCalendarHeader but was " + header.getClass(), header instanceof SpinningCalendarHeaderHandler.SpinningCalendarHeader);
    } finally {
        UIManager.put(CalendarHeaderHandler.uiControllerID, null);
    }
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:24,代码来源:BasicMonthViewUITest.java

示例9: testMonthHeaderBoundsAtLocation

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * coordinate mapping: monthBounds in pixel.
 * 
 */
@Test
public void testMonthHeaderBoundsAtLocation() {
    // This test will not work in a headless configuration.
    if (GraphicsEnvironment.isHeadless()) {
        LOG.fine("cannot run test - headless environment");
        return;
    }
    JXMonthView monthView = new JXMonthView();
    monthView.setTraversable(true);
    JXFrame frame = new JXFrame();
    frame.add(monthView);
    frame.pack();
    BasicMonthViewUI ui = (BasicMonthViewUI) monthView.getUI();
    Rectangle monthBoundsLToR = ui.getMonthHeaderBoundsAtLocation(20, 20);
    assertEquals("", ui.getMonthHeaderHeight(), monthBoundsLToR.height);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:21,代码来源:BasicMonthViewUITest.java

示例10: getRealizedMonthViewUI

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * Returns the ui of a realized JXMonthView with
 * given componentOrientation and showingWeekNumbers flag.
 * It's prefColumns/Rows are set to 2. The first displayedDate is 
 * 20. Feb. 2008 (to have fixed leading/trailing dates)
 * 
 * The frame is packed and it's size extended by 40, 40 to
 * give a slight off-position (!= 0) of the months shown. 
 * 
 * NOTE: this must not be used in a headless environment.
 * 
 * @param co the componentOrientation to use
 * @return
 */
private BasicMonthViewUI getRealizedMonthViewUI(ComponentOrientation co,
        boolean isShowingWeekNumbers) {
    JXMonthView monthView = new JXMonthView();
    monthView.setPreferredColumnCount(2);
    monthView.setPreferredRowCount(2);
    monthView.setComponentOrientation(co);
    monthView.setShowingWeekNumber(isShowingWeekNumbers);
    Calendar calendar = monthView.getCalendar();
    calendar.set(2008, Calendar.FEBRUARY, 20);
    monthView.setFirstDisplayedDay(calendar.getTime());
    JXFrame frame = new JXFrame();
    frame.add(monthView);
    frame.pack();
    frame.setSize(frame.getWidth() + 40, frame.getHeight() + 40);
    frame.setVisible(true);
    BasicMonthViewUI ui = (BasicMonthViewUI) monthView.getUI();
    return ui;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:33,代码来源:BasicMonthViewUITest.java

示例11: testGetDayAtLocation

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * cleanup date representation as long: new api getDayAtLocation. will
 * replace getDayAt which is deprecated as a first step.
 */
@Test
public void testGetDayAtLocation() {
    // This test will not work in a headless configuration.
    if (GraphicsEnvironment.isHeadless()) {
        LOG.fine("cannot run test - headless environment");
        return;
    }
    JXMonthView monthView = new JXMonthView();
    monthView.getSelectionModel().setMinimalDaysInFirstWeek(1);
    JXFrame frame = new JXFrame();
    frame.add(monthView);
    frame.pack();
    Dimension pref = monthView.getPreferredSize();
    pref.width = pref.width / 2;
    pref.height = pref.height / 2;
    Date date = monthView.getDayAtLocation(pref.width, pref.height);
    assertNotNull(date);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:BasicMonthViewUITest.java

示例12: getRealizedMonthViewUI

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * Returns the ui of a realized JXMonthView with
 * given componentOrientation and showingWeekNumbers flag.
 * It's prefColumns/Rows are set to 2. The first displayedDate is 
 * 20. Feb. 2008 (to have fixed leading/trailing dates)
 * 
 * The frame is packed and it's size extended by 40, 40 to
 * give a slight off-position (!= 0) of the months shown. 
 * 
 * 
 * 
 * NOTE: this must not be used in a headless environment.
 * 
 * @param co the componentOrientation to use
 * @return
 */
private BasicMonthViewUI getRealizedMonthViewUI(ComponentOrientation co,
        boolean isShowingWeekNumbers) {
    JXMonthView monthView = new JXMonthView();
    monthView.setPreferredColumnCount(2);
    monthView.setPreferredRowCount(2);
    monthView.setComponentOrientation(co);
    monthView.setShowingWeekNumber(isShowingWeekNumbers);
    Calendar calendar = monthView.getCalendar();
    calendar.set(2008, Calendar.FEBRUARY, 20);
    monthView.setFirstDisplayedDay(calendar.getTime());
    JXFrame frame = new JXFrame();
    frame.add(monthView);
    frame.pack();
    frame.setSize(frame.getWidth() + 40, frame.getHeight() + 40);
    frame.setVisible(true);
    BasicMonthViewUI ui = (BasicMonthViewUI) monthView.getUI();
    return ui;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:35,代码来源:BasicMonthViewUIIssues.java

示例13: interactiveRenderingOn

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
     * Issue #750-swingx: use rendering to side-step antialiase probs.
     * 
     * Debugging ...
     */
    public void interactiveRenderingOn() {
        new JXMonthView();
        // KEEP this is global state - uncomment for debug painting completely
//        // use spinning navigation header if zoomable
//        UIManager.put(CalendarHeaderHandler.uiControllerID, "org.jdesktop.swingx.plaf.basic.SpinningCalendarHeaderHandler");
//        // configure header: arrows around month text
//        UIManager.put(SpinningCalendarHeaderHandler.ARROWS_SURROUND_MONTH, Boolean.TRUE);
//        // configuter header: allow focus in spinner text (== editable)
//        UIManager.put(SpinningCalendarHeaderHandler.FOCUSABLE_SPINNER_TEXT, Boolean.TRUE);
//        // custom ui delegate for arabic digits in formats
//        UIManager.put(JXMonthView.uiClassID, "org.jdesktop.swingx.plaf.basic.BasicMonthViewUIVisualCheck$MyMonthViewUI");
//        // force picker to use a zoomable monthView by default
//        UIManager.put("JXDatePicker.forceZoomable", Boolean.TRUE);
        // KEEP this is global state - uncomment for debug painting completely
        UIManager.put("JXMonthView.trailingDayForeground", Color.YELLOW);
        UIManager.put("JXMonthView.leadingDayForeground", Color.ORANGE);
        UIManager.put("JXMonthView.weekOfTheYearForeground", Color.GREEN);
        UIManager.put("JXMonthView.unselectableDayForeground", Color.MAGENTA);
        String frameTitle = "Debug painting: rendering on";
        showDebugMonthView(frameTitle);
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:BasicMonthViewVisualCheck.java

示例14: createMonthViewDemo

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
private void createMonthViewDemo() {
    monthView = new JXMonthView();
    monthView.setName("monthView");
    
    // add to container which doesn't grow the size beyond the pref
    JComponent monthViewContainer = new JXPanel();
    monthViewContainer.add(monthView);
    
    JPanel monthViewControlPanel = new JXPanel();
    add(monthViewControlPanel, BorderLayout.SOUTH);

    FormLayout formLayout = new FormLayout(
            "f:m:g, l:4dlu:n, f:m:g", // columns
            "c:d:g, t:2dlu:n, t:d:n "
    ); // rows
    PanelBuilder builder = new PanelBuilder(formLayout, this);
    builder.setBorder(Borders.DLU4_BORDER);
    CellConstraints cc = new CellConstraints();
    
    builder.add(monthViewContainer, cc.xywh(1, 1, 3, 1));
    
    builder.add(createBoxPropertiesPanel(), cc.xywh(1, 3, 1, 1));
    builder.add(createConfigPanel(), cc.xywh(3, 3, 1, 1));
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:MonthViewDemo.java

示例15: installUI

import org.jdesktop.swingx.JXMonthView; //导入依赖的package包/类
/**
 * Installs the component as appropriate for the current lf.
 * 
 * PENDING JW: clarify sequence of installXX methods. 
 */
@Override
public void installUI(JComponent c) {
    monthView = (JXMonthView)c;
    monthView.setLayout(createLayoutManager());
    
    // PENDING JW: move to installDefaults or installComponents?
    installRenderingHandler();
    
    installDefaults();
    installDelegate();
    installComponents();
    installKeyboardActions();
    updateLocale(false);
    updateZoomable();
    installListeners();
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:22,代码来源:BasicMonthViewUI.java


注:本文中的org.jdesktop.swingx.JXMonthView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。