[cp-patches] FYI: MetalComboBoxUI updates

2005-10-17 Thread David Gilbert
I committed this patch to fix a problem with JComboBoxes that use a custom renderer. 
 I've updated the ComboBoxDemo class to show this working.  And I added the 
'List.font' default to the MetalLookAndFeel since it was missing:


2005-10-17  David Gilbert  [EMAIL PROTECTED]

* examples/gnu/classpath/examples/swing/ComboBoxDemo.java:
(CustomCellRenderer): new inner class,
(comboState6): new field,
(combo11): new field,
(combo12): new field,
(createContent): add panel from createPanel6(),
(createPanel6): new method,
(actionPerformed): update state for new JComboBoxes,
* javax/swing/plaf/basic/BasicComboBoxUI.java
(installComponents): don't create arrowButton until after listBox is
created, set listBox to the JList created by the popup,
* javax/swing/plaf/metal/MetalComboBoxButton.java:
(MetalComboBoxButton(JComboBox, Icon, boolean, CellRendererPane,
JList)): set margins to zero,
(paintComponent): use list cell renderer to paint button content,
* javax/swing/plaf/metal/MetalLookAndFeel.java
(initComponentDefaults): add 'List.font' default.

Regards,

Dave
Index: examples/gnu/classpath/examples/swing/ComboBoxDemo.java
===
RCS file: 
/cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java,v
retrieving revision 1.2
diff -u -r1.2 ComboBoxDemo.java
--- examples/gnu/classpath/examples/swing/ComboBoxDemo.java 29 Sep 2005 
22:15:21 -  1.2
+++ examples/gnu/classpath/examples/swing/ComboBoxDemo.java 17 Oct 2005 
09:48:05 -
@@ -24,6 +24,7 @@
 
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.GridLayout;
@@ -31,12 +32,16 @@
 import java.awt.event.ActionListener;
 
 import javax.swing.BorderFactory;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
