/*
* @(#)CustomMonthViewUI.java
*
* Copyright (c) 2003-2004 Stand By Soft, Ltd. All rights reserved.
*
* This software is the proprietary information of Stand By Soft, Ltd.
* Use is subject to license terms.
*/
package com.standbysoft.demo.date.plaf;
import java.awt.Insets;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.ComponentUI;
import com.standbysoft.component.date.swing.plaf.basic.DefaultMonthViewUI;
/**
* <p>A UI delegate for <code>JMonthView</code> that customizes the buttons
* that scroll to the next and previous months.</p>
*
* <p>In order for all <code>JMonthView</code> components to use such a custom UI,
* one must register it in the system like this:</p>
*
* <pre>
* UIManager.put("MonthViewUI", CustomMonthViewUI.class.getName());
* </pre>
*
* <p>Whenever a new <code>JMonthView</code> is created it will use the specified UI delegate.</p>
*/
public class CustomMonthViewUI extends DefaultMonthViewUI {
/**
* Factory method that creates the actual UI delegate.
*/
public static ComponentUI createUI(JComponent c) {
return new CustomMonthViewUI();
}
/**
* Creates a button that scrolls to the previous month in the calendar.
*
* @return actual button
*/
protected JButton createPreviousMonthButton() {
JButton button = new JButton(new ImageIcon(getClass().getResource("/toolbarButtonGraphics/navigation/Back16.gif"))) {
//don't need to allow the button to gain focus
public boolean isFocusTraversable() {
return false;
}
};
button.setToolTipText("Scroll to previous month");
button.setContentAreaFilled(false);
button.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
return button;
}
/**
* Creates a button that scrolls to the next month in the calendar.
*
* @return actual button
*/
protected JButton createNextMonthButton() {
JButton button = new JButton(new ImageIcon(getClass().getResource("/toolbarButtonGraphics/navigation/Forward16.gif"))) {
//don't need to allow the button to gain focus
public boolean isFocusTraversable() {
return false;
}
};
button.setToolTipText("Scroll to next month");
button.setContentAreaFilled(false);
button.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
return button;
}
}
|