benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

CellRendererComponents#textFrom #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I use a JList with a custom ListCellRenderer and I want to use the
selectItem and selectItems methods of JListFixture. The problem is that
CellRendererComponents#textFrom assumes that the default renderer, a
JLabel, is used.
The method should be modified to allow for some degree of extensibility.
Using an interface, for example:

final class CellRendererComponents {

  static String textFrom(Component cellRendererComponent) {
    String text = null;
    if (cellRendererComponent instanceof TextualCellRenderer) {
      text = ((TextualCellRenderer)cellRendererComponent).getText();
    } else if (cellRendererComponent instanceof JLabel) {
      text = ((JLabel)cellRendererComponent).getText();
    }
    if (text != null) text = text.trim();
    return text;
  }

  private CellRendererComponents() {}
}

interface TextualCellRenderer {
  String getText();
}

Original issue reported on code.google.com by csaba.ju...@gmail.com on 10 Jun 2008 at 12:06

GoogleCodeExporter commented 9 years ago
In version 1.0a2, FEST provides cell readers (JListCell reader for JList,) that 
users
can extend to support their own cell renderers in JComboBoxes, JLists, JTables 
and
JTrees. For more details please visit
http://fest.easytesting.org/swing/wiki/pmwiki.php?n=FEST-Swing.CustomCellRendere
rs

Please note, there is a bug in the JComboBoxDriver that is not using the cell 
reader
for certain methods. I already fixed the bug and will be part of release 1.0a3.

Thanks!
-Alex

Original comment by Alex.Rui...@gmail.com on 10 Jun 2008 at 12:56

GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 2:02