提交 49d9d970 编写于 作者: P peterz

6827653: Make Synth UI classes public

Reviewed-by: alexp
上级 8dc74913
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
*/ */
package com.sun.java.swing.plaf.gtk; package com.sun.java.swing.plaf.gtk;
import sun.swing.plaf.synth.SynthUI;
import sun.awt.UNIXToolkit; import sun.awt.UNIXToolkit;
import javax.swing.plaf.synth.*; import javax.swing.plaf.synth.*;
......
...@@ -60,13 +60,13 @@ public abstract class ComponentUI { ...@@ -60,13 +60,13 @@ public abstract class ComponentUI {
} }
/** /**
* Configures the specified component appropriate for the look and feel. * Configures the specified component appropriately for the look and feel.
* This method is invoked when the <code>ComponentUI</code> instance is being installed * This method is invoked when the <code>ComponentUI</code> instance is being installed
* as the UI delegate on the specified component. This method should * as the UI delegate on the specified component. This method should
* completely configure the component for the look and feel, * completely configure the component for the look and feel,
* including the following: * including the following:
* <ol> * <ol>
* <li>Install any default property values for color, fonts, borders, * <li>Install default property values for color, fonts, borders,
* icons, opacity, etc. on the component. Whenever possible, * icons, opacity, etc. on the component. Whenever possible,
* property values initialized by the client program should <i>not</i> * property values initialized by the client program should <i>not</i>
* be overridden. * be overridden.
...@@ -116,7 +116,7 @@ public abstract class ComponentUI { ...@@ -116,7 +116,7 @@ public abstract class ComponentUI {
} }
/** /**
* Paints the specified component appropriate for the look and feel. * Paints the specified component appropriately for the look and feel.
* This method is invoked from the <code>ComponentUI.update</code> method when * This method is invoked from the <code>ComponentUI.update</code> method when
* the specified component is being painted. Subclasses should override * the specified component is being painted. Subclasses should override
* this method and use the specified <code>Graphics</code> object to * this method and use the specified <code>Graphics</code> object to
...@@ -134,15 +134,15 @@ public abstract class ComponentUI { ...@@ -134,15 +134,15 @@ public abstract class ComponentUI {
} }
/** /**
* Notifies this UI delegate that it's time to paint the specified * Notifies this UI delegate that it is time to paint the specified
* component. This method is invoked by <code>JComponent</code> * component. This method is invoked by <code>JComponent</code>
* when the specified component is being painted. * when the specified component is being painted.
* By default this method will fill the specified component with *
* its background color (if its <code>opaque</code> property is * <p>By default this method fills the specified component with
* <code>true</code>) and then immediately call <code>paint</code>. * its background color if its {@code opaque} property is {@code true},
* In general this method need not be overridden by subclasses; * and then immediately calls {@code paint}. In general this method need
* all look-and-feel rendering code should reside in the <code>paint</code> * not be overridden by subclasses; all look-and-feel rendering code should
* method. * reside in the {@code paint} method.
* *
* @param g the <code>Graphics</code> context in which to paint * @param g the <code>Graphics</code> context in which to paint
* @param c the component being painted; * @param c the component being painted;
......
...@@ -24,14 +24,10 @@ ...@@ -24,14 +24,10 @@
*/ */
package javax.swing.plaf.basic; package javax.swing.plaf.basic;
import javax.swing.*; import javax.swing.ComboBoxEditor;
import javax.swing.JTextField;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.Component;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -73,12 +69,17 @@ public class BasicComboBoxEditor implements ComboBoxEditor,FocusListener { ...@@ -73,12 +69,17 @@ public class BasicComboBoxEditor implements ComboBoxEditor,FocusListener {
* @param anObject the displayed value of the editor * @param anObject the displayed value of the editor
*/ */
public void setItem(Object anObject) { public void setItem(Object anObject) {
if ( anObject != null ) { String text;
editor.setText(anObject.toString());
if ( anObject != null ) {
text = anObject.toString();
oldValue = anObject; oldValue = anObject;
} else { } else {
editor.setText(""); text = "";
}
// workaround for 4530952
if (! text.equals(editor.getText())) {
editor.setText(text);
} }
} }
......
...@@ -30,7 +30,6 @@ import java.awt.event.*; ...@@ -30,7 +30,6 @@ import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.accessibility.*; import javax.accessibility.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.border.*;
import javax.swing.text.*; import javax.swing.text.*;
import javax.swing.event.*; import javax.swing.event.*;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
...@@ -189,19 +188,20 @@ public class BasicComboBoxUI extends ComboBoxUI { ...@@ -189,19 +188,20 @@ public class BasicComboBoxUI extends ComboBoxUI {
/** /**
* Indicates whether or not the combo box button should be square. * Indicates whether or not the combo box button should be square.
* If square, then the width and height are equal, and are both set to * If square, then the width and height are equal, and are both set to
* the height of the combo (minus appropriate insets). * the height of the combo minus appropriate insets.
*
* @since 1.7
*/ */
private boolean squareButton = true; protected boolean squareButton = true;
/** /**
* Optional: if specified, these insets act as padding around the cell * If specified, these insets act as padding around the cell renderer when
* renderer when laying out and painting the "selected" item in the * laying out and painting the "selected" item in the combo box. These
* combo box. BasicComboBoxUI uses a single combo box renderer for rendering * insets add to those specified by the cell renderer.
* both the main combo box item and also all the items in the dropdown *
* for the combo box. padding allows you to specify addition insets in * @since 1.7
* addition to those specified by the cell renderer.
*/ */
private Insets padding; protected Insets padding;
// Used for calculating the default size. // Used for calculating the default size.
private static ListCellRenderer getDefaultListCellRenderer() { private static ListCellRenderer getDefaultListCellRenderer() {
...@@ -345,7 +345,7 @@ public class BasicComboBoxUI extends ComboBoxUI { ...@@ -345,7 +345,7 @@ public class BasicComboBoxUI extends ComboBoxUI {
} }
/** /**
* Create and install the listeners for the combo box and its model. * Creates and installs listeners for the combo box and its model.
* This method is called when the UI is installed. * This method is called when the UI is installed.
*/ */
protected void installListeners() { protected void installListeners() {
...@@ -379,8 +379,8 @@ public class BasicComboBoxUI extends ComboBoxUI { ...@@ -379,8 +379,8 @@ public class BasicComboBoxUI extends ComboBoxUI {
} }
/** /**
* Uninstalls the default colors, default font, default renderer, and default * Uninstalls the default colors, default font, default renderer,
* editor into the JComboBox. * and default editor from the combo box.
*/ */
protected void uninstallDefaults() { protected void uninstallDefaults() {
LookAndFeel.installColorsAndFont( comboBox, LookAndFeel.installColorsAndFont( comboBox,
...@@ -391,7 +391,7 @@ public class BasicComboBoxUI extends ComboBoxUI { ...@@ -391,7 +391,7 @@ public class BasicComboBoxUI extends ComboBoxUI {
} }
/** /**
* Remove the installed listeners from the combo box and its model. * Removes the installed listeners from the combo box and its model.
* The number and types of listeners removed and in this method should be * The number and types of listeners removed and in this method should be
* the same that was added in <code>installListeners</code> * the same that was added in <code>installListeners</code>
*/ */
...@@ -839,7 +839,7 @@ public class BasicComboBoxUI extends ComboBoxUI { ...@@ -839,7 +839,7 @@ public class BasicComboBoxUI extends ComboBoxUI {
} }
/** /**
* Creates an button which will be used as the control to show or hide * Creates a button which will be used as the control to show or hide
* the popup portion of the combo box. * the popup portion of the combo box.
* *
* @return a button which represents the popup control * @return a button which represents the popup control
...@@ -1392,12 +1392,17 @@ public class BasicComboBoxUI extends ComboBoxUI { ...@@ -1392,12 +1392,17 @@ public class BasicComboBoxUI extends ComboBoxUI {
} }
/** /**
* This has been refactored out in hopes that it may be investigated and * Returns the size a component would have if used as a cell renderer.
* simplified for the next major release. adding/removing *
* the component to the currentValuePane and changing the font may be * @param comp a {@code Component} to check
* redundant operations. * @return size of the component
*/ * @since 1.7
private Dimension getSizeForComponent(Component comp) { */
protected Dimension getSizeForComponent(Component comp) {
// This has been refactored out in hopes that it may be investigated and
// simplified for the next major release. adding/removing
// the component to the currentValuePane and changing the font may be
// redundant operations.
currentValuePane.add(comp); currentValuePane.add(comp);
comp.setFont(comboBox.getFont()); comp.setFont(comboBox.getFont());
Dimension d = comp.getPreferredSize(); Dimension d = comp.getPreferredSize();
......
...@@ -141,11 +141,10 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener ...@@ -141,11 +141,10 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
} }
/** /**
* Paint the label text in the foreground color, if the label * Paints the label text with the foreground color, if the label is opaque
* is opaque then paint the entire background with the background * then paints the entire background with the background color. The Label
* color. The Label text is drawn by paintEnabledText() or * text is drawn by {@link #paintEnabledText} or {@link #paintDisabledText}.
* paintDisabledText(). The locations of the label parts are computed * The locations of the label parts are computed by {@link #layoutCL}.
* by layoutCL.
* *
* @see #paintEnabledText * @see #paintEnabledText
* @see #paintDisabledText * @see #paintDisabledText
......
...@@ -685,7 +685,7 @@ public class BasicListUI extends ListUI ...@@ -685,7 +685,7 @@ public class BasicListUI extends ListUI
/** /**
* Create and install the listeners for the JList, its model, and its * Creates and installs the listeners for the JList, its model, and its
* selectionModel. This method is called at installUI() time. * selectionModel. This method is called at installUI() time.
* *
* @see #installUI * @see #installUI
...@@ -728,7 +728,7 @@ public class BasicListUI extends ListUI ...@@ -728,7 +728,7 @@ public class BasicListUI extends ListUI
/** /**
* Remove the listeners for the JList, its model, and its * Removes the listeners from the JList, its model, and its
* selectionModel. All of the listener fields, are reset to * selectionModel. All of the listener fields, are reset to
* null here. This method is called at uninstallUI() time, * null here. This method is called at uninstallUI() time,
* it should be kept in sync with installListeners. * it should be kept in sync with installListeners.
...@@ -764,8 +764,8 @@ public class BasicListUI extends ListUI ...@@ -764,8 +764,8 @@ public class BasicListUI extends ListUI
/** /**
* Initialize JList properties, e.g. font, foreground, and background, * Initializes list properties such as font, foreground, and background,
* and add the CellRendererPane. The font, foreground, and background * and adds the CellRendererPane. The font, foreground, and background
* properties are only set if their current value is either null * properties are only set if their current value is either null
* or a UIResource, other properties are set if the current * or a UIResource, other properties are set if the current
* value is null. * value is null.
...@@ -820,9 +820,9 @@ public class BasicListUI extends ListUI ...@@ -820,9 +820,9 @@ public class BasicListUI extends ListUI
/** /**
* Set the JList properties that haven't been explicitly overridden to * Sets the list properties that have not been explicitly overridden to
* null. A property is considered overridden if its current value * {@code null}. A property is considered overridden if its current value
* is not a UIResource. * is not a {@code UIResource}.
* *
* @see #installDefaults * @see #installDefaults
* @see #uninstallUI * @see #uninstallUI
......
...@@ -32,7 +32,6 @@ import java.beans.PropertyChangeListener; ...@@ -32,7 +32,6 @@ import java.beans.PropertyChangeListener;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.text.View; import javax.swing.text.View;
...@@ -54,7 +53,12 @@ public class BasicMenuItemUI extends MenuItemUI ...@@ -54,7 +53,12 @@ public class BasicMenuItemUI extends MenuItemUI
protected Color disabledForeground; protected Color disabledForeground;
protected Color acceleratorForeground; protected Color acceleratorForeground;
protected Color acceleratorSelectionForeground; protected Color acceleratorSelectionForeground;
private String acceleratorDelimiter;
/**
* Accelerator delimiter string, such as {@code '+'} in {@code 'Ctrl+C'}.
* @since 1.7
*/
protected String acceleratorDelimiter;
protected int defaultTextIconGap; protected int defaultTextIconGap;
protected Font acceleratorFont; protected Font acceleratorFont;
......
...@@ -93,10 +93,13 @@ public class BasicScrollBarUI ...@@ -93,10 +93,13 @@ public class BasicScrollBarUI
* scrollbar. */ * scrollbar. */
private boolean supportsAbsolutePositioning; private boolean supportsAbsolutePositioning;
/** Hint as to what width (when vertical) or height (when horizontal) /**
* Hint as to what width (when vertical) or height (when horizontal)
* should be. * should be.
*
* @since 1.7
*/ */
private int scrollBarWidth; protected int scrollBarWidth;
private Handler handler; private Handler handler;
...@@ -117,18 +120,18 @@ public class BasicScrollBarUI ...@@ -117,18 +120,18 @@ public class BasicScrollBarUI
* number. If negative, then an overlap between the button and track will occur, * number. If negative, then an overlap between the button and track will occur,
* which is useful for shaped buttons. * which is useful for shaped buttons.
* *
* TODO This should be made protected in a feature release * @since 1.7
*/ */
private int incrGap; protected int incrGap;
/** /**
* Distance between the decrement button and the track. This may be a negative * Distance between the decrement button and the track. This may be a negative
* number. If negative, then an overlap between the button and track will occur, * number. If negative, then an overlap between the button and track will occur,
* which is useful for shaped buttons. * which is useful for shaped buttons.
* *
* TODO This should be made protected in a feature release * @since 1.7
*/ */
private int decrGap; protected int decrGap;
static void loadActionMap(LazyActionMap map) { static void loadActionMap(LazyActionMap map) {
map.put(new Actions(Actions.POSITIVE_UNIT_INCREMENT)); map.put(new Actions(Actions.POSITIVE_UNIT_INCREMENT));
...@@ -586,7 +589,7 @@ public class BasicScrollBarUI ...@@ -586,7 +589,7 @@ public class BasicScrollBarUI
/** /**
* Return the smallest acceptable size for the thumb. If the scrollbar * Returns the smallest acceptable size for the thumb. If the scrollbar
* becomes so small that this size isn't available, the thumb will be * becomes so small that this size isn't available, the thumb will be
* hidden. * hidden.
* <p> * <p>
...@@ -601,7 +604,7 @@ public class BasicScrollBarUI ...@@ -601,7 +604,7 @@ public class BasicScrollBarUI
} }
/** /**
* Return the largest acceptable size for the thumb. To create a fixed * Returns the largest acceptable size for the thumb. To create a fixed
* size thumb one make this method and <code>getMinimumThumbSize</code> * size thumb one make this method and <code>getMinimumThumbSize</code>
* return the same value. * return the same value.
* <p> * <p>
......
...@@ -1409,9 +1409,10 @@ public class BasicSliderUI extends SliderUI{ ...@@ -1409,9 +1409,10 @@ public class BasicSliderUI extends SliderUI{
} }
/** /**
* Returns a value give a y position. If yPos is past the track at the top or the * Returns the value at the y position. If {@code yPos} is beyond the
* bottom it will set the value to the min or max of the slider, depending if the * track at the the bottom or the top, this method sets the value to either
* slider is inverted or not. * the minimum or maximum value of the slider, depending on if the slider
* is inverted or not.
*/ */
public int valueForYPosition( int yPos ) { public int valueForYPosition( int yPos ) {
int value; int value;
...@@ -1440,9 +1441,10 @@ public class BasicSliderUI extends SliderUI{ ...@@ -1440,9 +1441,10 @@ public class BasicSliderUI extends SliderUI{
} }
/** /**
* Returns a value give an x position. If xPos is past the track at the left or the * Returns the value at the x position. If {@code xPos} is beyond the
* right it will set the value to the min or max of the slider, depending if the * track at the left or the right, this method sets the value to either the
* slider is inverted or not. * minimum or maximum value of the slider, depending on if the slider is
* inverted or not.
*/ */
public int valueForXPosition( int xPos ) { public int valueForXPosition( int xPos ) {
int value; int value;
......
...@@ -268,7 +268,7 @@ public class BasicSpinnerUI extends SpinnerUI ...@@ -268,7 +268,7 @@ public class BasicSpinnerUI extends SpinnerUI
} }
/** /**
* Create a <code>LayoutManager</code> that manages the <code>editor</code>, * Creates a <code>LayoutManager</code> that manages the <code>editor</code>,
* <code>nextButton</code>, and <code>previousButton</code> * <code>nextButton</code>, and <code>previousButton</code>
* children of the JSpinner. These three children must be * children of the JSpinner. These three children must be
* added with a constraint that identifies their role: * added with a constraint that identifies their role:
...@@ -286,7 +286,7 @@ public class BasicSpinnerUI extends SpinnerUI ...@@ -286,7 +286,7 @@ public class BasicSpinnerUI extends SpinnerUI
/** /**
* Create a <code>PropertyChangeListener</code> that can be * Creates a <code>PropertyChangeListener</code> that can be
* added to the JSpinner itself. Typically, this listener * added to the JSpinner itself. Typically, this listener
* will call replaceEditor when the "editor" property changes, * will call replaceEditor when the "editor" property changes,
* since it's the <code>SpinnerUI's</code> responsibility to * since it's the <code>SpinnerUI's</code> responsibility to
...@@ -302,16 +302,13 @@ public class BasicSpinnerUI extends SpinnerUI ...@@ -302,16 +302,13 @@ public class BasicSpinnerUI extends SpinnerUI
/** /**
* Create a component that will replace the spinner models value * Creates a decrement button, i.e. component that replaces the spinner
* with the object returned by <code>spinner.getPreviousValue</code>. * value with the object returned by <code>spinner.getPreviousValue</code>.
* By default the <code>previousButton</code> is a JButton. This * By default the <code>previousButton</code> is a {@code JButton}. If the
* method invokes <code>installPreviousButtonListeners</code> to * decrement button is not needed this method should return {@code null}.
* install the necessary listeners to update the <code>JSpinner</code>'s
* model in response to a user gesture. If a previousButton isn't needed
* (in a subclass) then override this method to return null.
* *
* @return a component that will replace the spinners model with the * @return a component that will replace the spinner's value with the
* next value in the sequence, or null * previous value in the sequence, or {@code null}
* @see #installUI * @see #installUI
* @see #createNextButton * @see #createNextButton
* @see #installPreviousButtonListeners * @see #installPreviousButtonListeners
...@@ -325,15 +322,13 @@ public class BasicSpinnerUI extends SpinnerUI ...@@ -325,15 +322,13 @@ public class BasicSpinnerUI extends SpinnerUI
/** /**
* Create a component that will replace the spinner models value * Creates an increment button, i.e. component that replaces the spinner
* with the object returned by <code>spinner.getNextValue</code>. * value with the object returned by <code>spinner.getNextValue</code>.
* By default the <code>nextButton</code> is a JButton * By default the <code>nextButton</code> is a {@code JButton}. If the
* who's <code>ActionListener</code> updates it's <code>JSpinner</code> * increment button is not needed this method should return {@code null}.
* ancestors model. If a nextButton isn't needed (in a subclass)
* then override this method to return null.
* *
* @return a component that will replace the spinners model with the * @return a component that will replace the spinner's value with the
* next value in the sequence, or null * next value in the sequence, or {@code null}
* @see #installUI * @see #installUI
* @see #createPreviousButton * @see #createPreviousButton
* @see #installNextButtonListeners * @see #installNextButtonListeners
......
...@@ -829,7 +829,7 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -829,7 +829,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
/** /**
* Returns the default non continuous layout divider, which is an * Returns the default non continuous layout divider, which is an
* instanceof Canvas that fills the background in dark gray. * instance of {@code Canvas} that fills in the background with dark gray.
*/ */
protected Component createDefaultNonContinuousLayoutDivider() { protected Component createDefaultNonContinuousLayoutDivider() {
return new Canvas() { return new Canvas() {
...@@ -1041,11 +1041,11 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -1041,11 +1041,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
/** /**
* Messaged after the JSplitPane the receiver is providing the look * Called when the specified split pane has finished painting
* and feel for paints its children. * its children.
*/ */
public void finishedPaintingChildren(JSplitPane jc, Graphics g) { public void finishedPaintingChildren(JSplitPane sp, Graphics g) {
if(jc == splitPane && getLastDragLocation() != -1 && if(sp == splitPane && getLastDragLocation() != -1 &&
!isContinuousLayout() && !draggingHW) { !isContinuousLayout() && !draggingHW) {
Dimension size = splitPane.getSize(); Dimension size = splitPane.getSize();
...@@ -1062,7 +1062,7 @@ public class BasicSplitPaneUI extends SplitPaneUI ...@@ -1062,7 +1062,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
/** /**
* Messaged to paint the look and feel. * @inheritDoc
*/ */
public void paint(Graphics g, JComponent jc) { public void paint(Graphics g, JComponent jc) {
if (!painted && splitPane.getDividerLocation()<0) { if (!painted && splitPane.getDividerLocation()<0) {
......
...@@ -306,7 +306,7 @@ public class BasicTableHeaderUI extends TableHeaderUI { ...@@ -306,7 +306,7 @@ public class BasicTableHeaderUI extends TableHeaderUI {
} }
/** /**
* Initialize JTableHeader properties, e.g. font, foreground, and background. * Initializes JTableHeader properties such as font, foreground, and background.
* The font, foreground, and background properties are only set if their * The font, foreground, and background properties are only set if their
* current value is either null or a UIResource, other properties are set * current value is either null or a UIResource, other properties are set
* if the current value is null. * if the current value is null.
...@@ -403,9 +403,9 @@ public class BasicTableHeaderUI extends TableHeaderUI { ...@@ -403,9 +403,9 @@ public class BasicTableHeaderUI extends TableHeaderUI {
} }
/** /**
* This method gets called every time the rollover column in the table * This method gets called every time when a rollover column in the table
* header is updated. Every look and feel supporting rollover effect * header is updated. Every look and feel that supports a rollover effect
* in table header should override this method and repaint the header. * in a table header should override this method and repaint the header.
* *
* @param oldColumn the index of the previous rollover column or -1 if the * @param oldColumn the index of the previous rollover column or -1 if the
* mouse was not over a column * mouse was not over a column
...@@ -736,7 +736,6 @@ public class BasicTableHeaderUI extends TableHeaderUI { ...@@ -736,7 +736,6 @@ public class BasicTableHeaderUI extends TableHeaderUI {
} }
private Dimension createHeaderSize(long width) { private Dimension createHeaderSize(long width) {
TableColumnModel columnModel = header.getColumnModel();
// None of the callers include the intercell spacing, do it here. // None of the callers include the intercell spacing, do it here.
if (width > Integer.MAX_VALUE) { if (width > Integer.MAX_VALUE) {
width = Integer.MAX_VALUE; width = Integer.MAX_VALUE;
......
...@@ -37,6 +37,7 @@ import javax.swing.text.*; ...@@ -37,6 +37,7 @@ import javax.swing.text.*;
import javax.swing.event.*; import javax.swing.event.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import javax.swing.plaf.synth.SynthUI;
import sun.swing.DefaultLookup; import sun.swing.DefaultLookup;
import sun.awt.AppContext; import sun.awt.AppContext;
import javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag; import javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag;
...@@ -221,8 +222,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -221,8 +222,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
// is ==, which is the case for the windows look and feel. // is ==, which is the case for the windows look and feel.
// Until an appropriate solution is found, the code is being // Until an appropriate solution is found, the code is being
// reverted to what it was before the original fix. // reverted to what it was before the original fix.
if (this instanceof sun.swing.plaf.synth.SynthUI || if (this instanceof SynthUI || (c instanceof JTextArea)) {
(c instanceof JTextArea)) {
return; return;
} }
Color background = c.getBackground(); Color background = c.getBackground();
...@@ -289,7 +289,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -289,7 +289,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
protected abstract String getPropertyPrefix(); protected abstract String getPropertyPrefix();
/** /**
* Initializes component properties, e.g. font, foreground, * Initializes component properties, such as font, foreground,
* background, caret color, selection color, selected text color, * background, caret color, selection color, selected text color,
* disabled text color, and border color. The font, foreground, and * disabled text color, and border color. The font, foreground, and
* background properties are only set if their current value is either null * background properties are only set if their current value is either null
...@@ -377,9 +377,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -377,9 +377,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
} }
/** /**
* Sets the component properties that haven't been explicitly overridden to * Sets the component properties that have not been explicitly overridden
* null. A property is considered overridden if its current value * to {@code null}. A property is considered overridden if its current
* is not a UIResource. * value is not a {@code UIResource}.
* *
* @see #installDefaults * @see #installDefaults
* @see #uninstallUI * @see #uninstallUI
...@@ -756,18 +756,18 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -756,18 +756,18 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
* things. * things.
* <ol> * <ol>
* <li> * <li>
* Set the associated component to opaque (can be changed * Sets the associated component to opaque (can be changed
* easily by a subclass or on JTextComponent directly), * easily by a subclass or on JTextComponent directly),
* which is the most common case. This will cause the * which is the most common case. This will cause the
* component's background color to be painted. * component's background color to be painted.
* <li> * <li>
* Install the default caret and highlighter into the * Installs the default caret and highlighter into the
* associated component. * associated component.
* <li> * <li>
* Attach to the editor and model. If there is no * Attaches to the editor and model. If there is no
* model, a default one is created. * model, a default one is created.
* <li> * <li>
* create the view factory and the view hierarchy used * Creates the view factory and the view hierarchy used
* to represent the model. * to represent the model.
* </ol> * </ol>
* *
...@@ -784,7 +784,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -784,7 +784,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
// This is a workaround as these should not override what synth has // This is a workaround as these should not override what synth has
// set them to // set them to
if (!(this instanceof sun.swing.plaf.synth.SynthUI)){ if (! (this instanceof SynthUI)) {
// common case is background painted... this can // common case is background painted... this can
// easily be changed by subclasses or from outside // easily be changed by subclasses or from outside
// of the component. // of the component.
...@@ -857,9 +857,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory { ...@@ -857,9 +857,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
* To prevent this from happening twice, this method is * To prevent this from happening twice, this method is
* reimplemented to simply paint. * reimplemented to simply paint.
* <p> * <p>
* <em>NOTE:</em> Superclass is also not thread-safe in * <em>NOTE:</em> NOTE: Superclass is also not thread-safe in its
* it's rendering of the background, although that's not * rendering of the background, although that is not an issue with the
* an issue with the default rendering. * default rendering.
*/ */
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
paint(g, c); paint(g, c);
......
...@@ -669,7 +669,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -669,7 +669,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
/** /**
* Sets the border of the component to have a rollover border which * Sets the border of the component to have a rollover border which
* was created by <code>createRolloverBorder</code>. * was created by the {@link #createRolloverBorder} method.
* *
* @param c component which will have a rollover border installed * @param c component which will have a rollover border installed
* @see #createRolloverBorder * @see #createRolloverBorder
...@@ -709,7 +709,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants ...@@ -709,7 +709,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
/** /**
* Sets the border of the component to have a non-rollover border which * Sets the border of the component to have a non-rollover border which
* was created by <code>createNonRolloverBorder</code>. * was created by the {@link #createNonRolloverBorder} method.
* *
* @param c component which will have a non-rollover border installed * @param c component which will have a non-rollover border installed
* @see #createNonRolloverBorder * @see #createNonRolloverBorder
......
...@@ -30,16 +30,12 @@ import javax.swing.event.*; ...@@ -30,16 +30,12 @@ import javax.swing.event.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.datatransfer.*; import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.beans.*; import java.beans.*;
import java.io.*;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.TooManyListenersException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import javax.swing.plaf.TreeUI; import javax.swing.plaf.TreeUI;
...@@ -1244,11 +1240,26 @@ public class BasicTreeUI extends TreeUI ...@@ -1244,11 +1240,26 @@ public class BasicTreeUI extends TreeUI
drawingCache.clear(); drawingCache.clear();
} }
private boolean isDropLine(JTree.DropLocation loc) { /**
* Tells if a {@code DropLocation} should be indicated by a line between
* nodes. This is meant for {@code javax.swing.DropMode.INSERT} and
* {@code javax.swing.DropMode.ON_OR_INSERT} drop modes.
*
* @param loc a {@code DropLocation}
* @return {@code true} if the drop location should be shown as a line
* @since 1.7
*/
protected boolean isDropLine(JTree.DropLocation loc) {
return loc != null && loc.getPath() != null && loc.getChildIndex() != -1; return loc != null && loc.getPath() != null && loc.getChildIndex() != -1;
} }
private void paintDropLine(Graphics g) { /**
* Paints the drop line.
*
* @param g {@code Graphics} object to draw on
* @since 1.7
*/
protected void paintDropLine(Graphics g) {
JTree.DropLocation loc = tree.getDropLocation(); JTree.DropLocation loc = tree.getDropLocation();
if (!isDropLine(loc)) { if (!isDropLine(loc)) {
return; return;
...@@ -1262,7 +1273,14 @@ public class BasicTreeUI extends TreeUI ...@@ -1262,7 +1273,14 @@ public class BasicTreeUI extends TreeUI
} }
} }
private Rectangle getDropLineRect(JTree.DropLocation loc) { /**
* Returns a ubounding box for the drop line.
*
* @param loc a {@code DropLocation}
* @return bounding box for the drop line
* @since 1.7
*/
protected Rectangle getDropLineRect(JTree.DropLocation loc) {
Rectangle rect; Rectangle rect;
TreePath path = loc.getPath(); TreePath path = loc.getPath();
int index = loc.getChildIndex(); int index = loc.getChildIndex();
...@@ -1684,7 +1702,7 @@ public class BasicTreeUI extends TreeUI ...@@ -1684,7 +1702,7 @@ public class BasicTreeUI extends TreeUI
treeState.setExpandedState(path, true); treeState.setExpandedState(path, true);
} }
} }
updateLeadRow(); updateLeadSelectionRow();
updateSize(); updateSize();
} }
} }
...@@ -2425,11 +2443,21 @@ public class BasicTreeUI extends TreeUI ...@@ -2425,11 +2443,21 @@ public class BasicTreeUI extends TreeUI
return tree.getLeadSelectionPath(); return tree.getLeadSelectionPath();
} }
private void updateLeadRow() { /**
* Updates the lead row of the selection.
* @since 1.7
*/
protected void updateLeadSelectionRow() {
leadRow = getRowForPath(tree, getLeadSelectionPath()); leadRow = getRowForPath(tree, getLeadSelectionPath());
} }
private int getLeadSelectionRow() { /**
* Returns the lead row of the selection.
*
* @return selection lead row
* @since 1.7
*/
protected int getLeadSelectionRow() {
return leadRow; return leadRow;
} }
...@@ -3345,7 +3373,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3345,7 +3373,7 @@ public class BasicTreeUI extends TreeUI
if (changeName == JTree.LEAD_SELECTION_PATH_PROPERTY) { if (changeName == JTree.LEAD_SELECTION_PATH_PROPERTY) {
if (!ignoreLAChange) { if (!ignoreLAChange) {
updateLeadRow(); updateLeadSelectionRow();
repaintPath((TreePath)event.getOldValue()); repaintPath((TreePath)event.getOldValue());
repaintPath((TreePath)event.getNewValue()); repaintPath((TreePath)event.getNewValue());
} }
...@@ -3763,7 +3791,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3763,7 +3791,7 @@ public class BasicTreeUI extends TreeUI
completeEditing(); completeEditing();
if(path != null && tree.isVisible(path)) { if(path != null && tree.isVisible(path)) {
treeState.setExpandedState(path, false); treeState.setExpandedState(path, false);
updateLeadRow(); updateLeadSelectionRow();
updateSize(); updateSize();
} }
} }
...@@ -3823,7 +3851,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3823,7 +3851,7 @@ public class BasicTreeUI extends TreeUI
if(treeState != null && e != null) { if(treeState != null && e != null) {
treeState.treeNodesInserted(e); treeState.treeNodesInserted(e);
updateLeadRow(); updateLeadSelectionRow();
TreePath path = e.getTreePath(); TreePath path = e.getTreePath();
...@@ -3848,7 +3876,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3848,7 +3876,7 @@ public class BasicTreeUI extends TreeUI
if(treeState != null && e != null) { if(treeState != null && e != null) {
treeState.treeNodesRemoved(e); treeState.treeNodesRemoved(e);
updateLeadRow(); updateLeadSelectionRow();
TreePath path = e.getTreePath(); TreePath path = e.getTreePath();
...@@ -3862,7 +3890,7 @@ public class BasicTreeUI extends TreeUI ...@@ -3862,7 +3890,7 @@ public class BasicTreeUI extends TreeUI
if(treeState != null && e != null) { if(treeState != null && e != null) {
treeState.treeStructureChanged(e); treeState.treeStructureChanged(e);
updateLeadRow(); updateLeadSelectionRow();
TreePath pPath = e.getTreePath(); TreePath pPath = e.getTreePath();
......
...@@ -34,7 +34,7 @@ import java.awt.Dimension; ...@@ -34,7 +34,7 @@ import java.awt.Dimension;
/** /**
* The default layout manager for Popup menus and menubars. This * The default layout manager for Popup menus and menubars. This
* class is an extension of BoxLayout which adds the UIResource tag * class is an extension of BoxLayout which adds the UIResource tag
* so that plauggable L&Fs can distinguish it from user-installed * so that pluggable L&Fs can distinguish it from user-installed
* layout managers on menus. * layout managers on menus.
* *
* @author Georges Saab * @author Georges Saab
......
...@@ -257,12 +257,40 @@ public class NimbusLookAndFeel extends SynthLookAndFeel { ...@@ -257,12 +257,40 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
/** /**
* @inheritDoc * @inheritDoc
* @return true * @return {@code true}
*/ */
@Override public boolean shouldUpdateStyleOnAncestorChanged() { @Override public boolean shouldUpdateStyleOnAncestorChanged() {
return true; return true;
} }
/**
* @inheritDoc
*
* <p>Overridden to return {@code true} when one of the following
* properties change:
* <ul>
* <li>{@code "Nimbus.Overrides"}
* <li>{@code "Nimbus.Overrides.InheritDefaults"}
* <li>{@code "JComponent.sizeVariant"}
* </ul>
*
* @since 1.7
*/
@Override
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev) {
String eName = ev.getPropertyName();
// Always update when overrides or size variant change
if ("Nimbus.Overrides" == eName ||
"Nimbus.Overrides.InheritDefaults" == eName ||
"JComponent.sizeVariant" == eName) {
return true;
}
return super.shouldUpdateStyleOnEvent(ev);
}
/** /**
* <p>Registers a third party component with the NimbusLookAndFeel.</p> * <p>Registers a third party component with the NimbusLookAndFeel.</p>
* *
......
...@@ -88,12 +88,11 @@ encouraged. ...@@ -88,12 +88,11 @@ encouraged.
<p><strong>Note:</strong> <p><strong>Note:</strong>
Most of the Swing API is <em>not</em> thread safe. Most of the Swing API is <em>not</em> thread safe.
For details, see For details, see
<a <a href="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html"
href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html" target="_top">Concurrency in Swing</a>,
target="_top">Threads and Swing</a>,
a section in a section in
<em><a href="http://java.sun.com/docs/books/tutorial/" <em><a href="http://java.sun.com/docs/books/tutorial/"
target="_top">The Java Tutorial</a></em>. target="_top">The Java Tutorial</a></em>.
@since 1.7 @since 1.7
@serial exclude @serial exclude
......
...@@ -29,7 +29,6 @@ import javax.swing.*; ...@@ -29,7 +29,6 @@ import javax.swing.*;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import sun.swing.plaf.synth.SynthUI;
/** /**
* SynthBorder is a border that delegates to a Painter. The Insets * SynthBorder is a border that delegates to a Painter. The Insets
......
...@@ -25,40 +25,49 @@ ...@@ -25,40 +25,49 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.beans.*; import java.beans.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicButtonUI; import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicHTML; import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View; import javax.swing.text.View;
import sun.swing.plaf.synth.SynthUI;
import sun.swing.plaf.synth.DefaultSynthStyle;
/** /**
* Synth's ButtonUI implementation. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JButton}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthButtonUI extends BasicButtonUI implements public class SynthButtonUI extends BasicButtonUI implements
PropertyChangeListener, SynthUI { PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthButtonUI(); return new SynthButtonUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults(AbstractButton b) { protected void installDefaults(AbstractButton b) {
updateStyle(b); updateStyle(b);
LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE); LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners(AbstractButton b) { protected void installListeners(AbstractButton b) {
super.installListeners(b); super.installListeners(b);
b.addPropertyChangeListener(this); b.addPropertyChangeListener(this);
...@@ -99,11 +108,19 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -99,11 +108,19 @@ class SynthButtonUI extends BasicButtonUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners(AbstractButton b) { protected void uninstallListeners(AbstractButton b) {
super.uninstallListeners(b); super.uninstallListeners(b);
b.removePropertyChangeListener(this); b.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults(AbstractButton b) { protected void uninstallDefaults(AbstractButton b) {
SynthContext context = getContext(b, ENABLED); SynthContext context = getContext(b, ENABLED);
...@@ -112,20 +129,20 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -112,20 +129,20 @@ class SynthButtonUI extends BasicButtonUI implements
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
SynthContext getContext(JComponent c, int state) { SynthContext getContext(JComponent c, int state) {
Region region = getRegion(c); Region region = SynthLookAndFeel.getRegion(c);
return SynthContext.getContext(SynthContext.class, c, region, return SynthContext.getContext(SynthContext.class, c, region,
style, state); style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
/** /**
* Returns the current state of the passed in <code>AbstractButton</code>. * Returns the current state of the passed in <code>AbstractButton</code>.
*/ */
...@@ -164,6 +181,10 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -164,6 +181,10 @@ class SynthButtonUI extends BasicButtonUI implements
return state; return state;
} }
/**
* @inheritDoc
*/
@Override
public int getBaseline(JComponent c, int width, int height) { public int getBaseline(JComponent c, int width, int height) {
if (c == null) { if (c == null) {
throw new NullPointerException("Component must be non-null"); throw new NullPointerException("Component must be non-null");
...@@ -215,6 +236,10 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -215,6 +236,10 @@ class SynthButtonUI extends BasicButtonUI implements
// Paint Methods // Paint Methods
// ******************************** // ********************************
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -224,6 +249,10 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -224,6 +249,10 @@ class SynthButtonUI extends BasicButtonUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -231,6 +260,12 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -231,6 +260,12 @@ class SynthButtonUI extends BasicButtonUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
AbstractButton b = (AbstractButton)context.getComponent(); AbstractButton b = (AbstractButton)context.getComponent();
...@@ -253,19 +288,22 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -253,19 +288,22 @@ class SynthButtonUI extends BasicButtonUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintButtonBorder(context, g, x, y, w, h); context.getPainter().paintButtonBorder(context, g, x, y, w, h);
} }
/** /**
* Returns the default icon. This should NOT callback * Returns the default icon. This should not callback
* to the JComponent. * to the JComponent.
* *
* @param b AbstractButton the icon is associated with * @param b button the icon is associated with
* @return default icon * @return default icon
*/ */
protected Icon getDefaultIcon(AbstractButton b) { protected Icon getDefaultIcon(AbstractButton b) {
SynthContext context = getContext(b); SynthContext context = getContext(b);
Icon icon = context.getStyle().getIcon(context, getPropertyPrefix() + "icon"); Icon icon = context.getStyle().getIcon(context, getPropertyPrefix() + "icon");
...@@ -274,7 +312,11 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -274,7 +312,11 @@ class SynthButtonUI extends BasicButtonUI implements
} }
/** /**
* Returns the Icon to use in painting the button. * Returns the Icon to use for painting the button. The icon is chosen with
* respect to the current state of the button.
*
* @param b button the icon is associated with
* @return an icon
*/ */
protected Icon getIcon(AbstractButton b) { protected Icon getIcon(AbstractButton b) {
Icon icon = b.getIcon(); Icon icon = b.getIcon();
...@@ -374,7 +416,7 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -374,7 +416,7 @@ class SynthButtonUI extends BasicButtonUI implements
/** /**
* Returns the amount to shift the text/icon when painting. * Returns the amount to shift the text/icon when painting.
*/ */
protected int getTextShiftOffset(SynthContext state) { private int getTextShiftOffset(SynthContext state) {
AbstractButton button = (AbstractButton)state.getComponent(); AbstractButton button = (AbstractButton)state.getComponent();
ButtonModel model = button.getModel(); ButtonModel model = button.getModel();
...@@ -389,6 +431,11 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -389,6 +431,11 @@ class SynthButtonUI extends BasicButtonUI implements
// ******************************** // ********************************
// Layout Methods // Layout Methods
// ******************************** // ********************************
/**
* @inheritDoc
*/
@Override
public Dimension getMinimumSize(JComponent c) { public Dimension getMinimumSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) { if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null; return null;
...@@ -406,6 +453,10 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -406,6 +453,10 @@ class SynthButtonUI extends BasicButtonUI implements
return size; return size;
} }
/**
* @inheritDoc
*/
@Override
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) { if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null; return null;
...@@ -423,6 +474,10 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -423,6 +474,10 @@ class SynthButtonUI extends BasicButtonUI implements
return size; return size;
} }
/**
* @inheritDoc
*/
@Override
public Dimension getMaximumSize(JComponent c) { public Dimension getMaximumSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) { if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null; return null;
...@@ -442,7 +497,8 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -442,7 +497,8 @@ class SynthButtonUI extends BasicButtonUI implements
} }
/** /**
* Returns the Icon used in calculating the pref/min/max size. * Returns the Icon used in calculating the
* preferred/minimum/maximum size.
*/ */
protected Icon getSizingIcon(AbstractButton b) { protected Icon getSizingIcon(AbstractButton b) {
Icon icon = getEnabledIcon(b, b.getIcon()); Icon icon = getEnabledIcon(b, b.getIcon());
...@@ -452,6 +508,10 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -452,6 +508,10 @@ class SynthButtonUI extends BasicButtonUI implements
return icon; return icon;
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((AbstractButton)e.getSource()); updateStyle((AbstractButton)e.getSource());
......
...@@ -27,56 +27,50 @@ package javax.swing.plaf.synth; ...@@ -27,56 +27,50 @@ package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.border.*;
import java.io.Serializable;
/** /**
* Synth's CheckBoxMenuItemUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JCheckBoxMenuItem}.
* *
* @author Leif Samuelsson * @author Leif Samuelsson
* @author Georges Saab * @author Georges Saab
* @author David Karlton * @author David Karlton
* @author Arnaud Weber * @author Arnaud Weber
* @since 1.7
*/ */
class SynthCheckBoxMenuItemUI extends SynthMenuItemUI { public class SynthCheckBoxMenuItemUI extends SynthMenuItemUI {
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthCheckBoxMenuItemUI(); return new SynthCheckBoxMenuItemUI();
} }
/**
* @inheritDoc
*/
@Override
protected String getPropertyPrefix() { protected String getPropertyPrefix() {
return "CheckBoxMenuItem"; return "CheckBoxMenuItem";
} }
public void processMouseEvent(JMenuItem item, MouseEvent e, @Override
MenuElement path[], MenuSelectionManager manager) {
Point p = e.getPoint();
if (p.x >= 0 && p.x < item.getWidth() && p.y >= 0 && p.y < item.getHeight()) {
if (e.getID() == MouseEvent.MOUSE_RELEASED) {
manager.clearSelectedPath();
item.doClick(0);
} else {
manager.setSelectedPath(path);
}
} else if (item.getModel().isArmed()) {
int c = path.length - 1;
MenuElement newPath[] = new MenuElement[c];
for (int i = 0; i < c; i++) {
newPath[i] = path[i];
}
manager.setSelectedPath(newPath);
}
}
void paintBackground(SynthContext context, Graphics g, JComponent c) { void paintBackground(SynthContext context, Graphics g, JComponent c) {
context.getPainter().paintCheckBoxMenuItemBackground(context, g, 0, 0, context.getPainter().paintCheckBoxMenuItemBackground(context, g, 0, 0,
c.getWidth(), c.getHeight()); c.getWidth(), c.getHeight());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintCheckBoxMenuItemBorder(context, g, x, y, w, h); context.getPainter().paintCheckBoxMenuItemBorder(context, g, x, y, w, h);
......
...@@ -25,36 +25,51 @@ ...@@ -25,36 +25,51 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import javax.swing.*; import javax.swing.JComponent;
import java.awt.*; import java.awt.Graphics;
import java.awt.event.*; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.*;
import java.io.Serializable;
/** /**
* Synth's CheckBoxUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JCheckBox}.
* *
* @author Jeff Dinkins * @author Jeff Dinkins
* @since 1.7
*/ */
class SynthCheckBoxUI extends SynthRadioButtonUI { public class SynthCheckBoxUI extends SynthRadioButtonUI {
// ******************************** // ********************************
// Create PLAF // Create PLAF
// ******************************** // ********************************
/**
* Creates a new UI object for the given component.
*
* @param b component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent b) { public static ComponentUI createUI(JComponent b) {
return new SynthCheckBoxUI(); return new SynthCheckBoxUI();
} }
/**
* @inheritDoc
*/
@Override
protected String getPropertyPrefix() { protected String getPropertyPrefix() {
return "CheckBox."; return "CheckBox.";
} }
@Override
void paintBackground(SynthContext context, Graphics g, JComponent c) { void paintBackground(SynthContext context, Graphics g, JComponent c) {
context.getPainter().paintCheckBoxBackground(context, g, 0, 0, context.getPainter().paintCheckBoxBackground(context, g, 0, 0,
c.getWidth(), c.getHeight()); c.getWidth(), c.getHeight());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintCheckBoxBorder(context, g, x, y, w, h); context.getPainter().paintCheckBoxBorder(context, g, x, y, w, h);
......
...@@ -28,34 +28,39 @@ package javax.swing.plaf.synth; ...@@ -28,34 +28,39 @@ package javax.swing.plaf.synth;
import javax.swing.*; import javax.swing.*;
import javax.swing.colorchooser.*; import javax.swing.colorchooser.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicColorChooserUI; import javax.swing.plaf.basic.BasicColorChooserUI;
import java.util.*;
import java.awt.*; import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.Serializable;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's ColorChooserUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JColorChooser}.
* *
* @author Tom Santos * @author Tom Santos
* @author Steve Wilson * @author Steve Wilson
* @since 1.7
*/ */
class SynthColorChooserUI extends BasicColorChooserUI implements public class SynthColorChooserUI extends BasicColorChooserUI implements
PropertyChangeListener, SynthUI { PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthColorChooserUI(); return new SynthColorChooserUI();
} }
/**
* @inheritDoc
*/
@Override
protected AbstractColorChooserPanel[] createDefaultChoosers() { protected AbstractColorChooserPanel[] createDefaultChoosers() {
SynthContext context = getContext(chooser, ENABLED); SynthContext context = getContext(chooser, ENABLED);
AbstractColorChooserPanel[] panels = (AbstractColorChooserPanel[]) AbstractColorChooserPanel[] panels = (AbstractColorChooserPanel[])
...@@ -68,6 +73,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements ...@@ -68,6 +73,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
return panels; return panels;
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
super.installDefaults(); super.installDefaults();
updateStyle(chooser); updateStyle(chooser);
...@@ -79,6 +88,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements ...@@ -79,6 +88,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(chooser, ENABLED); SynthContext context = getContext(chooser, ENABLED);
...@@ -88,16 +101,28 @@ class SynthColorChooserUI extends BasicColorChooserUI implements ...@@ -88,16 +101,28 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
super.uninstallDefaults(); super.uninstallDefaults();
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
chooser.addPropertyChangeListener(this); chooser.addPropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
chooser.removePropertyChangeListener(this); chooser.removePropertyChangeListener(this);
super.uninstallListeners(); super.uninstallListeners();
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -107,14 +132,14 @@ class SynthColorChooserUI extends BasicColorChooserUI implements ...@@ -107,14 +132,14 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -125,6 +150,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements ...@@ -125,6 +150,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -132,14 +161,29 @@ class SynthColorChooserUI extends BasicColorChooserUI implements ...@@ -132,14 +161,29 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
* This implementation does not perform any actions.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintColorChooserBorder(context, g, x, y,w,h); context.getPainter().paintColorChooserBorder(context, g, x, y,w,h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((JColorChooser)e.getSource()); updateStyle((JColorChooser)e.getSource());
......
...@@ -27,21 +27,21 @@ package javax.swing.plaf.synth; ...@@ -27,21 +27,21 @@ package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.lang.reflect.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.event.*; import javax.swing.event.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's ComboBoxUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JComboBox}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthComboBoxUI extends BasicComboBoxUI implements public class SynthComboBoxUI extends BasicComboBoxUI implements
PropertyChangeListener, SynthUI { PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
private boolean useListColors; private boolean useListColors;
...@@ -93,12 +93,11 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -93,12 +93,11 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
private boolean forceOpaque = false; private boolean forceOpaque = false;
/** /**
* NOTE: This serves the same purpose as the same field in BasicComboBoxUI. * Creates a new UI object for the given component.
* It is here because I could not give the padding field in *
* BasicComboBoxUI protected access in an update release. * @param c component to create UI object for
* @return the UI object
*/ */
private Insets padding;
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthComboBoxUI(); return new SynthComboBoxUI();
} }
...@@ -118,21 +117,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -118,21 +117,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
@Override @Override
protected void installDefaults() { protected void installDefaults() {
//NOTE: This next line of code was added because, since squareButton in
//BasicComboBoxUI is private, I need to have some way of reading it from UIManager.
//This is an incomplete solution (since it implies that squareButons,
//once set, cannot be reset per state. Probably ok, but not always ok).
//This line of code should be removed at the same time that squareButton
//is made protected in the super class.
super.installDefaults();
//This is here instead of in updateStyle because the value for padding
//needs to remain consistent with the value for padding in
//BasicComboBoxUI. I wouldn't have this value here at all if not
//for the fact that I cannot make "padding" protected in any way
//for an update release. This *should* be fixed in Java 7
padding = UIManager.getInsets("ComboBox.padding");
updateStyle(comboBox); updateStyle(comboBox);
} }
...@@ -142,6 +126,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -142,6 +126,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
style = SynthLookAndFeel.updateStyle(context, this); style = SynthLookAndFeel.updateStyle(context, this);
if (style != oldStyle) { if (style != oldStyle) {
padding = (Insets) style.get(context, "ComboBox.padding");
popupInsets = (Insets)style.get(context, "ComboBox.popupInsets"); popupInsets = (Insets)style.get(context, "ComboBox.popupInsets");
useListColors = style.getBoolean(context, useListColors = style.getBoolean(context,
"ComboBox.rendererUseListColors", true); "ComboBox.rendererUseListColors", true);
...@@ -149,6 +134,8 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -149,6 +134,8 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
"ComboBox.buttonWhenNotEditable", false); "ComboBox.buttonWhenNotEditable", false);
pressedWhenPopupVisible = style.getBoolean(context, pressedWhenPopupVisible = style.getBoolean(context,
"ComboBox.pressedWhenPopupVisible", false); "ComboBox.pressedWhenPopupVisible", false);
squareButton = style.getBoolean(context,
"ComboBox.squareButton", true);
if (oldStyle != null) { if (oldStyle != null) {
uninstallKeyboardActions(); uninstallKeyboardActions();
...@@ -164,6 +151,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -164,6 +151,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
} }
/**
* @inheritDoc
*/
@Override @Override
protected void installListeners() { protected void installListeners() {
comboBox.addPropertyChangeListener(this); comboBox.addPropertyChangeListener(this);
...@@ -172,6 +162,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -172,6 +162,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
super.installListeners(); super.installListeners();
} }
/**
* @inheritDoc
*/
@Override @Override
public void uninstallUI(JComponent c) { public void uninstallUI(JComponent c) {
if (popup instanceof SynthComboPopup) { if (popup instanceof SynthComboPopup) {
...@@ -181,6 +174,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -181,6 +174,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
buttonHandler = null; buttonHandler = null;
} }
/**
* @inheritDoc
*/
@Override @Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(comboBox, ENABLED); SynthContext context = getContext(comboBox, ENABLED);
...@@ -190,6 +186,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -190,6 +186,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override @Override
protected void uninstallListeners() { protected void uninstallListeners() {
editorFocusHandler.unregister(); editorFocusHandler.unregister();
...@@ -200,6 +199,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -200,6 +199,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
super.uninstallListeners(); super.uninstallListeners();
} }
/**
* @inheritDoc
*/
@Override @Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
...@@ -210,10 +212,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -210,10 +212,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
// currently we have a broken situation where if a developer // currently we have a broken situation where if a developer
// takes the border from a JComboBox and sets it on a JTextField // takes the border from a JComboBox and sets it on a JTextField
...@@ -252,6 +250,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -252,6 +250,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
} }
/**
* @inheritDoc
*/
@Override @Override
protected ComboPopup createPopup() { protected ComboPopup createPopup() {
SynthComboPopup p = new SynthComboPopup(comboBox); SynthComboPopup p = new SynthComboPopup(comboBox);
...@@ -259,11 +260,17 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -259,11 +260,17 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
return p; return p;
} }
/**
* @inheritDoc
*/
@Override @Override
protected ListCellRenderer createRenderer() { protected ListCellRenderer createRenderer() {
return new SynthComboBoxRenderer(); return new SynthComboBoxRenderer();
} }
/**
* @inheritDoc
*/
@Override @Override
protected ComboBoxEditor createEditor() { protected ComboBoxEditor createEditor() {
return new SynthComboBoxEditor(); return new SynthComboBoxEditor();
...@@ -273,6 +280,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -273,6 +280,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
// end UI Initialization // end UI Initialization
//====================== //======================
/**
* @inheritDoc
*/
@Override @Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
...@@ -280,6 +290,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -280,6 +290,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
} }
/**
* @inheritDoc
*/
@Override @Override
protected JButton createArrowButton() { protected JButton createArrowButton() {
SynthArrowButton button = new SynthArrowButton(SwingConstants.SOUTH); SynthArrowButton button = new SynthArrowButton(SwingConstants.SOUTH);
...@@ -291,6 +304,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -291,6 +304,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
//================================= //=================================
// begin ComponentUI Implementation // begin ComponentUI Implementation
/**
* @inheritDoc
*/
@Override @Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -302,6 +318,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -302,6 +318,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -310,6 +329,12 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -310,6 +329,12 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
hasFocus = comboBox.hasFocus(); hasFocus = comboBox.hasFocus();
if ( !comboBox.isEditable() ) { if ( !comboBox.isEditable() ) {
...@@ -318,6 +343,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -318,6 +343,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
} }
/**
* @inheritDoc
*/
@Override @Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
...@@ -375,7 +403,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -375,7 +403,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
/** /**
* Return the default size of an empty display area of the combo box using * Returns the default size of an empty display area of the combo box using
* the current renderer and font. * the current renderer and font.
* *
* This method was overridden to use SynthComboBoxRenderer instead of * This method was overridden to use SynthComboBoxRenderer instead of
...@@ -393,23 +421,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -393,23 +421,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
return new Dimension(d.width, d.height); return new Dimension(d.width, d.height);
} }
/**
* This has been refactored out in hopes that it may be investigated and
* simplified for the next major release. adding/removing
* the component to the currentValuePane and changing the font may be
* redundant operations.
*
* NOTE: This method was copied in its entirety from BasicComboBoxUI. Might
* want to make it protected in BasicComboBoxUI in Java 7
*/
private Dimension getSizeForComponent(Component comp) {
currentValuePane.add(comp);
comp.setFont(comboBox.getFont());
Dimension d = comp.getPreferredSize();
currentValuePane.remove(comp);
return d;
}
/** /**
* From BasicComboBoxRenderer v 1.18. * From BasicComboBoxRenderer v 1.18.
* *
...@@ -478,84 +489,16 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -478,84 +489,16 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
/** private static class SynthComboBoxEditor
* From BasicCombBoxEditor v 1.24. extends BasicComboBoxEditor.UIResource {
*/
private static class SynthComboBoxEditor implements
ComboBoxEditor, UIResource {
protected JTextField editor;
private Object oldValue;
public SynthComboBoxEditor() {
editor = new JTextField("",9);
editor.setName("ComboBox.textField");
}
@Override
public Component getEditorComponent() {
return editor;
}
/**
* Sets the item that should be edited.
*
* @param anObject the displayed value of the editor
*/
@Override
public void setItem(Object anObject) {
String text;
if ( anObject != null ) {
text = anObject.toString();
oldValue = anObject;
} else {
text = "";
}
// workaround for 4530952
if (!text.equals(editor.getText())) {
editor.setText(text);
}
}
@Override
public Object getItem() {
Object newValue = editor.getText();
if (oldValue != null && !(oldValue instanceof String)) {
// The original value is not a string. Should return the value in it's
// original type.
if (newValue.equals(oldValue.toString())) {
return oldValue;
} else {
// Must take the value from the editor and get the value and cast it to the new type.
Class<?> cls = oldValue.getClass();
try {
Method method = cls.getMethod("valueOf", new Class[]{String.class});
newValue = method.invoke(oldValue, new Object[] { editor.getText()});
} catch (Exception ex) {
// Fail silently and return the newValue (a String object)
}
}
}
return newValue;
}
@Override @Override public JTextField createEditorComponent() {
public void selectAll() { JTextField f = new JTextField("", 9);
editor.selectAll(); f.setName("ComboBox.textField");
editor.requestFocus(); return f;
} }
@Override
public void addActionListener(ActionListener l) {
editor.addActionListener(l);
} }
@Override
public void removeActionListener(ActionListener l) {
editor.removeActionListener(l);
}
}
/** /**
* Handles all the logic for treating the combo as a button when it is * Handles all the logic for treating the combo as a button when it is
...@@ -620,7 +563,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -620,7 +563,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
//------------------------------------------------------------------ //------------------------------------------------------------------
/** /**
* {@inheritDoc} * @inheritDoc
* *
* Ensures that isPressed() will return true if the combo is pressed, * Ensures that isPressed() will return true if the combo is pressed,
* or the arrowButton is pressed, <em>or</em> if the combo popup is * or the arrowButton is pressed, <em>or</em> if the combo popup is
...@@ -634,7 +577,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -634,7 +577,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* Ensures that the armed state is in sync with the pressed state * Ensures that the armed state is in sync with the pressed state
* if shouldActLikeButton is true. Without this method, the arrow * if shouldActLikeButton is true. Without this method, the arrow
...@@ -649,7 +592,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -649,7 +592,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* Ensures that isRollover() will return true if the combo is * Ensures that isRollover() will return true if the combo is
* rolled over, or the arrowButton is rolled over. * rolled over, or the arrowButton is rolled over.
...@@ -660,7 +603,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -660,7 +603,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* Forwards pressed states to the internal "pressed" field * Forwards pressed states to the internal "pressed" field
*/ */
...@@ -671,7 +614,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements ...@@ -671,7 +614,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* Forwards rollover states to the internal "over" field * Forwards rollover states to the internal "over" field
*/ */
......
...@@ -27,7 +27,6 @@ package javax.swing.plaf.synth; ...@@ -27,7 +27,6 @@ package javax.swing.plaf.synth;
import sun.swing.DefaultLookup; import sun.swing.DefaultLookup;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import sun.swing.plaf.synth.SynthUI;
/** /**
* SynthDefaultLookup redirects all lookup calls to the SynthContext. * SynthDefaultLookup redirects all lookup calls to the SynthContext.
......
...@@ -28,36 +28,44 @@ package javax.swing.plaf.synth; ...@@ -28,36 +28,44 @@ package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicDesktopIconUI; import javax.swing.plaf.basic.BasicDesktopIconUI;
import java.beans.*; import java.beans.*;
import java.io.Serializable;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth L&F for a minimized window on a desktop. * Provides the Synth L&F UI delegate for a minimized internal frame on a desktop.
* *
* @author Joshua Outwater * @author Joshua Outwater
* @since 1.7
*/ */
class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, public class SynthDesktopIconUI extends BasicDesktopIconUI
ActionListener, PropertyChangeListener { implements SynthUI, PropertyChangeListener {
private SynthStyle style; private SynthStyle style;
private Handler handler = new Handler();
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthDesktopIconUI(); return new SynthDesktopIconUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installComponents() { protected void installComponents() {
if (UIManager.getBoolean("InternalFrame.useTaskBar")) { if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
iconPane = new JToggleButton(frame.getTitle(), frame.getFrameIcon()) { iconPane = new JToggleButton(frame.getTitle(), frame.getFrameIcon()) {
public String getToolTipText() { @Override public String getToolTipText() {
return getText(); return getText();
} }
public JPopupMenu getComponentPopupMenu() { @Override public JPopupMenu getComponentPopupMenu() {
return frame.getComponentPopupMenu(); return frame.getComponentPopupMenu();
} }
}; };
...@@ -73,24 +81,37 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, ...@@ -73,24 +81,37 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
desktopIcon.add(iconPane, BorderLayout.CENTER); desktopIcon.add(iconPane, BorderLayout.CENTER);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
desktopIcon.addPropertyChangeListener(this); desktopIcon.addPropertyChangeListener(this);
if (iconPane instanceof JToggleButton) { if (iconPane instanceof JToggleButton) {
frame.addPropertyChangeListener(this); frame.addPropertyChangeListener(this);
((JToggleButton)iconPane).addActionListener(this); ((JToggleButton)iconPane).addActionListener(handler);
} }
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
if (iconPane instanceof JToggleButton) { if (iconPane instanceof JToggleButton) {
((JToggleButton)iconPane).removeActionListener(handler);
frame.removePropertyChangeListener(this); frame.removePropertyChangeListener(this);
} }
desktopIcon.removePropertyChangeListener(this); desktopIcon.removePropertyChangeListener(this);
super.uninstallListeners(); super.uninstallListeners();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
updateStyle(desktopIcon); updateStyle(desktopIcon);
} }
...@@ -101,6 +122,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, ...@@ -101,6 +122,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(desktopIcon, ENABLED); SynthContext context = getContext(desktopIcon, ENABLED);
style.uninstallDefaults(context); style.uninstallDefaults(context);
...@@ -108,12 +133,16 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, ...@@ -108,12 +133,16 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
private SynthContext getContext(JComponent c, int state) { private SynthContext getContext(JComponent c, int state) {
Region region = getRegion(c); Region region = SynthLookAndFeel.getRegion(c);
return SynthContext.getContext(SynthContext.class, c, region, return SynthContext.getContext(SynthContext.class, c, region,
style, state); style, state);
} }
...@@ -122,10 +151,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, ...@@ -122,10 +151,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
Region getRegion(JComponent c) { /**
return SynthLookAndFeel.getRegion(c); * @inheritDoc
} */
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -136,6 +165,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, ...@@ -136,6 +165,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -143,33 +176,24 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, ...@@ -143,33 +176,24 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintDesktopIconBorder(context, g, x, y, w, h); context.getPainter().paintDesktopIconBorder(context, g, x, y, w, h);
} }
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() instanceof JToggleButton) {
// Either iconify the frame or deiconify and activate it.
JToggleButton button = (JToggleButton)evt.getSource();
try {
boolean selected = button.isSelected();
if (!selected && !frame.isIconifiable()) {
button.setSelected(true);
} else {
frame.setIcon(!selected);
if (selected) {
frame.setSelected(true);
}
}
} catch (PropertyVetoException e2) {
}
}
}
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() instanceof JInternalFrame.JDesktopIcon) { if (evt.getSource() instanceof JInternalFrame.JDesktopIcon) {
if (SynthLookAndFeel.shouldUpdateStyle(evt)) { if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
...@@ -191,4 +215,25 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI, ...@@ -191,4 +215,25 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
} }
} }
} }
private final class Handler implements ActionListener {
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() instanceof JToggleButton) {
// Either iconify the frame or deiconify and activate it.
JToggleButton button = (JToggleButton)evt.getSource();
try {
boolean selected = button.isSelected();
if (!selected && !frame.isIconifiable()) {
button.setSelected(true);
} else {
frame.setIcon(!selected);
if (selected) {
frame.setSelected(true);
}
}
} catch (PropertyVetoException e2) {
}
}
}
}
} }
...@@ -29,34 +29,38 @@ import javax.swing.*; ...@@ -29,34 +29,38 @@ import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicDesktopPaneUI; import javax.swing.plaf.basic.BasicDesktopPaneUI;
import java.beans.*; import java.beans.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Graphics;
import java.awt.KeyboardFocusManager;
import java.awt.*; import java.awt.*;
import java.util.Vector;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth L&F for a desktop. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JDesktopPane}.
* *
* @author Joshua Outwater * @author Joshua Outwater
* @author Steve Wilson * @author Steve Wilson
* @since 1.7
*/ */
class SynthDesktopPaneUI extends BasicDesktopPaneUI implements public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
PropertyChangeListener, SynthUI { PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
private TaskBar taskBar; private TaskBar taskBar;
private DesktopManager oldDesktopManager; private DesktopManager oldDesktopManager;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthDesktopPaneUI(); return new SynthDesktopPaneUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
desktop.addPropertyChangeListener(this); desktop.addPropertyChangeListener(this);
...@@ -68,6 +72,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -68,6 +72,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
updateStyle(desktop); updateStyle(desktop);
...@@ -114,6 +122,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -114,6 +122,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
if (taskBar != null) { if (taskBar != null) {
desktop.removeComponentListener(taskBar); desktop.removeComponentListener(taskBar);
...@@ -123,6 +135,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -123,6 +135,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
super.uninstallListeners(); super.uninstallListeners();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(desktop, ENABLED); SynthContext context = getContext(desktop, ENABLED);
...@@ -147,6 +163,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -147,6 +163,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
protected void installDesktopManager() { protected void installDesktopManager() {
if (UIManager.getBoolean("InternalFrame.useTaskBar")) { if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
desktopManager = oldDesktopManager = desktop.getDesktopManager(); desktopManager = oldDesktopManager = desktop.getDesktopManager();
...@@ -159,6 +179,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -159,6 +179,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDesktopManager() { protected void uninstallDesktopManager() {
if (oldDesktopManager != null && !(oldDesktopManager instanceof UIResource)) { if (oldDesktopManager != null && !(oldDesktopManager instanceof UIResource)) {
desktopManager = desktop.getDesktopManager(); desktopManager = desktop.getDesktopManager();
...@@ -397,7 +421,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -397,7 +421,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -407,14 +434,14 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -407,14 +434,14 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -425,6 +452,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -425,6 +452,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -432,14 +463,28 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements ...@@ -432,14 +463,28 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintDesktopPaneBorder(context, g, x, y, w, h); context.getPainter().paintDesktopPaneBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
if (SynthLookAndFeel.shouldUpdateStyle(evt)) { if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
updateStyle((JDesktopPane)evt.getSource()); updateStyle((JDesktopPane)evt.getSource());
......
...@@ -31,47 +31,52 @@ import javax.swing.text.*; ...@@ -31,47 +31,52 @@ import javax.swing.text.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicEditorPaneUI; import javax.swing.plaf.basic.BasicEditorPaneUI;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Provides the look and feel for a JEditorPane in the * Provides the Synth L&F UI delegate for
* Synth look and feel. * {@link javax.swing.JEditorPane}.
* *
* @author Shannon Hickey * @author Shannon Hickey
* @since 1.7
*/ */
class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
private SynthStyle style; private SynthStyle style;
/* /*
* I would prefer to use UIResource instad of this. * I would prefer to use UIResource instad of this.
* Unfortunately Boolean is a final class * Unfortunately Boolean is a final class
*/ */
private Boolean localTrue = Boolean.TRUE; private Boolean localTrue = Boolean.TRUE;
private Boolean localFalse = Boolean.FALSE;
/** /**
* Creates a UI for the JTextPane. * Creates a new UI object for the given component.
* *
* @param c the JTextPane component * @param c component to create UI object for
* @return the UI * @return the UI object
*/ */
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthEditorPaneUI(); return new SynthEditorPaneUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
// Installs the text cursor on the component // Installs the text cursor on the component
super.installDefaults(); super.installDefaults();
JComponent c = getComponent(); JComponent c = getComponent();
Object clientProperty = Object clientProperty =
c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES); c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
if (clientProperty == null if (clientProperty == null) {
|| clientProperty == localFalse) { c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, localTrue);
c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
localTrue);
} }
updateStyle(getComponent()); updateStyle(getComponent());
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(getComponent(), ENABLED); SynthContext context = getContext(getComponent(), ENABLED);
JComponent c = getComponent(); JComponent c = getComponent();
...@@ -84,7 +89,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -84,7 +89,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
Object clientProperty = Object clientProperty =
c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES); c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
if (clientProperty == localTrue) { if (clientProperty == localTrue) {
getComponent().putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
Boolean.FALSE); Boolean.FALSE);
} }
super.uninstallDefaults(); super.uninstallDefaults();
...@@ -100,6 +105,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -100,6 +105,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
* *
* @param evt the property change event * @param evt the property change event
*/ */
@Override
protected void propertyChange(PropertyChangeEvent evt) { protected void propertyChange(PropertyChangeEvent evt) {
if (SynthLookAndFeel.shouldUpdateStyle(evt)) { if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
updateStyle((JTextComponent)evt.getSource()); updateStyle((JTextComponent)evt.getSource());
...@@ -124,6 +130,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -124,6 +130,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -137,6 +147,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -137,6 +147,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -146,10 +160,20 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -146,10 +160,20 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
super.paint(g, getComponent()); super.paint(g, getComponent());
} }
/**
* @inheritDoc
*/
@Override
protected void paintBackground(Graphics g) { protected void paintBackground(Graphics g) {
// Overriden to do nothing, all our painting is done from update/paint. // Overriden to do nothing, all our painting is done from update/paint.
} }
...@@ -159,6 +183,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { ...@@ -159,6 +183,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
c.getWidth(), c.getHeight()); c.getWidth(), c.getHeight());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintEditorPaneBorder(context, g, x, y, w, h); context.getPainter().paintEditorPaneBorder(context, g, x, y, w, h);
......
...@@ -24,16 +24,17 @@ ...@@ -24,16 +24,17 @@
*/ */
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*; import java.awt.Graphics;
import javax.swing.*; import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
/** /**
* Provides the look and feel implementation for * Provides the Synth L&F UI delegate for
* <code>JFormattedTextField</code>. * {@link javax.swing.JFormattedTextField}.
* *
* @since 1.7
*/ */
class SynthFormattedTextFieldUI extends SynthTextFieldUI { public class SynthFormattedTextFieldUI extends SynthTextFieldUI {
/** /**
* Creates a UI for a JFormattedTextField. * Creates a UI for a JFormattedTextField.
* *
...@@ -51,15 +52,24 @@ class SynthFormattedTextFieldUI extends SynthTextFieldUI { ...@@ -51,15 +52,24 @@ class SynthFormattedTextFieldUI extends SynthTextFieldUI {
* *
* @return the name "FormattedTextField" * @return the name "FormattedTextField"
*/ */
@Override
protected String getPropertyPrefix() { protected String getPropertyPrefix() {
return "FormattedTextField"; return "FormattedTextField";
} }
/**
* @inheritDoc
*/
@Override
void paintBackground(SynthContext context, Graphics g, JComponent c) { void paintBackground(SynthContext context, Graphics g, JComponent c) {
context.getPainter().paintFormattedTextFieldBackground(context, g, 0, context.getPainter().paintFormattedTextFieldBackground(context, g, 0,
0, c.getWidth(), c.getHeight()); 0, c.getWidth(), c.getHeight());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintFormattedTextFieldBorder(context, g, x, y, context.getPainter().paintFormattedTextFieldBorder(context, g, x, y,
......
...@@ -30,14 +30,9 @@ import java.awt.event.*; ...@@ -30,14 +30,9 @@ import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane; import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import javax.swing.border.*;
import javax.swing.event.InternalFrameEvent;
import java.util.EventListener;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.VetoableChangeListener;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import sun.swing.plaf.synth.SynthUI;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
/** /**
......
...@@ -27,52 +27,61 @@ package javax.swing.plaf.synth; ...@@ -27,52 +27,61 @@ package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.peer.LightweightPeer;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicInternalFrameUI; import javax.swing.plaf.basic.BasicInternalFrameUI;
import javax.swing.event.*;
import java.beans.*; import java.beans.*;
import java.io.Serializable;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's InternalFrameUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JInternalFrame}.
* *
* @author David Kloba * @author David Kloba
* @author Joshua Outwater * @author Joshua Outwater
* @author Rich Schiavi * @author Rich Schiavi
* @since 1.7
*/ */
class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, public class SynthInternalFrameUI extends BasicInternalFrameUI
PropertyChangeListener { implements SynthUI, PropertyChangeListener {
private SynthStyle style; private SynthStyle style;
private static DesktopManager sharedDesktopManager; /**
private boolean componentListenerAdded = false; * Creates a new UI object for the given component.
*
private Rectangle parentBounds; * @param b component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent b) { public static ComponentUI createUI(JComponent b) {
return new SynthInternalFrameUI((JInternalFrame)b); return new SynthInternalFrameUI((JInternalFrame)b);
} }
public SynthInternalFrameUI(JInternalFrame b) { protected SynthInternalFrameUI(JInternalFrame b) {
super(b); super(b);
} }
/**
* @inheritDoc
*/
@Override
public void installDefaults() { public void installDefaults() {
frame.setLayout(internalFrameLayout = createLayoutManager()); frame.setLayout(internalFrameLayout = createLayoutManager());
updateStyle(frame); updateStyle(frame);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
frame.addPropertyChangeListener(this); frame.addPropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallComponents() { protected void uninstallComponents() {
if (frame.getComponentPopupMenu() instanceof UIResource) { if (frame.getComponentPopupMenu() instanceof UIResource) {
frame.setComponentPopupMenu(null); frame.setComponentPopupMenu(null);
...@@ -80,6 +89,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, ...@@ -80,6 +89,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
super.uninstallComponents(); super.uninstallComponents();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
frame.removePropertyChangeListener(this); frame.removePropertyChangeListener(this);
super.uninstallListeners(); super.uninstallListeners();
...@@ -104,6 +117,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, ...@@ -104,6 +117,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(frame, ENABLED); SynthContext context = getContext(frame, ENABLED);
style.uninstallDefaults(context); style.uninstallDefaults(context);
...@@ -115,6 +132,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, ...@@ -115,6 +132,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -124,24 +145,28 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, ...@@ -124,24 +145,28 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
public int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
protected JComponent createNorthPane(JInternalFrame w) { protected JComponent createNorthPane(JInternalFrame w) {
titlePane = new SynthInternalFrameTitlePane(w); titlePane = new SynthInternalFrameTitlePane(w);
titlePane.setName("InternalFrame.northPane"); titlePane.setName("InternalFrame.northPane");
return titlePane; return titlePane;
} }
/**
* @inheritDoc
*/
@Override
protected ComponentListener createComponentListener() { protected ComponentListener createComponentListener() {
if (UIManager.getBoolean("InternalFrame.useTaskBar")) { if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
return new ComponentHandler() { return new ComponentHandler() {
public void componentResized(ComponentEvent e) { @Override public void componentResized(ComponentEvent e) {
if (frame != null && frame.isMaximum()) { if (frame != null && frame.isMaximum()) {
JDesktopPane desktop = (JDesktopPane)e.getSource(); JDesktopPane desktop = (JDesktopPane)e.getSource();
for (Component comp : desktop.getComponents()) { for (Component comp : desktop.getComponents()) {
...@@ -168,6 +193,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, ...@@ -168,6 +193,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
} }
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -178,6 +207,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, ...@@ -178,6 +207,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -185,15 +218,29 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI, ...@@ -185,15 +218,29 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintInternalFrameBorder(context, context.getPainter().paintInternalFrameBorder(context,
g, x, y, w, h); g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
SynthStyle oldStyle = style; SynthStyle oldStyle = style;
JInternalFrame f = (JInternalFrame)evt.getSource(); JInternalFrame f = (JInternalFrame)evt.getSource();
......
...@@ -29,38 +29,37 @@ import javax.swing.*; ...@@ -29,38 +29,37 @@ import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import javax.swing.text.View; import javax.swing.text.View;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's LabelUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JLabel}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthLabelUI extends BasicLabelUI implements SynthUI { public class SynthLabelUI extends BasicLabelUI implements SynthUI {
private SynthStyle style; private SynthStyle style;
/** /**
* Returns the LabelUI implementation used for the skins look and feel. * Returns the LabelUI implementation used for the skins look and feel.
*
* @param c component to create UI object for
* @return the UI object
*/ */
public static ComponentUI createUI(JComponent c){ public static ComponentUI createUI(JComponent c){
return new SynthLabelUI(); return new SynthLabelUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults(JLabel c) { protected void installDefaults(JLabel c) {
updateStyle(c); updateStyle(c);
} }
...@@ -71,6 +70,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -71,6 +70,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults(JLabel c){ protected void uninstallDefaults(JLabel c){
SynthContext context = getContext(c, ENABLED); SynthContext context = getContext(c, ENABLED);
...@@ -79,6 +82,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -79,6 +82,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -88,10 +95,6 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -88,10 +95,6 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
int state = SynthLookAndFeel.getComponentState(c); int state = SynthLookAndFeel.getComponentState(c);
if (SynthLookAndFeel.selectedUI == this && if (SynthLookAndFeel.selectedUI == this &&
...@@ -101,6 +104,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -101,6 +104,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return state; return state;
} }
/**
* @inheritDoc
*/
@Override
public int getBaseline(JComponent c, int width, int height) { public int getBaseline(JComponent c, int width, int height) {
if (c == null) { if (c == null) {
throw new NullPointerException("Component must be non-null"); throw new NullPointerException("Component must be non-null");
...@@ -153,6 +160,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -153,6 +160,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
* component. This method is invoked by <code>JComponent</code> * component. This method is invoked by <code>JComponent</code>
* when the specified component is being painted. * when the specified component is being painted.
*/ */
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -163,6 +174,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -163,6 +174,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -170,6 +185,12 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -170,6 +185,12 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
JLabel label = (JLabel)context.getComponent(); JLabel label = (JLabel)context.getComponent();
Icon icon = (label.isEnabled()) ? label.getIcon() : Icon icon = (label.isEnabled()) ? label.getIcon() :
...@@ -185,11 +206,19 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -185,11 +206,19 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
label.getIconTextGap(), label.getDisplayedMnemonicIndex(), 0); label.getIconTextGap(), label.getDisplayedMnemonicIndex(), 0);
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintLabelBorder(context, g, x, y, w, h); context.getPainter().paintLabelBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
JLabel label = (JLabel)c; JLabel label = (JLabel)c;
Icon icon = (label.isEnabled()) ? label.getIcon() : Icon icon = (label.isEnabled()) ? label.getIcon() :
...@@ -207,7 +236,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -207,7 +236,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return size; return size;
} }
/**
* @inheritDoc
*/
@Override
public Dimension getMinimumSize(JComponent c) { public Dimension getMinimumSize(JComponent c) {
JLabel label = (JLabel)c; JLabel label = (JLabel)c;
Icon icon = (label.isEnabled()) ? label.getIcon() : Icon icon = (label.isEnabled()) ? label.getIcon() :
...@@ -225,6 +257,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -225,6 +257,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return size; return size;
} }
/**
* @inheritDoc
*/
@Override
public Dimension getMaximumSize(JComponent c) { public Dimension getMaximumSize(JComponent c) {
JLabel label = (JLabel)c; JLabel label = (JLabel)c;
Icon icon = (label.isEnabled()) ? label.getIcon() : Icon icon = (label.isEnabled()) ? label.getIcon() :
...@@ -242,7 +278,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI { ...@@ -242,7 +278,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return size; return size;
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
super.propertyChange(e); super.propertyChange(e);
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
......
...@@ -27,38 +27,39 @@ package javax.swing.plaf.synth; ...@@ -27,38 +27,39 @@ package javax.swing.plaf.synth;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import javax.swing.text.Position;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.*;
import java.util.ArrayList;
import java.util.TooManyListenersException;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's ListUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JList}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthListUI extends BasicListUI implements PropertyChangeListener, public class SynthListUI extends BasicListUI
SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
private boolean useListColors; private boolean useListColors;
private boolean useUIBorder; private boolean useUIBorder;
/**
* Creates a new UI object for the given component.
*
* @param list component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent list) { public static ComponentUI createUI(JComponent list) {
return new SynthListUI(); return new SynthListUI();
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -69,27 +70,47 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener, ...@@ -69,27 +70,47 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
paint(g, c); paint(g, c);
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintListBorder(context, g, x, y, w, h); context.getPainter().paintListBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
list.addPropertyChangeListener(this); list.addPropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((JList)e.getSource()); updateStyle((JList)e.getSource());
} }
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
list.removePropertyChangeListener(this); list.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
if (list.getCellRenderer() == null || if (list.getCellRenderer() == null ||
(list.getCellRenderer() instanceof UIResource)) { (list.getCellRenderer() instanceof UIResource)) {
...@@ -135,6 +156,10 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener, ...@@ -135,6 +156,10 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
super.uninstallDefaults(); super.uninstallDefaults();
...@@ -145,6 +170,10 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener, ...@@ -145,6 +170,10 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -154,27 +183,23 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener, ...@@ -154,27 +183,23 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
private class SynthListCellRenderer extends DefaultListCellRenderer.UIResource { private class SynthListCellRenderer extends DefaultListCellRenderer.UIResource {
public String getName() { @Override public String getName() {
return "List.cellRenderer"; return "List.cellRenderer";
} }
public void setBorder(Border b) { @Override public void setBorder(Border b) {
if (useUIBorder || b instanceof SynthBorder) { if (useUIBorder || b instanceof SynthBorder) {
super.setBorder(b); super.setBorder(b);
} }
} }
public Component getListCellRendererComponent(JList list, Object value, @Override public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) { int index, boolean isSelected, boolean cellHasFocus) {
if (!useListColors && (isSelected || cellHasFocus)) { if (!useListColors && (isSelected || cellHasFocus)) {
SynthLookAndFeel.setSelectedUI((SynthLabelUI)SynthLookAndFeel. SynthLookAndFeel.setSelectedUI((SynthLabelUI)SynthLookAndFeel.
...@@ -190,7 +215,7 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener, ...@@ -190,7 +215,7 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
return this; return this;
} }
public void paint(Graphics g) { @Override public void paint(Graphics g) {
super.paint(g); super.paint(g);
SynthLookAndFeel.resetSelectedUI(); SynthLookAndFeel.resetSelectedUI();
} }
......
...@@ -234,44 +234,9 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -234,44 +234,9 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
* <code>shouldUpdateStyleOnAncestorChanged</code> as necessary. * <code>shouldUpdateStyleOnAncestorChanged</code> as necessary.
*/ */
static boolean shouldUpdateStyle(PropertyChangeEvent event) { static boolean shouldUpdateStyle(PropertyChangeEvent event) {
String eName = event.getPropertyName();
if ("name" == eName) {
// Always update on a name change
return true;
}
else if ("componentOrientation" == eName) {
// Always update on a component orientation change
return true;
}
else if ("ancestor" == eName && event.getNewValue() != null) {
// Only update on an ancestor change when getting a valid
// parent and the LookAndFeel wants this.
LookAndFeel laf = UIManager.getLookAndFeel(); LookAndFeel laf = UIManager.getLookAndFeel();
return (laf instanceof SynthLookAndFeel && return (laf instanceof SynthLookAndFeel &&
((SynthLookAndFeel)laf). ((SynthLookAndFeel) laf).shouldUpdateStyleOnEvent(event));
shouldUpdateStyleOnAncestorChanged());
}
// Note: The following two nimbus based overrides should be refactored
// to be in the Nimbus LAF. Due to constraints in an update release,
// we couldn't actually provide the public API necessary to allow
// NimbusLookAndFeel (a subclass of SynthLookAndFeel) to provide its
// own rules for shouldUpdateStyle.
else if ("Nimbus.Overrides" == eName) {
// Always update when the Nimbus.Overrides client property has
// been changed
return true;
}
else if ("Nimbus.Overrides.InheritDefaults" == eName) {
// Always update when the Nimbus.Overrides.InheritDefaults
// client property has changed
return true;
}
else if ("JComponent.sizeVariant" == eName) {
// Always update when the JComponent.sizeVariant
// client property has changed
return true;
}
return false;
} }
/** /**
...@@ -303,12 +268,6 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -303,12 +268,6 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
* @param c Component to update style for. * @param c Component to update style for.
*/ */
public static void updateStyles(Component c) { public static void updateStyles(Component c) {
_updateStyles(c);
c.repaint();
}
// Implementation for updateStyles
private static void _updateStyles(Component c) {
if (c instanceof JComponent) { if (c instanceof JComponent) {
// Yes, this is hacky. A better solution is to get the UI // Yes, this is hacky. A better solution is to get the UI
// and cast, but JComponent doesn't expose a getter for the UI // and cast, but JComponent doesn't expose a getter for the UI
...@@ -332,6 +291,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -332,6 +291,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
updateStyles(child); updateStyles(child);
} }
} }
c.repaint();
} }
/** /**
...@@ -788,6 +748,27 @@ public class SynthLookAndFeel extends BasicLookAndFeel { ...@@ -788,6 +748,27 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
return false; return false;
} }
/**
* Returns whether or not the UIs should update their styles when a
* particular event occurs.
*
* @param ev a {@code PropertyChangeEvent}
* @return whether or not the UIs should update their styles
* @since 1.7
*/
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev) {
String eName = ev.getPropertyName();
if ("name" == eName || "componentOrientation" == eName) {
return true;
}
if ("ancestor" == eName && ev.getNewValue() != null) {
// Only update on an ancestor change when getting a valid
// parent and the LookAndFeel wants this.
return shouldUpdateStyleOnAncestorChanged();
}
return false;
}
/** /**
* Returns the antialiasing information as specified by the host desktop. * Returns the antialiasing information as specified by the host desktop.
* Antialiasing might be forced off if the desktop is GNOME and the user * Antialiasing might be forced off if the desktop is GNOME and the user
......
...@@ -25,45 +25,49 @@ ...@@ -25,45 +25,49 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.*;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's MenuBarUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JMenuBar}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener, public class SynthMenuBarUI extends BasicMenuBarUI
SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
/**
* Creates a new UI object for the given component.
*
* @param x component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent x) { public static ComponentUI createUI(JComponent x) {
return new SynthMenuBarUI(); return new SynthMenuBarUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
if (menuBar.getLayout() == null || if (menuBar.getLayout() == null ||
menuBar.getLayout() instanceof UIResource) { menuBar.getLayout() instanceof UIResource) {
menuBar.setLayout(new DefaultMenuLayout(menuBar,BoxLayout.LINE_AXIS)); menuBar.setLayout(new SynthMenuLayout(menuBar,BoxLayout.LINE_AXIS));
} }
updateStyle(menuBar); updateStyle(menuBar);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
menuBar.addPropertyChangeListener(this); menuBar.addPropertyChangeListener(this);
...@@ -82,6 +86,10 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener, ...@@ -82,6 +86,10 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(menuBar, ENABLED); SynthContext context = getContext(menuBar, ENABLED);
...@@ -90,11 +98,19 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener, ...@@ -90,11 +98,19 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
menuBar.removePropertyChangeListener(this); menuBar.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -104,14 +120,14 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener, ...@@ -104,14 +120,14 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -122,6 +138,10 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener, ...@@ -122,6 +138,10 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -129,14 +149,28 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener, ...@@ -129,14 +149,28 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintMenuBarBorder(context, g, x, y, w, h); context.getPainter().paintMenuBarBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((JMenuBar)e.getSource()); updateStyle((JMenuBar)e.getSource());
......
...@@ -24,41 +24,44 @@ ...@@ -24,41 +24,44 @@
*/ */
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import javax.swing.plaf.basic.BasicHTML;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import javax.swing.text.View;
import sun.swing.plaf.synth.*;
import sun.swing.MenuItemLayoutHelper; import sun.swing.MenuItemLayoutHelper;
/** /**
* Synth's MenuItemUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JMenuItem}.
* *
* @author Georges Saab * @author Georges Saab
* @author David Karlton * @author David Karlton
* @author Arnaud Weber * @author Arnaud Weber
* @author Fredrik Lagerblad * @author Fredrik Lagerblad
* @since 1.7
*/ */
class SynthMenuItemUI extends BasicMenuItemUI implements public class SynthMenuItemUI extends BasicMenuItemUI implements
PropertyChangeListener, SynthUI { PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
private SynthStyle accStyle; private SynthStyle accStyle;
private String acceleratorDelimiter; /**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthMenuItemUI(); return new SynthMenuItemUI();
} }
/**
* @inheritDoc
*/
@Override
public void uninstallUI(JComponent c) { public void uninstallUI(JComponent c) {
super.uninstallUI(c); super.uninstallUI(c);
// Remove values from the parent's Client Properties. // Remove values from the parent's Client Properties.
...@@ -69,10 +72,18 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -69,10 +72,18 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
updateStyle(menuItem); updateStyle(menuItem);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
menuItem.addPropertyChangeListener(this); menuItem.addPropertyChangeListener(this);
...@@ -122,6 +133,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -122,6 +133,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
accContext.dispose(); accContext.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(menuItem, ENABLED); SynthContext context = getContext(menuItem, ENABLED);
style.uninstallDefaults(context); style.uninstallDefaults(context);
...@@ -137,11 +152,19 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -137,11 +152,19 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
super.uninstallDefaults(); super.uninstallDefaults();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
menuItem.removePropertyChangeListener(this); menuItem.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -151,7 +174,7 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -151,7 +174,7 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
public SynthContext getContext(JComponent c, Region region) { SynthContext getContext(JComponent c, Region region) {
return getContext(c, region, getComponentState(c, region)); return getContext(c, region, getComponentState(c, region));
} }
...@@ -160,10 +183,6 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -160,10 +183,6 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
region, accStyle, state); region, accStyle, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
int state; int state;
...@@ -186,6 +205,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -186,6 +205,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
return getComponentState(c); return getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
protected Dimension getPreferredMenuItemSize(JComponent c, protected Dimension getPreferredMenuItemSize(JComponent c,
Icon checkIcon, Icon checkIcon,
Icon arrowIcon, Icon arrowIcon,
...@@ -203,6 +226,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -203,6 +226,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -212,6 +239,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -212,6 +239,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -219,6 +250,12 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -219,6 +250,12 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
SynthContext accContext = getContext(menuItem, SynthContext accContext = getContext(menuItem,
Region.MENU_ITEM_ACCELERATOR); Region.MENU_ITEM_ACCELERATOR);
...@@ -236,11 +273,19 @@ class SynthMenuItemUI extends BasicMenuItemUI implements ...@@ -236,11 +273,19 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
SynthGraphicsUtils.paintBackground(context, g, c); SynthGraphicsUtils.paintBackground(context, g, c);
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintMenuItemBorder(context, g, x, y, w, h); context.getPainter().paintMenuItemBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((JMenuItem)e.getSource()); updateStyle((JMenuItem)e.getSource());
......
...@@ -25,44 +25,29 @@ ...@@ -25,44 +25,29 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import javax.swing.*; import javax.swing.plaf.basic.DefaultMenuLayout;
import javax.swing.plaf.UIResource; import javax.swing.JPopupMenu;
import java.awt.Container; import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
/** /**
* The default layout manager for Popup menus and menubars. This * @inheritDoc
* class is an extension of BoxLayout which adds the UIResource tag
* so that plauggable L&Fs can distinguish it from user-installed
* layout managers on menus.
*
* Derived from javax.swing.plaf.basic.DefaultMenuLayout
* *
* @author Georges Saab * @author Georges Saab
*/ */
class DefaultMenuLayout extends BoxLayout implements UIResource { class SynthMenuLayout extends DefaultMenuLayout {
public DefaultMenuLayout(Container target, int axis) { public SynthMenuLayout(Container target, int axis) {
super(target, axis); super(target, axis);
} }
public Dimension preferredLayoutSize(Container target) { public Dimension preferredLayoutSize(Container target) {
if (target instanceof JPopupMenu) { if (target instanceof JPopupMenu) {
JPopupMenu popupMenu = (JPopupMenu) target; JPopupMenu popupMenu = (JPopupMenu) target;
popupMenu.putClientProperty( popupMenu.putClientProperty(
SynthMenuItemLayoutHelper.MAX_ACC_OR_ARROW_WIDTH, null); SynthMenuItemLayoutHelper.MAX_ACC_OR_ARROW_WIDTH, null);
sun.swing.MenuItemLayoutHelper.clearUsedClientProperties(popupMenu);
if (popupMenu.getComponentCount() == 0) {
return new Dimension(0, 0);
}
} }
// Make BoxLayout recalculate cached preferred sizes
super.invalidateLayout(target);
return super.preferredLayoutSize(target); return super.preferredLayoutSize(target);
} }
} }
...@@ -25,40 +25,48 @@ ...@@ -25,40 +25,48 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.beans.*; import java.beans.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import javax.swing.border.*;
import java.util.Arrays;
import java.util.ArrayList;
import sun.swing.plaf.synth.SynthUI;
import sun.swing.MenuItemLayoutHelper; import sun.swing.MenuItemLayoutHelper;
/** /**
* Synth's MenuUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JMenu}.
* *
* @author Georges Saab * @author Georges Saab
* @author David Karlton * @author David Karlton
* @author Arnaud Weber * @author Arnaud Weber
* @since 1.7
*/ */
class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, public class SynthMenuUI extends BasicMenuUI
SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
private SynthStyle accStyle; private SynthStyle accStyle;
private String acceleratorDelimiter; /**
* Creates a new UI object for the given component.
*
* @param x component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent x) { public static ComponentUI createUI(JComponent x) {
return new SynthMenuUI(); return new SynthMenuUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
updateStyle(menuItem); updateStyle(menuItem);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
menuItem.addPropertyChangeListener(this); menuItem.addPropertyChangeListener(this);
...@@ -111,6 +119,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -111,6 +119,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
accContext.dispose(); accContext.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void uninstallUI(JComponent c) { public void uninstallUI(JComponent c) {
super.uninstallUI(c); super.uninstallUI(c);
// Remove values from the parent's Client Properties. // Remove values from the parent's Client Properties.
...@@ -121,6 +133,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -121,6 +133,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
} }
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(menuItem, ENABLED); SynthContext context = getContext(menuItem, ENABLED);
style.uninstallDefaults(context); style.uninstallDefaults(context);
...@@ -136,22 +152,30 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -136,22 +152,30 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
super.uninstallDefaults(); super.uninstallDefaults();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
menuItem.removePropertyChangeListener(this); menuItem.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
SynthContext getContext(JComponent c, int state) { SynthContext getContext(JComponent c, int state) {
Region region = getRegion(c); Region region = SynthLookAndFeel.getRegion(c);
return SynthContext.getContext(SynthContext.class, c, region, return SynthContext.getContext(SynthContext.class, c, region,
style, state); style, state);
} }
public SynthContext getContext(JComponent c, Region region) { SynthContext getContext(JComponent c, Region region) {
return getContext(c, region, getComponentState(c, region)); return getContext(c, region, getComponentState(c, region));
} }
...@@ -160,10 +184,6 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -160,10 +184,6 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
region, accStyle, state); region, accStyle, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
int state; int state;
...@@ -186,6 +206,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -186,6 +206,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
return getComponentState(c); return getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
protected Dimension getPreferredMenuItemSize(JComponent c, protected Dimension getPreferredMenuItemSize(JComponent c,
Icon checkIcon, Icon checkIcon,
Icon arrowIcon, Icon arrowIcon,
...@@ -202,7 +226,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -202,7 +226,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
return value; return value;
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -213,6 +240,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -213,6 +240,10 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -220,6 +251,12 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -220,6 +251,12 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
SynthContext accContext = getContext(menuItem, SynthContext accContext = getContext(menuItem,
Region.MENU_ITEM_ACCELERATOR); Region.MENU_ITEM_ACCELERATOR);
...@@ -232,11 +269,19 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener, ...@@ -232,11 +269,19 @@ class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
accContext.dispose(); accContext.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintMenuBorder(context, g, x, y, w, h); context.getPainter().paintMenuBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((JMenu)e.getSource()); updateStyle((JMenu)e.getSource());
......
...@@ -28,34 +28,45 @@ package javax.swing.plaf.synth; ...@@ -28,34 +28,45 @@ package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.beans.*; import java.beans.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import sun.swing.DefaultLookup; import sun.swing.DefaultLookup;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's OptionPaneUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JOptionPane}.
* *
* @author James Gosling * @author James Gosling
* @author Scott Violet * @author Scott Violet
* @author Amy Fowler * @author Amy Fowler
* @since 1.7
*/ */
class SynthOptionPaneUI extends BasicOptionPaneUI implements public class SynthOptionPaneUI extends BasicOptionPaneUI implements
PropertyChangeListener, SynthUI { PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
/** /**
* Creates a new BasicOptionPaneUI instance. * Creates a new UI object for the given component.
*
* @param x component to create UI object for
* @return the UI object
*/ */
public static ComponentUI createUI(JComponent x) { public static ComponentUI createUI(JComponent x) {
return new SynthOptionPaneUI(); return new SynthOptionPaneUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
updateStyle(optionPane); updateStyle(optionPane);
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
optionPane.addPropertyChangeListener(this); optionPane.addPropertyChangeListener(this);
...@@ -80,6 +91,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements ...@@ -80,6 +91,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(optionPane, ENABLED); SynthContext context = getContext(optionPane, ENABLED);
...@@ -88,11 +103,19 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements ...@@ -88,11 +103,19 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
optionPane.removePropertyChangeListener(this); optionPane.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void installComponents() { protected void installComponents() {
optionPane.add(createMessageArea()); optionPane.add(createMessageArea());
...@@ -108,6 +131,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements ...@@ -108,6 +131,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements
optionPane.applyComponentOrientation(optionPane.getComponentOrientation()); optionPane.applyComponentOrientation(optionPane.getComponentOrientation());
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -117,14 +144,14 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements ...@@ -117,14 +144,14 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -135,6 +162,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements ...@@ -135,6 +162,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -142,30 +173,49 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements ...@@ -142,30 +173,49 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintOptionPaneBorder(context, g, x, y, w, h); context.getPainter().paintOptionPaneBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((JOptionPane)e.getSource()); updateStyle((JOptionPane)e.getSource());
} }
} }
/**
* @inheritDoc
*/
@Override
protected boolean getSizeButtonsToSameWidth() { protected boolean getSizeButtonsToSameWidth() {
return DefaultLookup.getBoolean(optionPane, this, return DefaultLookup.getBoolean(optionPane, this,
"OptionPane.sameSizeButtons", true); "OptionPane.sameSizeButtons", true);
} }
/** /**
* Messaged from installComponents to create a Container containing the * Called from {@link #installComponents} to create a {@code Container}
* body of the message. The icon is the created by calling * containing the body of the message. The icon is the created by calling
* <code>addIcon</code>. * {@link #addIcon}.
*/ */
@Override
protected Container createMessageArea() { protected Container createMessageArea() {
JPanel top = new JPanel(); JPanel top = new JPanel();
top.setName("OptionPane.messageArea"); top.setName("OptionPane.messageArea");
...@@ -206,6 +256,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements ...@@ -206,6 +256,10 @@ class SynthOptionPaneUI extends BasicOptionPaneUI implements
return top; return top;
} }
/**
* @inheritDoc
*/
@Override
protected Container createSeparator() { protected Container createSeparator() {
JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL); JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import javax.swing.*;
/** /**
* <code>SynthPainter</code> is used for painting portions of * <code>SynthPainter</code> is used for painting portions of
......
...@@ -25,29 +25,37 @@ ...@@ -25,29 +25,37 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicPanelUI; import javax.swing.plaf.basic.BasicPanelUI;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.beans.*; import java.beans.*;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's PanelUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JPanel}.
* *
* @author Steve Wilson * @author Steve Wilson
* @since 1.7
*/ */
class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener, public class SynthPanelUI extends BasicPanelUI
SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthPanelUI(); return new SynthPanelUI();
} }
/**
* @inheritDoc
*/
@Override
public void installUI(JComponent c) { public void installUI(JComponent c) {
JPanel p = (JPanel)c; JPanel p = (JPanel)c;
...@@ -55,6 +63,10 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener, ...@@ -55,6 +63,10 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener,
installListeners(p); installListeners(p);
} }
/**
* @inheritDoc
*/
@Override
public void uninstallUI(JComponent c) { public void uninstallUI(JComponent c) {
JPanel p = (JPanel)c; JPanel p = (JPanel)c;
...@@ -62,18 +74,36 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener, ...@@ -62,18 +74,36 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener,
super.uninstallUI(c); super.uninstallUI(c);
} }
/**
* Installs listeners into the panel.
*
* @param p the {@code JPanel} object
*/
protected void installListeners(JPanel p) { protected void installListeners(JPanel p) {
p.addPropertyChangeListener(this); p.addPropertyChangeListener(this);
} }
/**
* Uninstalls listeners from the panel.
*
* @param p the {@code JPanel} object
*/
protected void uninstallListeners(JPanel p) { protected void uninstallListeners(JPanel p) {
p.removePropertyChangeListener(this); p.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults(JPanel p) { protected void installDefaults(JPanel p) {
updateStyle(p); updateStyle(p);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults(JPanel p) { protected void uninstallDefaults(JPanel p) {
SynthContext context = getContext(p, ENABLED); SynthContext context = getContext(p, ENABLED);
...@@ -88,6 +118,10 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener, ...@@ -88,6 +118,10 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -97,14 +131,14 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener, ...@@ -97,14 +131,14 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener,
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -115,6 +149,10 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener, ...@@ -115,6 +149,10 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -122,15 +160,29 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener, ...@@ -122,15 +160,29 @@ class SynthPanelUI extends BasicPanelUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
// do actual painting // do actual painting
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintPanelBorder(context, g, x, y, w, h); context.getPainter().paintPanelBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent pce) { public void propertyChange(PropertyChangeEvent pce) {
if (SynthLookAndFeel.shouldUpdateStyle(pce)) { if (SynthLookAndFeel.shouldUpdateStyle(pce)) {
updateStyle((JPanel)pce.getSource()); updateStyle((JPanel)pce.getSource());
......
...@@ -25,21 +25,19 @@ ...@@ -25,21 +25,19 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*; import java.awt.Graphics;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import javax.swing.plaf.*; import javax.swing.plaf.ComponentUI;
/** /**
* Provides the Synth look and feel for a password field. * Provides the Synth L&F UI delegate for
* The only difference from the standard text field is that * {@link javax.swing.JPasswordField}.
* the view of the text is simply a string of the echo
* character as specified in JPasswordField, rather than the
* real text contained in the field.
* *
* @author Shannon Hickey * @author Shannon Hickey
* @since 1.7
*/ */
class SynthPasswordFieldUI extends SynthTextFieldUI { public class SynthPasswordFieldUI extends SynthTextFieldUI {
/** /**
* Creates a UI for a JPasswordField. * Creates a UI for a JPasswordField.
...@@ -58,6 +56,7 @@ class SynthPasswordFieldUI extends SynthTextFieldUI { ...@@ -58,6 +56,7 @@ class SynthPasswordFieldUI extends SynthTextFieldUI {
* *
* @return the name ("PasswordField") * @return the name ("PasswordField")
*/ */
@Override
protected String getPropertyPrefix() { protected String getPropertyPrefix() {
return "PasswordField"; return "PasswordField";
} }
...@@ -68,20 +67,33 @@ class SynthPasswordFieldUI extends SynthTextFieldUI { ...@@ -68,20 +67,33 @@ class SynthPasswordFieldUI extends SynthTextFieldUI {
* @param elem the element * @param elem the element
* @return the view * @return the view
*/ */
@Override
public View create(Element elem) { public View create(Element elem) {
return new PasswordView(elem); return new PasswordView(elem);
} }
/**
* @inheritDoc
*/
@Override
void paintBackground(SynthContext context, Graphics g, JComponent c) { void paintBackground(SynthContext context, Graphics g, JComponent c) {
context.getPainter().paintPasswordFieldBackground(context, g, 0, 0, context.getPainter().paintPasswordFieldBackground(context, g, 0, 0,
c.getWidth(), c.getHeight()); c.getWidth(), c.getHeight());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintPasswordFieldBorder(context, g, x, y, w, h); context.getPainter().paintPasswordFieldBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
protected void installKeyboardActions() { protected void installKeyboardActions() {
super.installKeyboardActions(); super.installKeyboardActions();
ActionMap map = SwingUtilities.getUIActionMap(getComponent()); ActionMap map = SwingUtilities.getUIActionMap(getComponent());
......
...@@ -26,49 +26,43 @@ ...@@ -26,49 +26,43 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import javax.swing.border.*;
import java.applet.Applet;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.KeyboardFocusManager;
import java.awt.Window;
import java.awt.event.*;
import java.awt.AWTEvent;
import java.awt.Toolkit;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.util.*;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's PopupMenuUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JPopupMenu}.
* *
* @author Georges Saab * @author Georges Saab
* @author David Karlton * @author David Karlton
* @author Arnaud Weber * @author Arnaud Weber
* @since 1.7
*/ */
class SynthPopupMenuUI extends BasicPopupMenuUI implements public class SynthPopupMenuUI extends BasicPopupMenuUI
PropertyChangeListener, SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
/**
* Creates a new UI object for the given component.
*
* @param x component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent x) { public static ComponentUI createUI(JComponent x) {
return new SynthPopupMenuUI(); return new SynthPopupMenuUI();
} }
/**
* @inheritDoc
*/
@Override
public void installDefaults() { public void installDefaults() {
if (popupMenu.getLayout() == null || if (popupMenu.getLayout() == null ||
popupMenu.getLayout() instanceof UIResource) { popupMenu.getLayout() instanceof UIResource) {
popupMenu.setLayout(new DefaultMenuLayout( popupMenu.setLayout(new SynthMenuLayout(popupMenu, BoxLayout.Y_AXIS));
popupMenu, BoxLayout.Y_AXIS));
} }
updateStyle(popupMenu); updateStyle(popupMenu);
} }
...@@ -86,11 +80,19 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements ...@@ -86,11 +80,19 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
popupMenu.addPropertyChangeListener(this); popupMenu.addPropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(popupMenu, ENABLED); SynthContext context = getContext(popupMenu, ENABLED);
...@@ -103,11 +105,19 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements ...@@ -103,11 +105,19 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
popupMenu.removePropertyChangeListener(this); popupMenu.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -117,14 +127,14 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements ...@@ -117,14 +127,14 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -135,6 +145,10 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements ...@@ -135,6 +145,10 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -142,14 +156,28 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements ...@@ -142,14 +156,28 @@ class SynthPopupMenuUI extends BasicPopupMenuUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintPopupMenuBorder(context, g, x, y, w, h); context.getPainter().paintPopupMenuBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle(popupMenu); updateStyle(popupMenu);
......
...@@ -32,16 +32,17 @@ import javax.swing.plaf.*; ...@@ -32,16 +32,17 @@ import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicProgressBarUI; import javax.swing.plaf.basic.BasicProgressBarUI;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import sun.swing.plaf.synth.SynthUI;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
/** /**
* Synth's ProgressBarUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JProgressBar}.
* *
* @author Joshua Outwater * @author Joshua Outwater
* @since 1.7
*/ */
class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, public class SynthProgressBarUI extends BasicProgressBarUI
PropertyChangeListener { implements SynthUI, PropertyChangeListener {
private SynthStyle style; private SynthStyle style;
private int progressPadding; private int progressPadding;
private boolean rotateText; // added for Nimbus LAF private boolean rotateText; // added for Nimbus LAF
...@@ -49,22 +50,37 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -49,22 +50,37 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
private boolean tileWhenIndeterminate; //whether to tile indeterminate painting private boolean tileWhenIndeterminate; //whether to tile indeterminate painting
private int tileWidth; //the width of each tile private int tileWidth; //the width of each tile
/**
* Creates a new UI object for the given component.
*
* @param x component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent x) { public static ComponentUI createUI(JComponent x) {
return new SynthProgressBarUI(); return new SynthProgressBarUI();
} }
/**
* @inheritDoc
*/
@Override @Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
progressBar.addPropertyChangeListener(this); progressBar.addPropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override @Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
progressBar.removePropertyChangeListener(this); progressBar.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override @Override
protected void installDefaults() { protected void installDefaults() {
updateStyle(progressBar); updateStyle(progressBar);
...@@ -101,6 +117,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -101,6 +117,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override @Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
SynthContext context = getContext(progressBar, ENABLED); SynthContext context = getContext(progressBar, ENABLED);
...@@ -110,6 +129,10 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -110,6 +129,10 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -119,14 +142,13 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -119,14 +142,13 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override @Override
public int getBaseline(JComponent c, int width, int height) { public int getBaseline(JComponent c, int width, int height) {
super.getBaseline(c, width, height); super.getBaseline(c, width, height);
...@@ -142,6 +164,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -142,6 +164,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
return -1; return -1;
} }
/**
* @inheritDoc
*/
@Override @Override
protected Rectangle getBox(Rectangle r) { protected Rectangle getBox(Rectangle r) {
if (tileWhenIndeterminate) { if (tileWhenIndeterminate) {
...@@ -151,6 +176,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -151,6 +176,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
} }
} }
/**
* @inheritDoc
*/
@Override @Override
protected void setAnimationIndex(int newValue) { protected void setAnimationIndex(int newValue) {
if (paintOutsideClip) { if (paintOutsideClip) {
...@@ -164,6 +192,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -164,6 +192,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
} }
} }
/**
* @inheritDoc
*/
@Override @Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -176,6 +207,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -176,6 +207,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -184,6 +218,12 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -184,6 +218,12 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
JProgressBar pBar = (JProgressBar)context.getComponent(); JProgressBar pBar = (JProgressBar)context.getComponent();
int x = 0, y = 0, width = 0, height = 0; int x = 0, y = 0, width = 0, height = 0;
...@@ -261,8 +301,14 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -261,8 +301,14 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
} }
} }
protected void paintText(SynthContext context, Graphics g, /**
String title) { * Paints the component's text.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param title the text to paint
*/
protected void paintText(SynthContext context, Graphics g, String title) {
if (progressBar.isStringPainted()) { if (progressBar.isStringPainted()) {
SynthStyle style = context.getStyle(); SynthStyle style = context.getStyle();
Font font = style.getFont(context); Font font = style.getFont(context);
...@@ -323,12 +369,20 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -323,12 +369,20 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
} }
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintProgressBarBorder(context, g, x, y, w, h, context.getPainter().paintProgressBarBorder(context, g, x, y, w, h,
progressBar.getOrientation()); progressBar.getOrientation());
} }
/**
* @inheritDoc
*/
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e) || if (SynthLookAndFeel.shouldUpdateStyle(e) ||
"indeterminate".equals(e.getPropertyName())) { "indeterminate".equals(e.getPropertyName())) {
...@@ -336,6 +390,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI, ...@@ -336,6 +390,9 @@ class SynthProgressBarUI extends BasicProgressBarUI implements SynthUI,
} }
} }
/**
* @inheritDoc
*/
@Override @Override
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
Dimension size = null; Dimension size = null;
......
...@@ -27,49 +27,46 @@ package javax.swing.plaf.synth; ...@@ -27,49 +27,46 @@ package javax.swing.plaf.synth;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.border.*;
/** /**
* Synth's RadioButtonMenuItemUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JRadioButtonMenuItem}.
* *
* @author Georges Saab * @author Georges Saab
* @author David Karlton * @author David Karlton
* @since 1.7
*/
public class SynthRadioButtonMenuItemUI extends SynthMenuItemUI {
/**
* Creates a new UI object for the given component.
*
* @param b component to create UI object for
* @return the UI object
*/ */
class SynthRadioButtonMenuItemUI extends SynthMenuItemUI {
public static ComponentUI createUI(JComponent b) { public static ComponentUI createUI(JComponent b) {
return new SynthRadioButtonMenuItemUI(); return new SynthRadioButtonMenuItemUI();
} }
/**
* @inheritDoc
*/
@Override
protected String getPropertyPrefix() { protected String getPropertyPrefix() {
return "RadioButtonMenuItem"; return "RadioButtonMenuItem";
} }
public void processMouseEvent(JMenuItem item,MouseEvent e,MenuElement path[],MenuSelectionManager manager) { @Override
Point p = e.getPoint();
if(p.x >= 0 && p.x < item.getWidth() &&
p.y >= 0 && p.y < item.getHeight()) {
if(e.getID() == MouseEvent.MOUSE_RELEASED) {
manager.clearSelectedPath();
item.doClick(0);
item.setArmed(false);
} else
manager.setSelectedPath(path);
} else if(item.getModel().isArmed()) {
MenuElement newPath[] = new MenuElement[path.length-1];
int i,c;
for(i=0,c=path.length-1;i<c;i++)
newPath[i] = path[i];
manager.setSelectedPath(newPath);
}
}
void paintBackground(SynthContext context, Graphics g, JComponent c) { void paintBackground(SynthContext context, Graphics g, JComponent c) {
context.getPainter().paintRadioButtonMenuItemBackground(context, g, 0, context.getPainter().paintRadioButtonMenuItemBackground(context, g, 0,
0, c.getWidth(), c.getHeight()); 0, c.getWidth(), c.getHeight());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintRadioButtonMenuItemBorder(context, g, x, context.getPainter().paintRadioButtonMenuItemBorder(context, g, x,
......
...@@ -26,42 +26,58 @@ ...@@ -26,42 +26,58 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.text.View;
/** /**
* Synth's RadioButtonUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JRadioButton}.
* *
* @author Jeff Dinkins * @author Jeff Dinkins
* @since 1.7
*/ */
class SynthRadioButtonUI extends SynthToggleButtonUI { public class SynthRadioButtonUI extends SynthToggleButtonUI {
// ******************************** // ********************************
// Create PLAF // Create PLAF
// ******************************** // ********************************
/**
* Creates a new UI object for the given component.
*
* @param b component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent b) { public static ComponentUI createUI(JComponent b) {
return new SynthRadioButtonUI(); return new SynthRadioButtonUI();
} }
/**
* @inheritDoc
*/
@Override
protected String getPropertyPrefix() { protected String getPropertyPrefix() {
return "RadioButton."; return "RadioButton.";
} }
/** /**
* Returns the Icon used in calculating the pref/min/max size. * Returns the Icon used in calculating the
* preferred/minimum/maximum size.
*/ */
@Override
protected Icon getSizingIcon(AbstractButton b) { protected Icon getSizingIcon(AbstractButton b) {
return getIcon(b); return getIcon(b);
} }
@Override
void paintBackground(SynthContext context, Graphics g, JComponent c) { void paintBackground(SynthContext context, Graphics g, JComponent c) {
context.getPainter().paintRadioButtonBackground(context, g, 0, 0, context.getPainter().paintRadioButtonBackground(context, g, 0, 0,
c.getWidth(), c.getHeight()); c.getWidth(), c.getHeight());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintRadioButtonBorder(context, g, x, y, w, h); context.getPainter().paintRadioButtonBorder(context, g, x, y, w, h);
......
...@@ -26,30 +26,43 @@ ...@@ -26,30 +26,43 @@
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicRootPaneUI; import javax.swing.plaf.basic.BasicRootPaneUI;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's RootPaneUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JRootPane}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
private SynthStyle style; private SynthStyle style;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthRootPaneUI(); return new SynthRootPaneUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults(JRootPane c){ protected void installDefaults(JRootPane c){
updateStyle(c); updateStyle(c);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults(JRootPane root) { protected void uninstallDefaults(JRootPane root) {
SynthContext context = getContext(root, ENABLED); SynthContext context = getContext(root, ENABLED);
...@@ -58,6 +71,10 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { ...@@ -58,6 +71,10 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
style = null; style = null;
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -67,10 +84,6 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { ...@@ -67,10 +84,6 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
...@@ -88,6 +101,10 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { ...@@ -88,6 +101,10 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -98,6 +115,10 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { ...@@ -98,6 +115,10 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -105,9 +126,19 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { ...@@ -105,9 +126,19 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
context.dispose(); context.dispose();
} }
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintRootPaneBorder(context, g, x, y, w, h); context.getPainter().paintRootPaneBorder(context, g, x, y, w, h);
...@@ -118,6 +149,7 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { ...@@ -118,6 +149,7 @@ class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
* indicates the <code>defaultButton</code> has changed, this will * indicates the <code>defaultButton</code> has changed, this will
* reinstall the keyboard actions. * reinstall the keyboard actions.
*/ */
@Override
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) { if (SynthLookAndFeel.shouldUpdateStyle(e)) {
updateStyle((JRootPane)e.getSource()); updateStyle((JRootPane)e.getSource());
......
...@@ -30,41 +30,33 @@ import java.beans.*; ...@@ -30,41 +30,33 @@ import java.beans.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's ScrollBarUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JScrollBar}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthScrollBarUI extends BasicScrollBarUI implements public class SynthScrollBarUI extends BasicScrollBarUI
PropertyChangeListener, SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
private SynthStyle thumbStyle; private SynthStyle thumbStyle;
private SynthStyle trackStyle; private SynthStyle trackStyle;
private boolean validMinimumThumbSize; private boolean validMinimumThumbSize;
private int scrollBarWidth;
//These two variables should be removed when the corrosponding ones in BasicScrollBarUI are made protected
private int incrGap;
private int decrGap;
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthScrollBarUI(); return new SynthScrollBarUI();
} }
/**
* @inheritDoc
*/
@Override
protected void installDefaults() { protected void installDefaults() {
//NOTE: This next line of code was added because, since incrGap and decrGap in
//BasicScrollBarUI are private, I need to have some way of updating them.
//This is an incomplete solution (since it implies that the incrGap and decrGap
//are set once, and not reset per state. Probably ok, but not always ok).
//This line of code should be removed at the same time that incrGap and
//decrGap are removed and made protected in the super class.
super.installDefaults();
trackHighlight = NO_HIGHLIGHT; trackHighlight = NO_HIGHLIGHT;
if (scrollbar.getLayout() == null || if (scrollbar.getLayout() == null ||
(scrollbar.getLayout() instanceof UIResource)) { (scrollbar.getLayout() instanceof UIResource)) {
...@@ -73,6 +65,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -73,6 +65,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
updateStyle(scrollbar); updateStyle(scrollbar);
} }
/**
* @inheritDoc
*/
@Override
protected void configureScrollBarColors() { protected void configureScrollBarColors() {
} }
...@@ -137,16 +133,28 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -137,16 +133,28 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
scrollbar.addPropertyChangeListener(this); scrollbar.addPropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
scrollbar.removePropertyChangeListener(this); scrollbar.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
protected void uninstallDefaults(){ protected void uninstallDefaults(){
SynthContext context = getContext(scrollbar, ENABLED); SynthContext context = getContext(scrollbar, ENABLED);
style.uninstallDefaults(context); style.uninstallDefaults(context);
...@@ -166,9 +174,12 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -166,9 +174,12 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
super.uninstallDefaults(); super.uninstallDefaults();
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, SynthLookAndFeel.getComponentState(c));
} }
private SynthContext getContext(JComponent c, int state) { private SynthContext getContext(JComponent c, int state) {
...@@ -176,14 +187,6 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -176,14 +187,6 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c);
}
private SynthContext getContext(JComponent c, Region region) { private SynthContext getContext(JComponent c, Region region) {
return getContext(c, region, getComponentState(c, region)); return getContext(c, region, getComponentState(c, region));
} }
...@@ -206,6 +209,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -206,6 +209,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
return SynthLookAndFeel.getComponentState(c); return SynthLookAndFeel.getComponentState(c);
} }
/**
* @inheritDoc
*/
@Override
public boolean getSupportsAbsolutePositioning() { public boolean getSupportsAbsolutePositioning() {
SynthContext context = getContext(scrollbar); SynthContext context = getContext(scrollbar);
boolean value = style.getBoolean(context, boolean value = style.getBoolean(context,
...@@ -214,6 +221,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -214,6 +221,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
return value; return value;
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -225,6 +236,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -225,6 +236,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -232,6 +247,12 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -232,6 +247,12 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
SynthContext subcontext = getContext(scrollbar, SynthContext subcontext = getContext(scrollbar,
Region.SCROLL_BAR_TRACK); Region.SCROLL_BAR_TRACK);
...@@ -243,31 +264,49 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -243,31 +264,49 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
subcontext.dispose(); subcontext.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintScrollBarBorder(context, g, x, y, w, h, context.getPainter().paintScrollBarBorder(context, g, x, y, w, h,
scrollbar.getOrientation()); scrollbar.getOrientation());
} }
protected void paintTrack(SynthContext ss, Graphics g, /**
* Paints the scrollbar track.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param trackBounds bounding box for the track
*/
protected void paintTrack(SynthContext context, Graphics g,
Rectangle trackBounds) { Rectangle trackBounds) {
SynthLookAndFeel.updateSubregion(ss, g, trackBounds); SynthLookAndFeel.updateSubregion(context, g, trackBounds);
ss.getPainter().paintScrollBarTrackBackground(ss, g, trackBounds.x, context.getPainter().paintScrollBarTrackBackground(context, g, trackBounds.x,
trackBounds.y, trackBounds.width, trackBounds.height, trackBounds.y, trackBounds.width, trackBounds.height,
scrollbar.getOrientation()); scrollbar.getOrientation());
ss.getPainter().paintScrollBarTrackBorder(ss, g, trackBounds.x, context.getPainter().paintScrollBarTrackBorder(context, g, trackBounds.x,
trackBounds.y, trackBounds.width, trackBounds.height, trackBounds.y, trackBounds.width, trackBounds.height,
scrollbar.getOrientation()); scrollbar.getOrientation());
} }
protected void paintThumb(SynthContext ss, Graphics g, /**
* Paints the scrollbar thumb.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
* @param thumbBounds bounding box for the thumb
*/
protected void paintThumb(SynthContext context, Graphics g,
Rectangle thumbBounds) { Rectangle thumbBounds) {
SynthLookAndFeel.updateSubregion(ss, g, thumbBounds); SynthLookAndFeel.updateSubregion(context, g, thumbBounds);
int orientation = scrollbar.getOrientation(); int orientation = scrollbar.getOrientation();
ss.getPainter().paintScrollBarThumbBackground(ss, g, thumbBounds.x, context.getPainter().paintScrollBarThumbBackground(context, g, thumbBounds.x,
thumbBounds.y, thumbBounds.width, thumbBounds.height, thumbBounds.y, thumbBounds.width, thumbBounds.height,
orientation); orientation);
ss.getPainter().paintScrollBarThumbBorder(ss, g, thumbBounds.x, context.getPainter().paintScrollBarThumbBorder(context, g, thumbBounds.x,
thumbBounds.y, thumbBounds.width, thumbBounds.height, thumbBounds.y, thumbBounds.width, thumbBounds.height,
orientation); orientation);
} }
...@@ -288,6 +327,7 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -288,6 +327,7 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
* @see #getMaximumSize * @see #getMaximumSize
* @see #getMinimumSize * @see #getMinimumSize
*/ */
@Override
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
Insets insets = c.getInsets(); Insets insets = c.getInsets();
return (scrollbar.getOrientation() == JScrollBar.VERTICAL) return (scrollbar.getOrientation() == JScrollBar.VERTICAL)
...@@ -295,6 +335,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -295,6 +335,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
: new Dimension(48, scrollBarWidth + insets.top + insets.bottom); : new Dimension(48, scrollBarWidth + insets.top + insets.bottom);
} }
/**
* @inheritDoc
*/
@Override
protected Dimension getMinimumThumbSize() { protected Dimension getMinimumThumbSize() {
if (!validMinimumThumbSize) { if (!validMinimumThumbSize) {
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
...@@ -308,6 +352,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -308,6 +352,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
return minimumThumbSize; return minimumThumbSize;
} }
/**
* @inheritDoc
*/
@Override
protected JButton createDecreaseButton(int orientation) { protected JButton createDecreaseButton(int orientation) {
SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) { SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) {
@Override @Override
...@@ -333,6 +381,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -333,6 +381,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
return synthArrowButton; return synthArrowButton;
} }
/**
* @inheritDoc
*/
@Override
protected JButton createIncreaseButton(int orientation) { protected JButton createIncreaseButton(int orientation) {
SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) { SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) {
@Override @Override
...@@ -360,6 +412,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements ...@@ -360,6 +412,10 @@ class SynthScrollBarUI extends BasicScrollBarUI implements
return synthArrowButton; return synthArrowButton;
} }
/**
* @inheritDoc
*/
@Override
protected void setThumbRollover(boolean active) { protected void setThumbRollover(boolean active) {
if (isThumbRollover() != active) { if (isThumbRollover() != active) {
scrollbar.repaint(getThumbBounds()); scrollbar.repaint(getThumbBounds());
......
...@@ -40,24 +40,32 @@ import java.awt.event.ContainerEvent; ...@@ -40,24 +40,32 @@ import java.awt.event.ContainerEvent;
import java.awt.event.FocusListener; import java.awt.event.FocusListener;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import sun.swing.plaf.synth.SynthUI;
/** /**
* Synth's ScrollPaneUI. * Provides the Synth L&F UI delegate for
* {@link javax.swing.JScrollPane}.
* *
* @author Scott Violet * @author Scott Violet
* @since 1.7
*/ */
class SynthScrollPaneUI extends BasicScrollPaneUI implements public class SynthScrollPaneUI extends BasicScrollPaneUI
PropertyChangeListener, SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
private boolean viewportViewHasFocus = false; private boolean viewportViewHasFocus = false;
private ViewportViewFocusHandler viewportViewFocusHandler; private ViewportViewFocusHandler viewportViewFocusHandler;
/**
* Creates a new UI object for the given component.
*
* @param x component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent x) { public static ComponentUI createUI(JComponent x) {
return new SynthScrollPaneUI(); return new SynthScrollPaneUI();
} }
/**
* @inheritDoc
*/
@Override @Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -69,6 +77,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -69,6 +77,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -77,6 +88,12 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -77,6 +88,12 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
Border vpBorder = scrollpane.getViewportBorder(); Border vpBorder = scrollpane.getViewportBorder();
if (vpBorder != null) { if (vpBorder != null) {
...@@ -85,12 +102,18 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -85,12 +102,18 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
context.getPainter().paintScrollPaneBorder(context, g, x, y, w, h); context.getPainter().paintScrollPaneBorder(context, g, x, y, w, h);
} }
/**
* @inheritDoc
*/
@Override @Override
protected void installDefaults(JScrollPane scrollpane) { protected void installDefaults(JScrollPane scrollpane) {
updateStyle(scrollpane); updateStyle(scrollpane);
...@@ -114,7 +137,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -114,7 +137,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override @Override
protected void installListeners(JScrollPane c) { protected void installListeners(JScrollPane c) {
super.installListeners(c); super.installListeners(c);
...@@ -129,6 +154,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -129,6 +154,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override @Override
protected void uninstallDefaults(JScrollPane c) { protected void uninstallDefaults(JScrollPane c) {
SynthContext context = getContext(c, ENABLED); SynthContext context = getContext(c, ENABLED);
...@@ -141,7 +169,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -141,7 +169,9 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override @Override
protected void uninstallListeners(JComponent c) { protected void uninstallListeners(JComponent c) {
super.uninstallListeners(c); super.uninstallListeners(c);
...@@ -156,7 +186,10 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -156,7 +186,10 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
} }
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, getComponentState(c));
} }
...@@ -166,12 +199,6 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements ...@@ -166,12 +199,6 @@ class SynthScrollPaneUI extends BasicScrollPaneUI implements
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) { private int getComponentState(JComponent c) {
int baseState = SynthLookAndFeel.getComponentState(c); int baseState = SynthLookAndFeel.getComponentState(c);
if (viewportViewFocusHandler!=null && viewportViewHasFocus){ if (viewportViewFocusHandler!=null && viewportViewHasFocus){
......
...@@ -34,33 +34,51 @@ import javax.swing.plaf.ComponentUI; ...@@ -34,33 +34,51 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SeparatorUI; import javax.swing.plaf.SeparatorUI;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import javax.swing.plaf.DimensionUIResource; import javax.swing.plaf.DimensionUIResource;
import sun.swing.plaf.synth.SynthUI;
/** /**
* A Synth L&F implementation of SeparatorUI. This implementation * Provides the Synth L&F UI delegate for
* is a "combined" view/controller. * {@link javax.swing.JSeparator}.
* *
* @author Shannon Hickey * @author Shannon Hickey
* @author Joshua Outwater * @author Joshua Outwater
* @since 1.7
*/ */
class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, public class SynthSeparatorUI extends SeparatorUI
SynthUI { implements PropertyChangeListener, SynthUI {
private SynthStyle style; private SynthStyle style;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public static ComponentUI createUI(JComponent c) { public static ComponentUI createUI(JComponent c) {
return new SynthSeparatorUI(); return new SynthSeparatorUI();
} }
/**
* @inheritDoc
*/
@Override
public void installUI(JComponent c) { public void installUI(JComponent c) {
installDefaults((JSeparator)c); installDefaults((JSeparator)c);
installListeners((JSeparator)c); installListeners((JSeparator)c);
} }
public void uninstallDefaults(JComponent c) { /**
* @inheritDoc
*/
@Override
public void uninstallUI(JComponent c) {
uninstallListeners((JSeparator)c); uninstallListeners((JSeparator)c);
uninstallDefaults((JSeparator)c); uninstallDefaults((JSeparator)c);
} }
/**
* Installs default setting. This method is called when a
* {@code LookAndFeel} is installed.
*/
public void installDefaults(JSeparator c) { public void installDefaults(JSeparator c) {
updateStyle(c); updateStyle(c);
} }
...@@ -88,6 +106,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -88,6 +106,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* Uninstalls default setting. This method is called when a
* {@code LookAndFeel} is uninstalled.
*/
public void uninstallDefaults(JSeparator c) { public void uninstallDefaults(JSeparator c) {
SynthContext context = getContext(c, ENABLED); SynthContext context = getContext(c, ENABLED);
...@@ -96,14 +118,26 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -96,14 +118,26 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
style = null; style = null;
} }
/**
* Installs listeners. This method is called when a
* {@code LookAndFeel} is installed.
*/
public void installListeners(JSeparator c) { public void installListeners(JSeparator c) {
c.addPropertyChangeListener(this); c.addPropertyChangeListener(this);
} }
/**
* Uninstalls listeners. This method is called when a
* {@code LookAndFeel} is uninstalled.
*/
public void uninstallListeners(JSeparator c) { public void uninstallListeners(JSeparator c) {
c.removePropertyChangeListener(this); c.removePropertyChangeListener(this);
} }
/**
* @inheritDoc
*/
@Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -116,6 +150,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -116,6 +150,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* @inheritDoc
*/
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -123,6 +161,12 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -123,6 +161,12 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
context.dispose(); context.dispose();
} }
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected void paint(SynthContext context, Graphics g) { protected void paint(SynthContext context, Graphics g) {
JSeparator separator = (JSeparator)context.getComponent(); JSeparator separator = (JSeparator)context.getComponent();
context.getPainter().paintSeparatorForeground(context, g, 0, 0, context.getPainter().paintSeparatorForeground(context, g, 0, 0,
...@@ -130,6 +174,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -130,6 +174,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
separator.getOrientation()); separator.getOrientation());
} }
/**
* @inheritDoc
*/
@Override
public void paintBorder(SynthContext context, Graphics g, int x, public void paintBorder(SynthContext context, Graphics g, int x,
int y, int w, int h) { int y, int w, int h) {
JSeparator separator = (JSeparator)context.getComponent(); JSeparator separator = (JSeparator)context.getComponent();
...@@ -137,6 +185,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -137,6 +185,10 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
separator.getOrientation()); separator.getOrientation());
} }
/**
* @inheritDoc
*/
@Override
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
SynthContext context = getContext(c); SynthContext context = getContext(c);
...@@ -155,16 +207,28 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -155,16 +207,28 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
return size; return size;
} }
/**
* @inheritDoc
*/
@Override
public Dimension getMinimumSize(JComponent c) { public Dimension getMinimumSize(JComponent c) {
return getPreferredSize(c); return getPreferredSize(c);
} }
/**
* @inheritDoc
*/
@Override
public Dimension getMaximumSize(JComponent c) { public Dimension getMaximumSize(JComponent c) {
return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE); return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
} }
/**
* @inheritDoc
*/
@Override
public SynthContext getContext(JComponent c) { public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c)); return getContext(c, SynthLookAndFeel.getComponentState(c));
} }
private SynthContext getContext(JComponent c, int state) { private SynthContext getContext(JComponent c, int state) {
...@@ -172,14 +236,6 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener, ...@@ -172,14 +236,6 @@ class SynthSeparatorUI extends SeparatorUI implements PropertyChangeListener,
SynthLookAndFeel.getRegion(c), style, state); SynthLookAndFeel.getRegion(c), style, state);
} }
private Region getRegion(JComponent c) {
return SynthLookAndFeel.getRegion(c);
}
private int getComponentState(JComponent c) {
return SynthLookAndFeel.getComponentState(c);
}
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
if (SynthLookAndFeel.shouldUpdateStyle(evt)) { if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
updateStyle((JSeparator)evt.getSource()); updateStyle((JSeparator)evt.getSource());
......
...@@ -33,7 +33,6 @@ import javax.swing.text.DefaultEditorKit; ...@@ -33,7 +33,6 @@ import javax.swing.text.DefaultEditorKit;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import sun.swing.plaf.synth.SynthUI;
/** /**
* <code>SynthStyle</code> is a set of style properties. * <code>SynthStyle</code> is a set of style properties.
......
...@@ -24,10 +24,7 @@ ...@@ -24,10 +24,7 @@
*/ */
package javax.swing.plaf.synth; package javax.swing.plaf.synth;
import java.awt.*; import javax.swing.JComponent;
import java.util.*;
import javax.swing.plaf.*;
import javax.swing.*;
/** /**
* Factory used for obtaining <code>SynthStyle</code>s. Each of the * Factory used for obtaining <code>SynthStyle</code>s. Each of the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册