aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/javax/swing
diff options
context:
space:
mode:
authortbell <none@none>2008-06-25 16:44:55 -0700
committertbell <none@none>2008-06-25 16:44:55 -0700
commit8e5f27a2979fb21a3660b44668e3568330669916 (patch)
tree7a2891aeaecce23aced862a3723443cb1d58463b /src/share/classes/javax/swing
parent723bcc9a4d99acfe84a687af3317952ee6b0077e (diff)
parent5ba79bd30d3da7d6f44ba65b15eea6f89b6f894d (diff)
Merge
Diffstat (limited to 'src/share/classes/javax/swing')
-rw-r--r--src/share/classes/javax/swing/JFileChooser.java4
-rw-r--r--src/share/classes/javax/swing/JPopupMenu.java117
-rw-r--r--src/share/classes/javax/swing/JSlider.java77
-rw-r--r--src/share/classes/javax/swing/PopupFactory.java65
-rw-r--r--src/share/classes/javax/swing/plaf/FileChooserUI.java13
-rw-r--r--src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java2
-rw-r--r--src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java4
-rw-r--r--src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java58
-rw-r--r--src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java4
-rw-r--r--src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java30
-rw-r--r--src/share/classes/javax/swing/text/FlowView.java20
11 files changed, 222 insertions, 172 deletions
diff --git a/src/share/classes/javax/swing/JFileChooser.java b/src/share/classes/javax/swing/JFileChooser.java
index 8a2b2d539..344565a1f 100644
--- a/src/share/classes/javax/swing/JFileChooser.java
+++ b/src/share/classes/javax/swing/JFileChooser.java
@@ -770,7 +770,8 @@ public class JFileChooser extends JComponent implements Accessible {
* @since 1.4
*/
protected JDialog createDialog(Component parent) throws HeadlessException {
- String title = getUI().getDialogTitle(this);
+ FileChooserUI ui = getUI();
+ String title = ui.getDialogTitle(this);
putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
title);
@@ -794,6 +795,7 @@ public class JFileChooser extends JComponent implements Accessible {
dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
}
}
+ dialog.getRootPane().setDefaultButton(ui.getDefaultButton(this));
dialog.pack();
dialog.setLocationRelativeTo(parent);
diff --git a/src/share/classes/javax/swing/JPopupMenu.java b/src/share/classes/javax/swing/JPopupMenu.java
index b1cdd7db6..4edf073cd 100644
--- a/src/share/classes/javax/swing/JPopupMenu.java
+++ b/src/share/classes/javax/swing/JPopupMenu.java
@@ -41,6 +41,7 @@ import javax.swing.plaf.PopupMenuUI;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.event.*;
+import sun.security.util.SecurityConstants;
import java.applet.Applet;
@@ -320,17 +321,67 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
* This adustment may be cancelled by invoking the application with
* -Djavax.swing.adjustPopupLocationToFit=false
*/
- Point adjustPopupLocationToFitScreen(int xposition, int yposition) {
- Point p = new Point(xposition, yposition);
+ Point adjustPopupLocationToFitScreen(int xPosition, int yPosition) {
+ Point popupLocation = new Point(xPosition, yPosition);
- if(popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless())
- return p;
+ if(popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless()) {
+ return popupLocation;
+ }
+ // Get screen bounds
+ Rectangle scrBounds;
+ GraphicsConfiguration gc = getCurrentGraphicsConfiguration(popupLocation);
Toolkit toolkit = Toolkit.getDefaultToolkit();
- Rectangle screenBounds;
+ if(gc != null) {
+ // If we have GraphicsConfiguration use it to get screen bounds
+ scrBounds = gc.getBounds();
+ } else {
+ // If we don't have GraphicsConfiguration use primary screen
+ scrBounds = new Rectangle(toolkit.getScreenSize());
+ }
+
+ // Calculate the screen size that popup should fit
+ Dimension popupSize = JPopupMenu.this.getPreferredSize();
+ int popupRightX = popupLocation.x + popupSize.width;
+ int popupBottomY = popupLocation.y + popupSize.height;
+ int scrWidth = scrBounds.width;
+ int scrHeight = scrBounds.height;
+ if (!canPopupOverlapTaskBar()) {
+ // Insets include the task bar. Take them into account.
+ Insets scrInsets = toolkit.getScreenInsets(gc);
+ scrBounds.x += scrInsets.left;
+ scrBounds.y += scrInsets.top;
+ scrWidth -= scrInsets.left + scrInsets.right;
+ scrHeight -= scrInsets.top + scrInsets.bottom;
+ }
+ int scrRightX = scrBounds.x + scrWidth;
+ int scrBottomY = scrBounds.y + scrHeight;
+
+ // Ensure that popup menu fits the screen
+ if (popupRightX > scrRightX) {
+ popupLocation.x = scrRightX - popupSize.width;
+ if( popupLocation.x < scrBounds.x ) {
+ popupLocation.x = scrBounds.x ;
+ }
+ }
+ if (popupBottomY > scrBottomY) {
+ popupLocation.y = scrBottomY - popupSize.height;
+ if( popupLocation.y < scrBounds.y ) {
+ popupLocation.y = scrBounds.y;
+ }
+ }
+
+ return popupLocation;
+ }
+
+ /**
+ * Tries to find GraphicsConfiguration
+ * that contains the mouse cursor position.
+ * Can return null.
+ */
+ private GraphicsConfiguration getCurrentGraphicsConfiguration(
+ Point popupLocation) {
GraphicsConfiguration gc = null;
- // Try to find GraphicsConfiguration, that includes mouse
- // pointer position
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gd = ge.getScreenDevices();
@@ -338,50 +389,36 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
if(gd[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration dgc =
gd[i].getDefaultConfiguration();
- if(dgc.getBounds().contains(p)) {
+ if(dgc.getBounds().contains(popupLocation)) {
gc = dgc;
break;
}
}
}
-
// If not found and we have invoker, ask invoker about his gc
if(gc == null && getInvoker() != null) {
gc = getInvoker().getGraphicsConfiguration();
}
+ return gc;
+ }
- if(gc != null) {
- // If we have GraphicsConfiguration use it to get
- // screen bounds
- screenBounds = gc.getBounds();
- } else {
- // If we don't have GraphicsConfiguration use primary screen
- screenBounds = new Rectangle(toolkit.getScreenSize());
+ /**
+ * Checks that there are enough security permissions
+ * to make popup "always on top", which allows to show it above the task bar.
+ */
+ static boolean canPopupOverlapTaskBar() {
+ boolean result = true;
+ try {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(
+ SecurityConstants.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
+ }
+ } catch (SecurityException se) {
+ // There is no permission to show popups over the task bar
+ result = false;
}
-
- Dimension size;
-
- size = JPopupMenu.this.getPreferredSize();
-
- // Use long variables to prevent overflow
- long pw = (long) p.x + (long) size.width;
- long ph = (long) p.y + (long) size.height;
-
- if( pw > screenBounds.x + screenBounds.width )
- p.x = screenBounds.x + screenBounds.width - size.width;
-
- if( ph > screenBounds.y + screenBounds.height)
- p.y = screenBounds.y + screenBounds.height - size.height;
-
- /* Change is made to the desired (X,Y) values, when the
- PopupMenu is too tall OR too wide for the screen
- */
- if( p.x < screenBounds.x )
- p.x = screenBounds.x ;
- if( p.y < screenBounds.y )
- p.y = screenBounds.y;
-
- return p;
+ return result;
}
diff --git a/src/share/classes/javax/swing/JSlider.java b/src/share/classes/javax/swing/JSlider.java
index e1a7909b0..6432b9f59 100644
--- a/src/share/classes/javax/swing/JSlider.java
+++ b/src/share/classes/javax/swing/JSlider.java
@@ -25,18 +25,15 @@
package javax.swing;
-import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.accessibility.*;
import java.io.Serializable;
import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
import java.io.IOException;
-import java.awt.Color;
-import java.awt.Font;
+import java.awt.*;
import java.util.*;
import java.beans.*;
@@ -409,8 +406,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
* @since 1.4
*/
public ChangeListener[] getChangeListeners() {
- return (ChangeListener[])listenerList.getListeners(
- ChangeListener.class);
+ return listenerList.getListeners(ChangeListener.class);
}
@@ -642,9 +638,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
/**
* Sets the model's {@code valueIsAdjusting} property. Slider look and
* feel implementations should set this property to {@code true} when
- * a knob drag begins, and to {@code false} when the drag ends. The
- * slider model will not generate {@code ChangeEvent}s while
- * {@code valueIsAdjusting} is {@code true}.
+ * a knob drag begins, and to {@code false} when the drag ends.
*
* @param b the new value for the {@code valueIsAdjusting} property
* @see #getValueIsAdjusting
@@ -764,6 +758,33 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
updateLabelSizes();
}
+ /**
+ * {@inheritDoc}
+ * @since 1.7
+ */
+ public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
+ if (!isShowing()) {
+ return false;
+ }
+
+ // Check that there is a label with such image
+ Enumeration elements = labelTable.elements();
+
+ while (elements.hasMoreElements()) {
+ Component component = (Component) elements.nextElement();
+
+ if (component instanceof JLabel) {
+ JLabel label = (JLabel) component;
+
+ if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img) ||
+ SwingUtilities.doesIconReferenceImage(label.getDisabledIcon(), img)) {
+ return super.imageUpdate(img, infoflags, x, y, w, h);
+ }
+ }
+ }
+
+ return false;
+ }
/**
* Returns the dictionary of what labels to draw at which values.
@@ -826,17 +847,16 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
* @see JComponent#updateUI
*/
protected void updateLabelUIs() {
- if ( getLabelTable() == null ) {
+ Dictionary labelTable = getLabelTable();
+
+ if (labelTable == null) {
return;
}
- Enumeration labels = getLabelTable().keys();
+ Enumeration labels = labelTable.keys();
while ( labels.hasMoreElements() ) {
- Object value = getLabelTable().get( labels.nextElement() );
- if ( value instanceof JComponent ) {
- JComponent component = (JComponent)value;
- component.updateUI();
- component.setSize( component.getPreferredSize() );
- }
+ JComponent component = (JComponent) labelTable.get(labels.nextElement());
+ component.updateUI();
+ component.setSize(component.getPreferredSize());
}
}
@@ -845,11 +865,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
if (labelTable != null) {
Enumeration labels = labelTable.elements();
while (labels.hasMoreElements()) {
- Object value = labels.nextElement();
- if (value instanceof JComponent) {
- JComponent component = (JComponent)value;
- component.setSize(component.getPreferredSize());
- }
+ JComponent component = (JComponent) labels.nextElement();
+ component.setSize(component.getPreferredSize());
}
}
}
@@ -960,14 +977,14 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
if ( e.getPropertyName().equals( "minimum" ) ||
e.getPropertyName().equals( "maximum" ) ) {
- Enumeration keys = getLabelTable().keys();
- Object key = null;
+ Dictionary labelTable = getLabelTable();
+ Enumeration keys = labelTable.keys();
Hashtable hashtable = new Hashtable();
// Save the labels that were added by the developer
while ( keys.hasMoreElements() ) {
- key = keys.nextElement();
- Object value = getLabelTable().get( key );
+ Object key = keys.nextElement();
+ Object value = labelTable.get(key);
if ( !(value instanceof LabelUIResource) ) {
hashtable.put( key, value );
}
@@ -979,7 +996,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
// Add the saved labels
keys = hashtable.keys();
while ( keys.hasMoreElements() ) {
- key = keys.nextElement();
+ Object key = keys.nextElement();
put( key, hashtable.get( key ) );
}
@@ -996,8 +1013,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
SmartHashtable table = new SmartHashtable( increment, start );
- if ( getLabelTable() != null && (getLabelTable() instanceof PropertyChangeListener) ) {
- removePropertyChangeListener( (PropertyChangeListener)getLabelTable() );
+ Dictionary labelTable = getLabelTable();
+
+ if (labelTable != null && (labelTable instanceof PropertyChangeListener)) {
+ removePropertyChangeListener((PropertyChangeListener) labelTable);
}
addPropertyChangeListener( table );
diff --git a/src/share/classes/javax/swing/PopupFactory.java b/src/share/classes/javax/swing/PopupFactory.java
index 86b737750..7a934150f 100644
--- a/src/share/classes/javax/swing/PopupFactory.java
+++ b/src/share/classes/javax/swing/PopupFactory.java
@@ -548,47 +548,46 @@ public class PopupFactory {
}
/**
- * Returns true if the Popup can fit on the screen.
+ * Returns true if popup can fit the screen and the owner's top parent.
+ * It determines can popup be lightweight or mediumweight.
*/
boolean fitsOnScreen() {
+ boolean result = false;
Component component = getComponent();
-
if (owner != null && component != null) {
- Container parent;
- int width = component.getWidth();
- int height = component.getHeight();
- for(parent = owner.getParent(); parent != null ;
- parent = parent.getParent()) {
- if (parent instanceof JFrame ||
- parent instanceof JDialog ||
- parent instanceof JWindow) {
-
- Rectangle r = parent.getBounds();
- Insets i = parent.getInsets();
- r.x += i.left;
- r.y += i.top;
- r.width -= (i.left + i.right);
- r.height -= (i.top + i.bottom);
-
- GraphicsConfiguration gc = parent.getGraphicsConfiguration();
+ Container parent = (Container) SwingUtilities.getRoot(owner);
+ int popupWidth = component.getWidth();
+ int popupHeight = component.getHeight();
+ Rectangle parentBounds = parent.getBounds();
+ if (parent instanceof JFrame ||
+ parent instanceof JDialog ||
+ parent instanceof JWindow) {
+
+ Insets i = parent.getInsets();
+ parentBounds.x += i.left;
+ parentBounds.y += i.top;
+ parentBounds.width -= i.left + i.right;
+ parentBounds.height -= i.top + i.bottom;
+
+ if (JPopupMenu.canPopupOverlapTaskBar()) {
+ GraphicsConfiguration gc =
+ parent.getGraphicsConfiguration();
Rectangle popupArea = getContainerPopupArea(gc);
- return r.intersection(popupArea).contains(x, y, width, height);
-
- } else if (parent instanceof JApplet) {
- Rectangle r = parent.getBounds();
- Point p = parent.getLocationOnScreen();
-
- r.x = p.x;
- r.y = p.y;
- return r.contains(x, y, width, height);
- } else if (parent instanceof Window ||
- parent instanceof Applet) {
- // No suitable swing component found
- break;
+ result = parentBounds.intersection(popupArea)
+ .contains(x, y, popupWidth, popupHeight);
+ } else {
+ result = parentBounds
+ .contains(x, y, popupWidth, popupHeight);
}
+ } else if (parent instanceof JApplet) {
+ Point p = parent.getLocationOnScreen();
+ parentBounds.x = p.x;
+ parentBounds.y = p.y;
+ result = parentBounds
+ .contains(x, y, popupWidth, popupHeight);
}
}
- return false;
+ return result;
}
Rectangle getContainerPopupArea(GraphicsConfiguration gc) {
diff --git a/src/share/classes/javax/swing/plaf/FileChooserUI.java b/src/share/classes/javax/swing/plaf/FileChooserUI.java
index 78064e08e..aaab089cc 100644
--- a/src/share/classes/javax/swing/plaf/FileChooserUI.java
+++ b/src/share/classes/javax/swing/plaf/FileChooserUI.java
@@ -25,7 +25,7 @@
package javax.swing.plaf;
-import javax.swing.JFileChooser;
+import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileView;
import java.io.File;
@@ -46,4 +46,15 @@ public abstract class FileChooserUI extends ComponentUI
public abstract void rescanCurrentDirectory(JFileChooser fc);
public abstract void ensureFileIsVisible(JFileChooser fc, File f);
+
+ /**
+ * Returns default button for current <code>LookAndFeel</code>.
+ * <code>JFileChooser</code> will use this button as default button
+ * for dialog windows.
+ *
+ * @since 1.7
+ */
+ public JButton getDefaultButton(JFileChooser fc) {
+ return null;
+ }
}
diff --git a/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java b/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
index 06b4dc5b6..6bc400f97 100644
--- a/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
+++ b/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
@@ -196,7 +196,7 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
}
protected void sort(Vector<? extends File> v){
- ShellFolder.sortFiles(v);
+ ShellFolder.sort(v);
}
// Obsolete - not used
diff --git a/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java b/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
index 5a9daae32..e8728d807 100644
--- a/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -384,6 +384,10 @@ public class BasicFileChooserUI extends FileChooserUI {
return null;
}
+ public JButton getDefaultButton(JFileChooser fc) {
+ return getApproveButton(fc);
+ }
+
public String getApproveButtonToolTipText(JFileChooser fc) {
String tooltipText = fc.getApproveButtonToolTipText();
if(tooltipText != null) {
diff --git a/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java b/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
index c1aada744..635efb044 100644
--- a/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
@@ -25,25 +25,12 @@
package javax.swing.plaf.basic;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Adjustable;
import java.awt.event.*;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.awt.Point;
-import java.awt.Insets;
-import java.awt.Color;
-import java.awt.IllegalComponentStateException;
-import java.awt.Polygon;
+import java.awt.*;
import java.beans.*;
import java.util.Dictionary;
import java.util.Enumeration;
-import javax.swing.border.AbstractBorder;
-
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
@@ -409,7 +396,7 @@ public class BasicSliderUI extends SliderUI{
Enumeration elements = dictionary.elements();
int baseline = -1;
while (elements.hasMoreElements()) {
- Component label = (Component)elements.nextElement();
+ JComponent label = (JComponent) elements.nextElement();
Dimension pref = label.getPreferredSize();
int labelBaseline = label.getBaseline(pref.width,
pref.height);
@@ -634,7 +621,7 @@ public class BasicSliderUI extends SliderUI{
protected void calculateTrackRect() {
- int centerSpacing = 0; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
+ int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
centerSpacing = thumbRect.height;
if ( slider.getPaintTicks() ) centerSpacing += getTickLength();
@@ -764,7 +751,7 @@ public class BasicSliderUI extends SliderUI{
if ( dictionary != null ) {
Enumeration keys = dictionary.keys();
while ( keys.hasMoreElements() ) {
- Component label = (Component)dictionary.get( keys.nextElement() );
+ JComponent label = (JComponent) dictionary.get(keys.nextElement());
widest = Math.max( label.getPreferredSize().width, widest );
}
}
@@ -777,7 +764,7 @@ public class BasicSliderUI extends SliderUI{
if ( dictionary != null ) {
Enumeration keys = dictionary.keys();
while ( keys.hasMoreElements() ) {
- Component label = (Component)dictionary.get( keys.nextElement() );
+ JComponent label = (JComponent) dictionary.get(keys.nextElement());
tallest = Math.max( label.getPreferredSize().height, tallest );
}
}
@@ -1001,22 +988,14 @@ public class BasicSliderUI extends SliderUI{
public void paintTicks(Graphics g) {
Rectangle tickBounds = tickRect;
- int i;
- int maj, min, max;
- int w = tickBounds.width;
- int h = tickBounds.height;
- int centerEffect, tickHeight;
g.setColor(DefaultLookup.getColor(slider, this, "Slider.tickColor", Color.black));
- maj = slider.getMajorTickSpacing();
- min = slider.getMinorTickSpacing();
-
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
g.translate( 0, tickBounds.y);
int value = slider.getMinimum();
- int xPos = 0;
+ int xPos;
if ( slider.getMinorTickSpacing() > 0 ) {
while ( value <= slider.getMaximum() ) {
@@ -1042,7 +1021,7 @@ public class BasicSliderUI extends SliderUI{
g.translate(tickBounds.x, 0);
int value = slider.getMinimum();
- int yPos = 0;
+ int yPos;
if ( slider.getMinorTickSpacing() > 0 ) {
int offset = 0;
@@ -1111,10 +1090,19 @@ public class BasicSliderUI extends SliderUI{
Integer key = (Integer)keys.nextElement();
int value = key.intValue();
if (value >= minValue && value <= maxValue) {
- Component label = (Component)dictionary.get( key );
- if (label instanceof JComponent) {
- ((JComponent)label).setEnabled(enabled);
+ JComponent label = (JComponent) dictionary.get(key);
+ label.setEnabled(enabled);
+
+ if (label instanceof JLabel) {
+ Icon icon = label.isEnabled() ? ((JLabel) label).getIcon() : ((JLabel) label).getDisabledIcon();
+
+ if (icon instanceof ImageIcon) {
+ // Register Slider as an image observer. It allows to catch notifications about
+ // image changes (e.g. gif animation)
+ Toolkit.getDefaultToolkit().checkImage(((ImageIcon) icon).getImage(), -1, -1, slider);
+ }
}
+
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
g.translate( 0, labelBounds.y );
paintHorizontalLabel( g, value, label );
@@ -1364,7 +1352,7 @@ public class BasicSliderUI extends SliderUI{
int min = slider.getMinimum();
int max = slider.getMaximum();
double valueRange = (double)max - (double)min;
- double pixelsPerValue = (double)trackHeight / (double)valueRange;
+ double pixelsPerValue = (double)trackHeight / valueRange;
int trackBottom = trackY + (trackHeight - 1);
int yPosition;
@@ -1715,7 +1703,7 @@ public class BasicSliderUI extends SliderUI{
* of the thumb relative to the origin of the track.
*/
public void mouseDragged(MouseEvent e) {
- int thumbMiddle = 0;
+ int thumbMiddle;
if (!slider.isEnabled()) {
return;
@@ -1841,7 +1829,7 @@ public class BasicSliderUI extends SliderUI{
public void componentResized(ComponentEvent e) {
getHandler().componentResized(e);
}
- };
+ }
/**
* Focus-change listener.
@@ -1903,7 +1891,7 @@ public class BasicSliderUI extends SliderUI{
return b;
}
- };
+ }
/**
diff --git a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
index d1f7c0593..272799409 100644
--- a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -853,9 +853,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ESCAPE", "cancelSelection",
"F2", "editFileName",
"F5", "refresh",
- "BACK_SPACE", "Go Up",
- "ENTER", "approveSelection",
- "ctrl ENTER", "approveSelection"
+ "BACK_SPACE", "Go Up"
}),
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java b/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
index 0cf5ed226..c8d5a0959 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
@@ -25,26 +25,17 @@
package javax.swing.plaf.synth;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Adjustable;
import java.awt.event.*;
import java.awt.Graphics;
import java.awt.Dimension;
-import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.awt.Point;
import java.awt.Insets;
-import java.awt.Color;
-import java.awt.IllegalComponentStateException;
-import java.awt.Polygon;
import java.beans.*;
import java.util.Dictionary;
import java.util.Enumeration;
-import javax.swing.border.AbstractBorder;
import javax.swing.*;
-import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicSliderUI;
import sun.swing.plaf.synth.SynthUI;
@@ -203,8 +194,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
centerY += valueHeight + 2;
centerY += trackHeight + trackInsets.top + trackInsets.bottom;
centerY += tickHeight + 2;
- Component label = (Component)slider.getLabelTable().
- elements().nextElement();
+ JComponent label = (JComponent) slider.getLabelTable().elements().nextElement();
Dimension pref = label.getPreferredSize();
return centerY + label.getBaseline(pref.width, pref.height);
}
@@ -226,8 +216,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
int trackHeight = contentHeight - valueHeight;
int yPosition = yPositionForValue(value.intValue(), trackY,
trackHeight);
- Component label = (Component)slider.getLabelTable().
- get(value);
+ JComponent label = (JComponent) slider.getLabelTable().get(value);
Dimension pref = label.getPreferredSize();
return yPosition - pref.height / 2 +
label.getBaseline(pref.width, pref.height);
@@ -434,16 +423,14 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
/**
* Calculates the pad for the label at the specified index.
*
- * @param index index of the label to calculate pad for.
+ * @param i index of the label to calculate pad for.
* @return padding required to keep label visible.
*/
private int getPadForLabel(int i) {
- Dictionary dictionary = slider.getLabelTable();
int pad = 0;
- Object o = dictionary.get(i);
- if (o != null) {
- Component c = (Component)o;
+ JComponent c = (JComponent) slider.getLabelTable().get(i);
+ if (c != null) {
int centerX = xPositionForValue(i);
int cHalfWidth = c.getPreferredSize().width / 2;
if (centerX - cHalfWidth < insetCache.left) {
@@ -500,8 +487,6 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
}
}
- private static Rectangle unionRect = new Rectangle();
-
public void setThumbLocation(int x, int y) {
super.setThumbLocation(x, y);
// Value rect is tied to the thumb location. We need to repaint when
@@ -544,7 +529,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
trackBorder;
int trackLength = trackBottom - trackTop;
double valueRange = (double)max - (double)min;
- double pixelsPerValue = (double)trackLength / (double)valueRange;
+ double pixelsPerValue = (double)trackLength / valueRange;
int yPosition;
if (!drawInverted()) {
@@ -802,8 +787,7 @@ class SynthSliderUI extends BasicSliderUI implements PropertyChangeListener,
}
public void mouseDragged(MouseEvent e) {
- SynthScrollBarUI ui;
- int thumbMiddle = 0;
+ int thumbMiddle;
if (!slider.isEnabled()) {
return;
diff --git a/src/share/classes/javax/swing/text/FlowView.java b/src/share/classes/javax/swing/text/FlowView.java
index 39f8a5d60..e784b33c5 100644
--- a/src/share/classes/javax/swing/text/FlowView.java
+++ b/src/share/classes/javax/swing/text/FlowView.java
@@ -333,17 +333,24 @@ public abstract class FlowView extends BoxView {
* @since 1.3
*/
public static class FlowStrategy {
- int damageStart = Integer.MAX_VALUE;
+ Position damageStart = null;
Vector<View> viewBuffer;
void addDamage(FlowView fv, int offset) {
if (offset >= fv.getStartOffset() && offset < fv.getEndOffset()) {
- damageStart = Math.min(damageStart, offset);
+ if (damageStart == null || offset < damageStart.getOffset()) {
+ try {
+ damageStart = fv.getDocument().createPosition(offset);
+ } catch (BadLocationException e) {
+ // shouldn't happen since offset is inside view bounds
+ assert(false);
+ }
+ }
}
}
void unsetDamage() {
- damageStart = Integer.MAX_VALUE;
+ damageStart = null;
}
/**
@@ -438,13 +445,14 @@ public abstract class FlowView extends BoxView {
int p1 = fv.getEndOffset();
if (fv.majorAllocValid) {
- if (damageStart == Integer.MAX_VALUE) {
+ if (damageStart == null) {
return;
}
// In some cases there's no view at position damageStart, so
// step back and search again. See 6452106 for details.
- while ((rowIndex = fv.getViewIndexAtPosition(damageStart)) < 0) {
- damageStart--;
+ int offset = damageStart.getOffset();
+ while ((rowIndex = fv.getViewIndexAtPosition(offset)) < 0) {
+ offset--;
}
if (rowIndex > 0) {
rowIndex--;