+import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalIconFactory;
 
 /**
  * A simple demo showing various combo boxes in different states.
@@ -46,6 +51,24 @@
   implements ActionListener 
 {
  
+  class CustomCellRenderer extends DefaultListCellRenderer
+  {
+public Component getListCellRendererComponent(JList list,
+  Object value,
+  int index,
+  boolean isSelected,
+  boolean cellHasFocus)
+{
+  DefaultListCellRenderer result = (DefaultListCellRenderer) 
+  super.getListCellRendererComponent(list, value, index, isSelected, 
+ cellHasFocus);
+  Icon icon = (Icon) value;
+  result.setIcon(icon);
+  result.setText(Index =  + index);
+  return result;
+}
+  }
+
   private JCheckBox comboState1;  
   private JComboBox combo1;
   private JComboBox combo2;
@@ -66,6 +89,10 @@
   private JComboBox combo9;
   private JComboBox combo10;
   
+  private JCheckBox comboState6;
+  private JComboBox combo11;
+  private JComboBox combo12;
+  
   /**
* Creates a new demo instance.
* 
@@ -80,12 +107,13 @@
   private JPanel createContent() 
   {
 JPanel content = new JPanel(new BorderLayout());
-JPanel panel = new JPanel(new GridLayout(5, 1));
+JPanel panel = new JPanel(new GridLayout(6, 1));
 panel.add(createPanel1());
 panel.add(createPanel2());
 panel.add(createPanel3());
 panel.add(createPanel4());
 panel.add(createPanel5());
+panel.add(createPanel6());
 content.add(panel);
 JPanel closePanel = new JPanel();
 JButton closeButton = new JButton(Close);
@@ -234,6 +262,41 @@
 return panel;
   }
 
+  /**
+   * This panel contains combo boxes with a custom renderer.
+   * 
+   * @return A panel.
+   */
+  private JPanel createPanel6() 
+  {
+JPanel panel = new JPanel(new BorderLayout());
+this.comboState6 = new JCheckBox(Enabled, true);
+this.comboState6.setActionCommand(COMBO_STATE6);
+this.comboState6.addActionListener(this);
+panel.add(this.comboState6, BorderLayout.EAST);
+
+JPanel controlPanel = new JPanel();
+controlPanel.setBorder(BorderFactory.createTitledBorder(Custom Renderer: 
));
+this.combo11 = new JComboBox(new Object[] {
+MetalIconFactory.getFileChooserHomeFolderIcon(),
+MetalIconFactory.getFileChooserNewFolderIcon()});
+this.combo11.setPreferredSize(new Dimension(100, 30));
+this.combo11.setRenderer(new CustomCellRenderer());
+this.combo12 = new JComboBox(new Object[] {
+MetalIconFactory.getFileChooserHomeFolderIcon(),
+

[cp-patches] FYI: JTable rendering fix

2005-10-17 Thread Roman Kennke
This fixes painting of selected cells/rows.

2005-10-17  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/DefaultTableCellRenderer.java
(getTableCellRendererComponent): Setup colors (more) correctly.
* javax/swing/DefaultListSelectionModel.java
(isSelectedIndex): Check for an illegal index argument.


/Roman
Index: javax/swing/table/DefaultTableCellRenderer.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/table/DefaultTableCellRenderer.java,v
retrieving revision 1.14
diff -u -r1.14 DefaultTableCellRenderer.java
--- javax/swing/table/DefaultTableCellRenderer.java	9 Aug 2005 15:56:40 -	1.14
+++ javax/swing/table/DefaultTableCellRenderer.java	17 Oct 2005 15:15:54 -
@@ -64,6 +64,7 @@
   {
 public UIResource()
 {
+  super();
 }
   }
 
@@ -135,7 +136,12 @@
 if (table == null)
   return this;
 
-if (isSelected)
+if (isSelected  hasFocus)
+  {
+setBackground(table.getBackground());
+setForeground(table.getSelectionForeground());
+  }
+else if (table.isRowSelected(row))
   {
 setBackground(table.getSelectionBackground());
 setForeground(table.getSelectionForeground());
Index: javax/swing/DefaultListSelectionModel.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/DefaultListSelectionModel.java,v
retrieving revision 1.21
diff -u -r1.21 DefaultListSelectionModel.java
--- javax/swing/DefaultListSelectionModel.java	27 Jul 2005 12:41:33 -	1.21
+++ javax/swing/DefaultListSelectionModel.java	17 Oct 2005 15:15:54 -
@@ -388,6 +388,9 @@
*/
   public boolean isSelectedIndex(int a)
   {
+// TODO: Probably throw an exception here?
+if (a = sel.length() || a  0)
+  return false;
 return sel.get(a);
   }
 
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: Another JComboBox fix

2005-10-17 Thread Roman Kennke
Hi,

this fixes the size of the combobox popup and sets the selected item in
the combobox before closing the popup.

2005-10-17  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JPopupMenu.java
(setVisible): Set size according to the size property instead of
the preferredSize property.
* javax/swing/plaf/basic/BasicComboPopup.java
(ListMouseHandler.mouseReleased): Set comboBox selected index
before
closing the popup.


/Roman
Index: javax/swing/JPopupMenu.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JPopupMenu.java,v
retrieving revision 1.27
diff -u -r1.27 JPopupMenu.java
--- javax/swing/JPopupMenu.java	30 Sep 2005 19:13:23 -	1.27
+++ javax/swing/JPopupMenu.java	17 Oct 2005 15:22:19 -
@@ -564,7 +564,7 @@
 Dimension screenSize = getToolkit().getScreenSize();
 
 boolean fit = true;
-Dimension size = this.getPreferredSize();
+Dimension size = this.getSize();
 if ((size.width  (rootContainer.getWidth() - popupLocation.x))
 || (size.height  (rootContainer.getHeight() - popupLocation.y)))
   fit = false;
Index: javax/swing/plaf/basic/BasicComboPopup.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboPopup.java,v
retrieving revision 1.9
diff -u -r1.9 BasicComboPopup.java
--- javax/swing/plaf/basic/BasicComboPopup.java	17 Oct 2005 13:35:59 -	1.9
+++ javax/swing/plaf/basic/BasicComboPopup.java	17 Oct 2005 15:22:19 -
@@ -912,7 +912,10 @@
 
 public void mouseReleased(MouseEvent anEvent)
 {
-  updateListBoxSelectionForEvent(anEvent, false);
+  int index = list.locationToIndex(anEvent.getPoint());
+  // Check for valid index.
+  if (index = 0)
+comboBox.setSelectedIndex(index);
   hide();
 }
   }
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: ListDataListener - reformatted, added API docs

2005-10-17 Thread David Gilbert

I committed this patch:

2005-10-17  David Gilbert  [EMAIL PROTECTED]

* javax/swing/event/ListDataListener:
reformatted and added API docs.

Regards,

Dave
Index: javax/swing/event/ListDataListener.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/event/ListDataListener.java,v
retrieving revision 1.5
diff -u -r1.5 ListDataListener.java
--- javax/swing/event/ListDataListener.java 2 Jul 2005 20:32:50 -   
1.5
+++ javax/swing/event/ListDataListener.java 17 Oct 2005 15:43:55 -
@@ -1,5 +1,5 @@
 /* ListDataListener.java --
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -37,33 +37,46 @@
 
 package javax.swing.event;
 
-// Imports
 import java.util.EventListener;
 
+import javax.swing.ListModel;
+
 /**
- * ListDataListener public interface
+ * A codeListDataListener/code can register with a [EMAIL PROTECTED] 
ListModel} and
+ * receive notification of updates to the model.
+ * 
  * @author Andrew Selkirk
  * @author Ronald Veldema
  */
-public interface ListDataListener extends EventListener {
-
-   /**
-* Contents Changed
-* @param event ListDataEvent Event
-*/
-   void contentsChanged(ListDataEvent event);
-
-   /**
-* Interval Added
-* @param event ListDataEvent Event
-*/
-   void intervalAdded(ListDataEvent event);
-
-   /**
-* Interval Removed
-* @param event ListDataEvent Event
-*/
-   void intervalRemoved(ListDataEvent event);
+public interface ListDataListener extends EventListener 
+{
 
+  /**
+   * Notifies the listener that the contents of the list have changed
+   * in some way.  This method will be called if the change cannot be
+   * notified via the [EMAIL PROTECTED] #intervalAdded(ListDataEvent)} or the
+   * [EMAIL PROTECTED] #intervalRemoved(ListDataEvent)} methods.
+   * 
+   * @param event  the event.
+   */
+  void contentsChanged(ListDataEvent event);
+
+  /**
+   * Notifies the listener that one or more items have been added to the
+   * list.  The codeevent/code argument can supply the indices for the
+   * range of items added.
+   * 
+   * @param event  the event.
+   */
+  void intervalAdded(ListDataEvent event);
+
+  /**
+   * Notifies the listener that one or more items have been removed from
+   * the list.  The codeevent/code argument can supply the indices for 
+   * the range of items removed.
+   * 
+   * @param event  the event.
+   */
+  void intervalRemoved(ListDataEvent event);
 
-} // ListDataListener
+}
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: BasicComboBoxUI

2005-10-17 Thread David Gilbert
This patch (committed) ensures that the editable text field in a JComboBox is 
updated when the selection changes, and fixes a problem I was having with the JUnit 
TestRunner:


2005-10-17  David Gilbert  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicComboBoxUI.java
(ItemHandler.itemStateChanged): if combo box is editable, update edit
text field with new selection.

Regards,

Dave
Index: javax/swing/plaf/basic/BasicComboBoxUI.java
===
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,v
retrieving revision 1.22
diff -u -r1.22 BasicComboBoxUI.java
--- javax/swing/plaf/basic/BasicComboBoxUI.java 17 Oct 2005 13:35:58 -  
1.22
+++ javax/swing/plaf/basic/BasicComboBoxUI.java 17 Oct 2005 16:12:56 -
@@ -1021,6 +1021,8 @@
  */
 public void itemStateChanged(ItemEvent e)
 {
+  if (e.getStateChange() == ItemEvent.SELECTED  comboBox.isEditable())
+comboBox.getEditor().setItem(e.getItem());
   comboBox.repaint();
 }
   }
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: BasicTreeUI fix

2005-10-17 Thread Lillian Angel
Now this is completely fixed.

2005-10-17  Lillian Angel  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicTreeUI.java
(installUI): Moved call to installKeyboardActions and Listeners
to before expansion of root.
(paint): Added check to make sure the cached visible path is 
updated.
(treeExpanded): Added call to update visible path.
(treeCollapsed): Likewise.
(treeNodesChanged): Likewise.
(treeNodesInserted): Likewise.
(treeNodesRemoved): Likewise.
(treeStructureChanged): Likewise.
(paintRecursive): Moved code to paintRow.
(paintControlIcons): Fixed to paint custom control icons 
properly.
(paintExpandControl): Removed unneeded parameter.
(paintRow): Added code to paint the row with the correct width.
* javax/swing/plaf/metal/MetalTreeUI.java
(installUI): Moved code to expand the root after all the 
listeners have been initialized.

On Fri, 2005-10-14 at 17:42 -0400, Lillian Angel wrote:
 After testing some new apps, I noticed that there was a slight problem
 with some custom icons. I almost have it fixed completely.
 
 2005-10-14  Lillian Angel  [EMAIL PROTECTED]
 
 * javax/swing/LookAndFeel.java
 (makeIcon): Implemented.
 * javax/swing/plaf/basic/BasicTreeUI.java
 (updateCachedPreferredSize): Should only add with of control
 icon if
 not a leaf.
 (mousePressed): Fixed to use new gap field.
 (paintRecursive): Likewise.
 (paintRow): Likewise.
 (updateCurrentVisiblePath): Shouldn't include root if it is
 not of a valid size to be painted.
 
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/plaf/basic/BasicTreeUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.99
diff -u -r1.99 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java	14 Oct 2005 22:37:07 -	1.99
+++ javax/swing/plaf/basic/BasicTreeUI.java	17 Oct 2005 18:38:45 -
@@ -1187,7 +1187,6 @@
   isLeaf = treeModel.isLeaf(path[i]);
 if (!isLeaf  hasControlIcons())
   bounds.width += getCurrentControlIcon(curr).getIconWidth();
-
 maxWidth = Math.max(maxWidth, bounds.x + bounds.width);
   }
 preferredSize = new Dimension(maxWidth, (getRowHeight() * path.length));
@@ -1347,7 +1346,9 @@
 installDefaults();
 
 installComponents();
-
+installKeyboardActions();
+installListeners();
+
 setCellEditor(createDefaultCellEditor());
 createdCellEditor = true;
 isEditing = false;
@@ -1362,8 +1363,6 @@
   }
 treeSelectionModel = tree.getSelectionModel();
 
