Index: java/awt/Window.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/Window.java,v retrieving revision 1.62 diff -u -r1.62 Window.java --- java/awt/Window.java 4 Nov 2005 22:46:45 -0000 1.62 +++ java/awt/Window.java 8 Nov 2005 20:47:25 -0000 @@ -805,26 +805,25 @@ public void setLocationRelativeTo(Component c) { + int x = 0; + int y = 0; + if (c == null || !c.isShowing()) { - int x = 0; - int y = 0; - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Point center = ge.getCenterPoint(); x = center.x - (width / 2); y = center.y - (height / 2); - setLocation(x, y); } else { - int x = c.getX(); - int y = c.getY(); - int cWidth = c.getWidth(); int cHeight = c.getHeight(); Dimension screenSize = getToolkit().getScreenSize(); + x = c.getLocationOnScreen().x; + y = c.getLocationOnScreen().y; + // If bottom of component is cut off, window placed // on the left or the right side of component if ((y + cHeight) > screenSize.height) @@ -866,16 +865,19 @@ if ((x + width) > screenSize.width) x = screenSize.width - width; // If left side of component is cut off - else if (x < 0) + else if (x < 0 || (x - (width - cWidth) / 2) < 0) x = 0; else x -= (width - cWidth) / 2; - - y -= (height - cHeight) / 2; - } - setLocation(x, y); + if ((y - (height - cHeight) / 2) > 0) + y -= (height - cHeight) / 2; + else + y = 0; + } } + + setLocation(x, y); } /** Index: javax/swing/JOptionPane.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JOptionPane.java,v retrieving revision 1.22 diff -u -r1.22 JOptionPane.java --- javax/swing/JOptionPane.java 7 Nov 2005 15:41:09 -0000 1.22 +++ javax/swing/JOptionPane.java 8 Nov 2005 20:47:26 -0000 @@ -369,14 +369,11 @@ inputValue = UNINITIALIZED_VALUE; value = UNINITIALIZED_VALUE; - // FIXME: This dialog should be centered on the parent - // or at the center of the screen (if the parent is null) - // Need getGraphicsConfiguration to return non-null in - // order for that to work so we know how large the - // screen is. dialog.getContentPane().add(this); dialog.setModal(true); dialog.setResizable(false); + dialog.pack(); + dialog.setLocationRelativeTo(parentComponent); return dialog; } @@ -860,9 +857,6 @@ { JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE); JDialog dialog = pane.createDialog(parentComponent, "Select an Option"); - - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); if (pane.getValue() instanceof Integer) @@ -889,8 +883,6 @@ { JOptionPane pane = new JOptionPane(message, PLAIN_MESSAGE, optionType); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); if (pane.getValue() instanceof Integer) @@ -918,8 +910,6 @@ { JOptionPane pane = new JOptionPane(message, messageType, optionType); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); if (pane.getValue() instanceof Integer) @@ -949,8 +939,6 @@ { JOptionPane pane = new JOptionPane(message, messageType, optionType, icon); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); if (pane.getValue() instanceof Integer) @@ -976,8 +964,6 @@ JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE); pane.setWantsInput(true); JDialog dialog = pane.createDialog(parentComponent, null); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); return (String) pane.getInputValue(); @@ -1004,8 +990,6 @@ pane.setInitialSelectionValue(initialSelectionValue); pane.setWantsInput(true); JDialog dialog = pane.createDialog(parentComponent, null); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); return (String) pane.getInputValue(); @@ -1031,8 +1015,6 @@ JOptionPane pane = new JOptionPane(message, messageType); pane.setWantsInput(true); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); return (String) pane.getInputValue(); @@ -1065,8 +1047,6 @@ pane.setSelectionValues(selectionValues); pane.setInitialSelectionValue(initialSelectionValue); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); return pane.getInputValue(); @@ -1087,7 +1067,6 @@ JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE); pane.setWantsInput(true); JDialog dialog = pane.createDialog(null, null); - dialog.pack(); dialog.show(); return (String) pane.getInputValue(); @@ -1112,7 +1091,6 @@ pane.setWantsInput(true); pane.setInitialSelectionValue(initialSelectionValue); JDialog dialog = pane.createDialog(null, null); - dialog.pack(); dialog.show(); return (String) pane.getInputValue(); @@ -1417,8 +1395,6 @@ { JOptionPane pane = new JOptionPane(message, INFORMATION_MESSAGE); JDialog dialog = pane.createDialog(parentComponent, null); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); } @@ -1437,8 +1413,6 @@ { JOptionPane pane = new JOptionPane(message, messageType); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); } @@ -1459,8 +1433,6 @@ JOptionPane pane = new JOptionPane(message, messageType); pane.setIcon(icon); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); } @@ -1490,8 +1462,6 @@ options, initialValue); JDialog dialog = pane.createDialog(parentComponent, title); - dialog.pack(); - dialog.setLocationRelativeTo(parentComponent); dialog.show(); if (pane.getValue() instanceof Integer) Index: javax/swing/JTree.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JTree.java,v retrieving revision 1.50 diff -u -r1.50 JTree.java --- javax/swing/JTree.java 7 Nov 2005 22:27:30 -0000 1.50 +++ javax/swing/JTree.java 8 Nov 2005 20:47:26 -0000 @@ -1480,7 +1480,7 @@ updateUI(); setRootVisible(true); setModel(model); - setSelectionModel(EmptySelectionModel.sharedInstance()); + setSelectionModel(new EmptySelectionModel()); } /** Index: javax/swing/plaf/basic/BasicTreeUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v retrieving revision 1.108 diff -u -r1.108 BasicTreeUI.java --- javax/swing/plaf/basic/BasicTreeUI.java 8 Nov 2005 20:35:44 -0000 1.108 +++ javax/swing/plaf/basic/BasicTreeUI.java 8 Nov 2005 20:47:26 -0000 @@ -3776,7 +3776,7 @@ dtcr = createDefaultCellRenderer(); Component c = dtcr.getTreeCellRendererComponent(tree, node, - selected, isExpanded, isLeaf, row, true); + selected, isExpanded, isLeaf, row, tree.hasFocus()); rendererPane.paintComponent(g, c, c.getParent(), bounds); } } @@ -3850,15 +3850,16 @@ if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 && currentVisiblePath != null) - selectPath(tree, new TreePath(currentVisiblePath.getPathComponent(0))); + selectPath(tree, new TreePath(getPathToRoot(currentVisiblePath. + getPathComponent(0), 0))); } /**