-installKeyboardActions();
-installListeners();
 completeUIInstall();
   }
 
@@ -1410,13 +1409,16 @@
   public void paint(Graphics g, JComponent c)
   {
 JTree tree = (JTree) c;
+if (currentVisiblePath == null)
+  updateCurrentVisiblePath();
+
 if (treeModel != null)
   {
 Object root = treeModel.getRoot();
 paintRecursive(g, 0, 0, 0, tree, treeModel, root);
 
 if (hasControlIcons())
-  paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, root);
+  paintControlIcons(g, 0, 0, 0, tree, treeModel, root);
   }
   }
 
@@ -2554,6 +2556,7 @@
 public void treeExpanded(TreeExpansionEvent event)
 {
   validCachedPreferredSize = false;
+  updateCurrentVisiblePath();
   tree.revalidate();
   tree.repaint();
 }
@@ -2567,6 +2570,7 @@
 public void treeCollapsed(TreeExpansionEvent event)
 {
   validCachedPreferredSize = false;
+  updateCurrentVisiblePath();
   tree.revalidate();
   tree.repaint();
 }
@@ -2750,6 +2754,7 @@
 public void treeNodesChanged(TreeModelEvent e)
 {
   validCachedPreferredSize = false;
+  updateCurrentVisiblePath();
   tree.revalidate();
   tree.repaint();
 }
@@ -2765,6 +2770,7 @@
 public void treeNodesInserted(TreeModelEvent e)
 {
   validCachedPreferredSize = false;
+  updateCurrentVisiblePath();
   tree.revalidate();
   tree.repaint();
 }
@@ -2783,6 +2789,7 @@
 public void treeNodesRemoved(TreeModelEvent e)
 {
   validCachedPreferredSize = false;
+  updateCurrentVisiblePath();
   tree.revalidate();
   tree.repaint();
 }
@@ -2800,6 +2807,7 @@
 public void treeStructureChanged(TreeModelEvent e)
 {
   validCachedPreferredSize = false;
+  updateCurrentVisiblePath();
   tree.revalidate();
   tree.repaint();
 }
@@ -3085,11 +3093,7 @@
 boolean isLeaf = mod.isLeaf(curr);
 Rectangle bounds = getPathBounds(tree, path);
 Object root = mod.getRoot();
-int 

[cp-patches] FYI: JList key bindings reworked

2005-10-17 Thread Anthony Balkissoon
This patch implements InputMap-ActionMap pairs for JList and removes the
KeyAdapater that used to directly listen for key presses.  Also fixes
some bugs in selectNextIndex and selectPreviousIndex as well as in when
these methods were being called (slight bugs, they were called on the
wrong keyStrokes and didn't check if they were already at the lowest or
highest index before advancing).

Working on this exposed problems in JViewport as scrolling through the
list didn't work perfectly, I've fixed what was fixable in
JViewport.scrollRectToVisible but have filed a bug report (PR 24411) for
a subtle problem with Viewports being 1 pixel smaller in width than they
should be.

I also added all the bindings for JList into
BasicLookAndFeel.initComponentDefaults for List.focusInputMap.

Not all the bindings are implemented yet, there is a commented out line
in BasicListUI.ListAction.actionPerformed (the last else statement)
that will display the names of unimplemented key bindings.  I don't
think all bindings are actually supposed to do something, like
selectNextColumn etc, I'm not sure how this is applicable to Lists but
it's in the JDK's List.focusInputMap.


2005-10-17  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JViewport.java:
(scrollRectToVisible): Return immediately if the View is null.  Check 
for contentRect being bigger than the port bounds separately in each 
direction, rather than together.
* javax/swing/plaf/basic/BasicListUI.java:
(KeyHandler): Removed this private class that listened directly for 
key presses.  This is now handled through InputMap-ActionMap pairs.
(ActionListenerProxy): New class to wrap the Actions for this lists
ActionMap.
(ListAction): New class, the actions for keypresses on this list.
(convertModifiers): New private method converts key press modifiers to 
the old style (CTRL_MASK instead of CTRL_DOWN_MASK, etc.).
(installKeyboardActions): Get the InputMap from the UIManager and 
register new InputMap-ActionMap pairs, then set these as the parents
of the list's InputMap and ActionMap.
(selectNextIndex): Avoid NPE by checking if we're already at the last
index.
(selectPreviousIndex): Check if we're already at the first index.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
(initComponentDefaults): Added bindings for List.focusInputMap.

--Tony
? javax/swing/text/WrappedPlainView.java
Index: javax/swing/JViewport.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JViewport.java,v
retrieving revision 1.31
diff -u -r1.31 JViewport.java
--- javax/swing/JViewport.java	17 Oct 2005 13:45:34 -	1.31
+++ javax/swing/JViewport.java	17 Oct 2005 18:32:22 -
@@ -566,32 +566,38 @@
*/
   public void scrollRectToVisible(Rectangle contentRect)
   {
+Component view = getView();
+if (view == null)
+  return;
+  
 Point pos = getViewPosition();
 Rectangle viewBounds = getView().getBounds();
 Rectangle portBounds = getBounds();
 
 // FIXME: should validate the view if it is not valid, however
 // this may cause excessive validation when the containment
-// hierarchy is being created.
+// hierarchy is being created.
+
+// Y-DIRECTION
 
 // if contentRect is larger than the portBounds, center the view
-if (contentRect.height  portBounds.height || 
-contentRect.width  portBounds.width)
-  {
-setViewPosition(new Point(contentRect.x, contentRect.y));
-return;
-  }
+if (contentRect.height  portBounds.height)
+  setViewPosition(new Point(pos.x, contentRect.y));
 
-// Y-DIRECTION
 if (contentRect.y  -viewBounds.y)
   setViewPosition(new Point(pos.x, contentRect.y));
 else if (contentRect.y + contentRect.height  
- -viewBounds.y + portBounds.height)
+ -viewBounds.y + portBounds.height) 
   setViewPosition (new Point(pos.x, contentRect.y - 
  (portBounds.height - contentRect.height)));
 
 // X-DIRECTION
 pos = getViewPosition();
+
+//  if contentRect is larger than the portBounds, center the view
+if (contentRect.width portBounds.width)
+setViewPosition(new Point(contentRect.x, pos.y));
+
 if (contentRect.x  -viewBounds.x)
   setViewPosition(new Point(contentRect.x, pos.y));
 else if (contentRect.x + contentRect.width  
Index: javax/swing/plaf/basic/BasicListUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicListUI.java,v
retrieving revision 1.32
diff -u -r1.32 BasicListUI.java
--- javax/swing/plaf/basic/BasicListUI.java	12 Oct 2005 12:09:59 -	1.32
+++ javax/swing/plaf/basic/BasicListUI.java	17 Oct 2005 18:32:22 -
@@ -44,22 

Re: [cp-patches] FYI: JTable rendering fix

2005-10-17 Thread Anthony Balkissoon
I noticed the TODO in your DefaultListSelectionModel patch, I don't
think it's necessary, this just returns false on the JDK.

Tony

On Mon, 2005-10-17 at 15:18 +, Roman Kennke wrote:
 This fixes painting of selected cells/rows.
 
 2005-10-17  Roman Kennke  [EMAIL PROTECTED]
 
 * javax/swing/DefaultTableCellRenderer.java
 (getTableCellRendererComponent): Setup colors (more) correctly.
 * javax/swing/DefaultListSelectionModel.java
 (isSelectedIndex): Check for an illegal index argument.
 
 
 /Roman
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: JTable rendering fix

2005-10-17 Thread Anthony Balkissoon
This patch breaks JTables where cell selection is allowed.  Attached to
this email is a test case, running it on the JDK shows that selecting
cells is allowed, and running it on ours selects only entire rows.

Reverting the patch solves this problem, so something is either wrong in
this patch or wrong elsewhere and needs to be fixed along with this
patch.

--Tony

On Mon, 2005-10-17 at 15:18 +, Roman Kennke wrote:
 This fixes painting of selected cells/rows.
 
 2005-10-17  Roman Kennke  [EMAIL PROTECTED]
 
 * javax/swing/DefaultTableCellRenderer.java
 (getTableCellRendererComponent): Setup colors (more) correctly.
 * javax/swing/DefaultListSelectionModel.java
 (isSelectedIndex): Check for an illegal index argument.
 
 
 /Roman
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches
import javax.swing.*;

class TestCase
{
  public static void main(String args[])
  {
JFrame jf = new JFrame();
JPanel topPanel;
JTable table;
JScrollPane scrollPane;

// Create a panel to hold all other components
topPanel = new JPanel();
jf.getContentPane().add( topPanel );

// Create columns names
String columnNames[] = { Column 1, Column 2, Column 3 };

// Create some data
String dataValues[][] =
  {
{ 12, 234, 67 },
{ -123, 43, 853 },
{ 93, 89.2, 109 },
{ 279, 9033, 3092 }
  };

// Create a new table instance
table = new JTable( dataValues, columnNames );

table.setColumnSelectionAllowed(true);
table.setRowSelectionAllowed(true);

// Add the table to a scrolling pane
scrollPane = new JScrollPane( table );
topPanel.add( scrollPane);

jf.pack();
jf.show();
  }
}
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches