Multiline cell table problem

hi all
i found in this forum a class that implements TableCellRenderer and that should allow my table to have multiline cells. i need it because if the content of my cell (retrieved via jdbc from a db) exceeds the cell width is truncated and a "..." appears.
so i searched, i founded and i tried some example but with no results. i don't know where is the mistake, also because the code should work.
i'll post the class code and my table's code and i hope someone could help me!!!
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.awt.*;
* @version 1.0 11/09/98
public class MultiLineCellRenderer extends JTextArea implements TableCellRenderer {
  public MultiLineCellRenderer() {
    setLineWrap(true);
    setWrapStyleWord(true);
    setOpaque(true);
  public Component getTableCellRendererComponent(JTable table, Object value,
               boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    setFont(table.getFont());
    if (hasFocus) {
      setBorder( UIManager.getBorder("Table.focusCellHighlightBorder") );
      if (table.isCellEditable(row, column)) {
        setForeground( UIManager.getColor("Table.focusCellForeground") );
        setBackground( UIManager.getColor("Table.focusCellBackground") );
    } else {
      setBorder(new EmptyBorder(1, 2, 1, 2));
    setText((value == null) ? "" : value.toString());
    return this;
}i set the new tablecellrenderer in this way:
table.setDefaultRenderer(String.class, new MultiLineCellRenderer() );
        Object[] columns=new Object[]{"Data","Ora","Nome","Referente","Indirizzo","Citt�","Telefono","Motivazione","App. con"};
        JTableHeader k=new JTableHeader();
        table.setTableHeader(k);
        table.setModel(new javax.swing.table.DefaultTableModel (o,columns)
                Class[] types = new Class [] {
                    java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
         anyone could help me?
thanx a lot

thanx to all my friends, but i still have my problem..
viravan, i'm using the same MultiLineCellRenderer class as the example, the only thing different is my class from where i set the MultiLineCellRenderer the default Renderer for my table
this is the code: (i post it because i didn't found any significant difference between the example class and the one of mine...) i suspect there is some problem in the table setting... but i don't know where...
import java.lang.Thread;
import java.sql.*;
import java.util.Vector;
import java.text.*;
import javax.swing.table.*;
public class AppTablePainter implements Runnable
    Thread t;
    DateFormat date;
    public AppTablePainter()
        t=new Thread(this);
        t.start();
    public void run()
        paint();
    void paint()
        Statement s=null;
        Vector clienti=new Vector();
        Vector appIl=new Vector();
        Vector hours=new Vector();
        Vector referenti=new Vector();
        Vector indirizzi=new Vector();
        Vector telefoni=new Vector();
        Vector citta=new Vector();
        Vector motivazioni=new Vector();
        Vector appCon=new Vector();
        Vector commerciali=new Vector();
        Vector commenti=new Vector();
        Vector ids=new Vector();       
        Vector tempCommerciali= new Vector();
        date=Jtm.date;
        String action="SELECT * FROM CONTATTI WHERE COMMERCIALE='"+Appuntamenti.cCommerciale.getSelectedItem()+"' AND APPUNTAMENTO_IL IS NOT NULL";
        //System.out.println(action);
        try
            s=Jtm.tmc.createStatement();
            ResultSet rs=s.executeQuery(action);           
            java.util.Date appDate;
            DateFormat appHour=new SimpleDateFormat("HH:mm");
            appHour.setLenient(false);
            String get=null;
            Appuntamenti.sp.set("Recupero appuntamenti in corso...");
            int maximum=0;
            while(rs.next())
                 try
                    maximum++;
                    get=rs.getString("appuntamento_il");                     
                    appDate=date.parse(get);               
                    String stringDate=date.format(appDate);                                       
                    if(!appDate.before(Jtm.now))
                        String id=rs.getString("id");
                        ids.add(id);  
                        appIl.add(get);                       
                        try
                            hours.add(appHour.format(appHour.parse(rs.getString("ore"))));                       
                        catch(ParseException p)
                            hours.add("23:00");
                        catch (NullPointerException np)
                            hours.add("23:01");
                catch(SQLException sq)
                    //JOptionPane.showMessageDialog(this, sq.getMessage(), "",JOptionPane.ERROR_MESSAGE);
                    sq.printStackTrace();
                catch(NullPointerException n){}
                catch(ParseException p)  //se la data non � parseable � perch� � nulla visto che c'� un controllo all'inserimento
                    //System.out.println("parseException "+get);
                    //JOptionPane.showMessageDialog(this, p.getMessage(), "",JOptionPane.ERROR_MESSAGE);
                    //p.printStackTrace();
            Appuntamenti.sp.progBar.setMaximum(maximum);
        catch(SQLException sq)
            sq.printStackTrace();
        catch(NullPointerException n)
            n.printStackTrace();
        /*System.out.println("prima ordinamento:");
        for(int i=0; i<ids.size();i++)
            System.out.println("id "+ids.get(i).toString()+", data app "+appIl.get(i).toString()+", ore "+hours.get(i).toString());
        for(int i=0; i<ids.size(); i++)
            System.out.println("ids("+i+")= "+ids.get(i).toString());
        for(int i=0; i<appIl.size(); i++)
            System.out.println("appIl("+i+")= "+appIl.get(i).toString());
        for(int i=0; i<hours.size(); i++)
            System.out.println("hours("+i+")= "+hours.get(i).toString());
        myAppArray[] dateArr=new myAppArray[appIl.size()];
        Appuntamenti.sp.set("Inizio ordinamento in corso");
        Appuntamenti.sp.progBar.setMaximum(appIl.size());
        for(int i=0; i<dateArr.length; i++)
            Appuntamenti.sp.progBar.setValue(i);
            dateArr=new myAppArray(ids.get(i).toString(),appIl.get(i).toString(),hours.get(i).toString());
java.util.Arrays.sort(dateArr, new ArrayAppDateComparator());
Vector newIds=new Vector();
for(int i=0; i< dateArr.length; i++)
myAppArray temp=dateArr[i];
//System.out.println("data: "+temp.getDate()+", ora: "+temp.getHour()+" id: "+temp.getId());
newIds.add(temp.getId());
appIl.clear();
hours.clear();
commerciali.clear();
clienti.clear();
commenti.clear();
try
Appuntamenti.sp.set("Recupero informazioni...");
Appuntamenti.sp.progBar.setValue(0);
Statement s1=Jtm.tmc.createStatement();
for(int i=0; i<newIds.size(); i++)
Appuntamenti.sp.progBar.setValue(i);
String tempId=newIds.get(i).toString();
//System.out.println("tempId: "+tempId);
ResultSet rs1=s1.executeQuery("select * from contatti where id="+tempId);
if(rs1.next())
appIl.add(rs1.getString("appuntamento_il"));
hours.add(rs1.getString("ore"));
clienti.add(rs1.getString("nome"));
referenti.add(rs1.getString("referente"));
indirizzi.add(rs1.getString("indirizzo"));
citta.add(rs1.getString("citta"));
telefoni.add(rs1.getString("telefono"));
motivazioni.add(rs1.getString("motivazione"));
appCon.add(rs1.getString("appuntamento_con"));
catch(SQLException sq)
sq.printStackTrace();
Object[][] o=new Object[ids.size()][9];
System.out.println("o.length: "+o.length);
String dataAppuntamento="";
for(int i=0; i<o.length; i++)
try
String tempData=appIl.get(i).toString();
if(tempData.equals(dataAppuntamento))
o[i][0]="";
else
dataAppuntamento=tempData;
o[i][0]=dataAppuntamento;
catch(NullPointerException n){o[i][0]="";}
for(int i=0; i<o.length; i++)
try
o[i][1]=hours.get(i).toString();
catch(NullPointerException n){o[i][1]="";}
for(int i=0; i<o.length; i++)
try
o[i][2]=clienti.get(i).toString();
catch(NullPointerException n){o[i][2]="";}
for(int i=0; i<o.length; i++)
try
o[i][3]=referenti.get(i).toString();
catch(NullPointerException n){o[i][3]="";}
for(int i=0; i<o.length; i++)
try
o[i][4]=indirizzi.get(i).toString();
catch(NullPointerException n){o[i][4]="";}
for(int i=0; i<o.length; i++)
try
o[i][5]=citta.get(i).toString();
catch(NullPointerException n){o[i][5]="";}
for(int i=0; i<o.length; i++)
try
o[i][6]=telefoni.get(i).toString();
catch(NullPointerException n){o[i][6]="";}
for(int i=0; i<o.length; i++)
try
o[i][7]=motivazioni.get(i).toString();
catch(NullPointerException n){o[i][7]="";}
for(int i=0; i<o.length; i++)
try
o[i][8]=appCon.get(i).toString();
catch(NullPointerException n){o[i][8]="";}
System.out.println("height: "+Appuntamenti.table.getRowHeight());
System.out.println("olenght: "+o.length);
System.out.println("risultato: "+ (Appuntamenti.table.getRowHeight() * o.length));
Appuntamenti.table.setRowHeight( Appuntamenti.table.getRowHeight());
//Appuntamenti.table.setRowHeight(16);
Appuntamenti.table.setDefaultRenderer(String.class, new MultiLineCellRenderer() );
Object[] columns=new Object[]{"Data","Ora","Nome","Referente","Indirizzo","Citt�","Telefono","Motivazione","App. con"};
JTableHeader k=new JTableHeader();
Appuntamenti.table.setTableHeader(k);
Appuntamenti.table.setModel(new javax.swing.table.DefaultTableModel (o,columns)
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
TableColumnModel tcm = Appuntamenti.table.getColumnModel();
TableColumn data = tcm.getColumn(0);
TableColumn ora = tcm.getColumn(1);
TableColumn cliente = tcm.getColumn(2);
TableColumn referente = tcm.getColumn(3);
TableColumn indirizzo = tcm.getColumn(4);
TableColumn citt = tcm.getColumn(5);
TableColumn telefono = tcm.getColumn(6);
TableColumn motivazione = tcm.getColumn(7);
TableColumn appcon = tcm.getColumn(8);
System.out.println("data "+data.getPreferredWidth());
System.out.println("ora "+ora.getPreferredWidth());
System.out.println("cliente "+cliente.getPreferredWidth());
System.out.println("referente "+referente.getPreferredWidth());
System.out.println("indirizzo "+indirizzo.getPreferredWidth());
System.out.println("citt "+citt.getPreferredWidth());
System.out.println("telefono "+telefono.getPreferredWidth());
System.out.println("motivazione "+motivazione.getPreferredWidth());
System.out.println("appcon "+appcon.getPreferredWidth());
data.setPreferredWidth(700);
ora.setPreferredWidth(350);
cliente.setPreferredWidth(1000);
referente.setPreferredWidth(1000);
indirizzo.setPreferredWidth(1300);
citt.setPreferredWidth(1000);
telefono.setPreferredWidth(1000);
motivazione.setPreferredWidth(1500);
appcon.setPreferredWidth(1000);
//data.setCellRenderer(new MultiLineTableCellRenderer());
//cliente.setCellRenderer(new MultiLineTableCellRenderer().getTableCellRendererComponent());
Appuntamenti.lTotale.setText(Integer.toString(o.length));
Appuntamenti.ids=newIds;
Appuntamenti.sp.mostra();
Appuntamenti.sp.dispose();
//Integer[] integerIds=Integer.ids.toArray();
for(int i=0; i<dateArr.length; i++)
System.out.println("dateArr["+i+"]= "+date.format(dateArr[i]));
java.util.Arrays.sort(dateArr);
for(int i=0; i<dateArr.length; i++)
System.out.println("ordinato dateArr["+i+"]= "+date.format(dateArr[i]));
class myAppArray
private String id;
private String date;
private String hour;
public myAppArray(String id, String date, String hour)
this.id=id;
this.date=date;
this.hour=hour;
public String getDate()
return date;
public String getHour()
return hour;
public String getId()
return id;
class ArrayAppDateComparator implements java.util.Comparator
private DateFormat date=Jtm.date;
private DateFormat hour=new SimpleDateFormat("HH:mm");
public int compare(Object o1, Object o2)
hour.setLenient(false);
myAppArray s1 = (myAppArray)o1;
myAppArray s2 = (myAppArray)o2;
java.util.Date d1=null;
java.util.Date d2=null;
java.util.Date h1=null;
java.util.Date h2=null;
try
d1 = date.parse(s1.getDate());
d2 = date.parse(s2.getDate());
catch(ParseException pe)
pe.printStackTrace();
if(!d1.equals(d2))
return d1.compareTo(d2);
else
try
h1 = hour.parse(s1.getHour());
h2 = hour.parse(s2.getHour());
catch(ParseException pe)
pe.printStackTrace();
return h1.compareTo(h2);

Similar Messages

  • Problem with addRow and MultiLine Cell renderer

    Hi ,
    Ive a problem with no solution to me .......
    Ive seen in the forum and Ivent found an answer.......
    The problem is this:
    Ive a JTable with a custom model and I use a custom multiline cell renderer.
    (becuse in the real application "way" hasnt static lenght)
    When I add the first row all seem to be ok.....
    when I try to add more row I obtain :
    java.lang.ArrayIndexOutOfBoundsException: 1
    at javax.swing.SizeSequence.insertEntries(SizeSequence.java:332)
    at javax.swing.JTable.tableRowsInserted(JTable.java:2926)
    at javax.swing.JTable.tableChanged(JTable.java:2858)
    at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableMo
    del.java:280)
    at javax.swing.table.AbstractTableModel.fireTableRowsInserted(AbstractTa
    bleModel.java:215)
    at TableDemo$MyTableModel.addRow(TableDemo.java:103)
    at TableDemo$2.actionPerformed(TableDemo.java:256)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
    64)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
    ctButton.java:1817)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:419)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:245)
    at java.awt.Component.processMouseEvent(Component.java:5134)
    at java.awt.Component.processEvent(Component.java:4931)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3639)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
    at java.awt.Container.dispatchEventImpl(Container.java:1609)
    at java.awt.Window.dispatchEventImpl(Window.java:1590)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:197)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    This seems to be caused by
    table.setRowHeight(row,(getPreferredSize().height+2)); (line 164 of my example code)
    About the model I think its ok.....but who knows :-(......
    Please HELP me in anyway!!!
    Example code :
    import javax.swing.*;
    import javax.swing.table.*;
    import java.text.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TableDemo extends JFrame {
    private boolean DEBUG = true;
    MyTableModel myModel = new MyTableModel();
    MyTable table = new MyTable(myModel);
    int i=0;
    public TableDemo() {
    super("TableDemo");
    JButton bottone = new JButton("Aggiungi 1 elemento");
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    //table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    //Add the scroll pane to this window.
    getContentPane().add(bottone,BorderLayout.NORTH);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    bottone.addActionListener(Add_Action);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    class MyTable extends JTable {
    MultiLineCellRenderer multiRenderer=new MultiLineCellRenderer();
    MyTable(TableModel tm)
    super(tm);
    public TableCellRenderer getCellRenderer(int row,int col) {
              if (col==1) return multiRenderer;
              else return super.getCellRenderer(row,col);
    class MyTableModel extends AbstractTableModel {
    Vector data=new Vector();
    final String[] columnNames = {"Name",
    "Way",
    "DeadLine (ms)"
    public int getColumnCount() { return 3; }
    public int getRowCount() { return data.size(); }
    public Object getValueAt(int row, int col) {
    Vector rowdata=(Vector)data.get(row);
                                                                return rowdata.get(col); }
    public String getColumnName(int col) {
    return columnNames[col];
    public void setValueAt (Object value, int row,int col)
         //setto i dati della modifica
    Vector actrow=(Vector)data.get(row);
    actrow.set(col,value);
         this.fireTableCellUpdated(row,col);
         public Class getColumnClass(int c)
              return this.getValueAt(0,c).getClass();
         public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col == 1)
    return false;
    else
    return true;
    public void addRow (String name,ArrayList path,Double dead) {
         Vector row =new Vector();
         row.add(name);
         row.add(path);
         row.add(dead);
         row.add(name); //!!!Mi tengo questo dato da utilizzare come key per andare a
         //prendere il path nella lista dei paths di Project
         //(needed as key to retrive data if name in col. 1 is changed)
         data.add(row);
         //Inspector.inspect(this);
         System.out.println ("Before firing Adding row...."+this.getRowCount());
         this.fireTableRowsInserted(this.getRowCount(),this.getRowCount());
    public void delRow (String namekey)
    for (int i=0;i<this.getRowCount();i++)
    if (namekey.equals(this.getValueAt(i,3)))
    data.remove(i);
    this.fireTableRowsDeleted(i,i);
    //per uscire dal ciclo
    i=this.getRowCount();
    public void delAllRows()
    int i;
    int bound =this.getRowCount();     
    for (i=0;i<bound;i++)     
         {data.remove(0);
         System.out.println ("Deleting .."+data);
    this.fireTableRowsDeleted(0,i);          
    class MultiLineCellRenderer extends JTextArea implements TableCellRenderer {
    private Hashtable rowHeights=new Hashtable();
    public MultiLineCellRenderer() {
    setEditable(false);
    setLineWrap(true);
    setWrapStyleWord(true);
    //this.setBorder(new Border(
    public Component getTableCellRendererComponent(JTable table,Object value,                              boolean isSelected, boolean hasFocus, int row, int column) {
    //System.out.println ("Renderer called"+value.getClass());
    if (value instanceof ArrayList) {
    String way=new String     (value.toString());
    setText(way);
    TableColumn thiscol=table.getColumn("Way");
    //System.out.println ("thiscol :"+thiscol.getPreferredWidth());
    //setto il size della JTextarea sulle dimensioni della colonna
    //per quanto riguarda il widht e su quelle ottenute da screen per l'height
    this.setSize(thiscol.getPreferredWidth(),this.getPreferredSize().height);
    // set the table's row height, if necessary
    //System.out.println ("Valore getPreferred.height"+getPreferredSize().height);
         if (table.getRowHeight(row)!=(this.getPreferredSize().height+2))
         {System.out.println ("Setting Row :"+row);
             System.out.println ("Dimension"+(getPreferredSize().height+2));
             System.out.println ("There are "+table.getRowCount()+"rows in the table ");
             if (row<table.getRowCount())
             table.setRowHeight(row,(getPreferredSize().height+2));
    else
    setText("");
    return this;
    /**Custom JTextField Subclass che permette all'utente di immettere solo numeri
    class WholeNumberField extends JTextField {
    private Toolkit toolkit;
    private NumberFormat integerFormatter;
    public WholeNumberField(int value, int columns) {
    super(columns);
    toolkit = Toolkit.getDefaultToolkit();
    integerFormatter = NumberFormat.getNumberInstance(Locale.US);
    integerFormatter.setParseIntegerOnly(true);
    setValue(value);
    public int getValue() {
    int retVal = 0;
    try {
    retVal = integerFormatter.parse(getText()).intValue();
    } catch (ParseException e) {
    // This should never happen because insertString allows
    // only properly formatted data to get in the field.
    toolkit.beep();
    return retVal;
    public void setValue(int value) {
    setText(integerFormatter.format(value));
    protected Document createDefaultModel() {
    return new WholeNumberDocument();
    protected class WholeNumberDocument extends PlainDocument {
    public void insertString(int offs,
    String str,
    AttributeSet a)
    throws BadLocationException {
    char[] source = str.toCharArray();
    char[] result = new char[source.length];
    int j = 0;
    for (int i = 0; i < result.length; i++) {
    if (Character.isDigit(source))
    result[j++] = source[i];
    else {
    toolkit.beep();
    System.err.println("insertString: " + source[i]);
    super.insertString(offs, new String(result, 0, j), a);
    ActionListener Add_Action = new ActionListener() {
              public void actionPerformed (ActionEvent e)
              System.out.println ("Adding");
              ArrayList way =new ArrayList();
              way.add(new String("Uno"));
              way.add(new String("Due"));
              way.add(new String("Tre"));
              way.add(new String("Quattro"));
              myModel.addRow(new String("Nome"+i++),way,new Double(0));     
    public static void main(String[] args) {
    TableDemo frame = new TableDemo();
    frame.pack();
    frame.setVisible(true);

    In the addRow method, change the line
    this.fireTableRowsInserted(this.getRowCount(),this.getRowCount()); to
    this.fireTableRowsInserted(data.size() - 1, data.size() - 1);Sai Pullabhotla

  • XSLT - html table problem

    Hi,
    I'm having a real problem with trying to get my xslt stylesheet to produce a html table.
    I want the table to look something like the following:
    |radio-button description | radio-button description |
    |radio-button description | radio-button description |
    |_________________________________________|
    So that each table row has the following:
    <tr><td>radio-button</td><td>decsription</td>
    <td>radio-button></td><td>description</td></tr>
    The code in the stylesheet is as follows:
    <CODE>
    <xsl:template match="table-RdbDataOptions2" >
    <!-- Add the data options and user info -->
    <table width="100%" border="0" align="left">
              <xsl:for-each select="td">
    <tr>
                   <td colspan="2">
                             <xsl:choose>
                                  <xsl:when test="position()=1">
                                       <div align="left" class="subheading"><xsl:value-of select="." /></div>
                                  </xsl:when>
                                  <xsl:when test="position()=2">
                                       <div align="left"><xsl:value-of select="." /></div>
                                  </xsl:when>
                             </xsl:choose>
                        </td>
                   </tr>
              </xsl:for-each>
    <!-- now build a 2x row/2x cell table-->
    <xsl:for-each select="rdb-DataOption">
    <xsl:choose>
    <xsl:when test="not(@recfav='')">
    <xsl:choose>
    <!-- when an uneven number, start a new table row. Add unevens to this row -->
    <xsl:when test="position() mod 2=1">
    <tr>
    <xsl:choose>
    <xsl:when test="@dataseriescheck=''">
    <td> <input type="radio" name="rdbDataOptions" value="series" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td> <input type="radio" name="rdbDataOptions" value="series" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    <xsl:when test="@aggregatecheck=''">
    <td> <input type="radio" name="rdbDataOptions" value="aggregate" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td><input type="radio" name="rdbDataOptions" value="series" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    </xsl:choose>
    </tr>
    </xsl:when><!-- end of test position() mod 2 = 1 -->
    <xsl:otherwise><!-- Add new row for even numbers -->
    <tr>
    <xsl:choose>
    <xsl:when test="@cummulativecheck=''">
    <td> <input type="radio" name="rdbDataOption" value="cummulative" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td><input type="radio" name="rdbDataOption" value="cummulative" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    <xsl:when test="@averagecheck=''">
    <td><input type="radio" name="rdbDataOption" value="Average" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td><input type="radio" name="rdbDataOption" value="Average" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    </xsl:choose>
    </tr>
    </xsl:otherwise><!-- end of adding new row for even numbers -->
    </xsl:choose>
    </xsl:when>
    </xsl:choose><!-- end of check for not recents -->
    <xsl:otherwise><!-- Recent -->
    <xsl:choose>
    <!-- when an uneven number, start a new table row. Add unevens to this row -->
    <xsl:when test="position() mod 2=1">
    <tr>
    <xsl:choose>
    <xsl:when test="@dataseriescheck=''">
    <td><input type="radio" name="rdbDataOptions" value="series" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td> <input type="radio" name="rdbDataOptions" value="series" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    <xsl:when test="@aggregatecheck=''">
    <td><input type="radio" name="rdbDataOptions" value="aggregate" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td><input type="radio" name="rdbDataOptions" value="series" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    </xsl:choose>
    </tr>
    </xsl:when><!-- end of test position() mod 2 = 1 -->
    <xsl:otherwise><!-- Add new row for even numbers -->
    <tr>
    <xsl:choose>
    <xsl:when test="@cummulativecheck=''">
    <td><input type="radio" name="rdbDataOption" value="cummulative" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td> <input type="radio" name="rdbDataOption" value="cummulative" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    <xsl:when test="@averagecheck=''">
    <td><input type="radio" name="rdbDataOption" value="Average" disabled="disabled"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:when>
    <xsl:otherwise>
    <td><input type="radio" name="rdbDataOption" value="Average" disabled="disabled" checked="checked"/></td>
    <td><div align="left"><xsl:value-of select="." /></div></td>
    </xsl:otherwise>
    </xsl:choose>
    </tr>
    </xsl:otherwise><!-- end of adding new row for even numbers -->
    </xsl:choose>
    </xsl:otherwise>
    </xsl:for-each>
    </table>
    </xsl:template>
    </CODE>
    The jsp creates the table in the following way:
    <CODE>
    <table-RdbDataOptions2>
    <td><%=Lang.get("DataOptions", User.getPrimary(), User.getFallback())%></td>
    <td><%=Lang.get("SelectDataOption", User.getPrimary(), User.getFallback())%></td>
    <rdb-DataOption recfav="<%=strDisabled %>" dataseriescheck="<%=strDataOption[0] %>" ><%=Lang.get("ShowDataSeries", User.getPrimary(), User.getFallback())%></rdb-DataOption>
    <rdb-DataOption recfav="<%=strDisabled %>" cumulativecheck="<%=strDataOption[1] %>" ><%=Lang.get("ShowCumulative", User.getPrimary(), User.getFallback())%></rdb-DataOption>
    <rdb-DataOption recfav="<%=strDisabled %>" aggregatecheck="<%=strDataOption[2] %>" ><%=Lang.get("ShowAggregate", User.getPrimary(), User.getFallback())%></rdb-DataOption>
    <rdb-DataOption recfav="<%=strDisabled %>" averagecheck="<%=strDataOption[3] %>" ><%=Lang.get("ShowDataSeriesAverage", User.getPrimary(), User.getFallback())%></rdb-DataOption>
    </table-RdbDataOptions>
    </CODE>
    The following is the error I'm receiving:
    javax.servlet.jsp.JspException: Error applying stylesheet..........
    I can easily produce a table with like this:
    |radio button description |
    |radio button description |
    |radio button description |
    |radio button description |
    |____________________|
    but unfortunately that's not what's req'd!
    Any help is disciplining the above stylesheet so that it does what its told would be greatly appreciated.
    Yours, with respect!
    Eddie.

    Well,
    Funny how just looking at your own posting can highlight pretty obvious errors.
    The reason for the stylesheet error msg was that the opening & closing table tags in the jsp didn't match!
    However, I now get an almost empty table. I get the table headers - in other words, this part of the stylesheet is working properly:
    <CODE>
    <xsl:for-each select="td">
    <tr>
                   <td colspan="2">
                             <xsl:choose>
                                  <xsl:when test="position()=1">
                                       <div align="left" class="subheading"><xsl:value-of select="." /></div>
                                  </xsl:when>
                                  <xsl:when test="position()=2">
                                       <div align="left"><xsl:value-of select="." /></div>
                                  </xsl:when>
                             </xsl:choose>
                        </td>
                   </tr>
              </xsl:for-each>
    </CODE>
    But the rest is returning 'empty'. So, it nows seems that one or more of my tests is not working properly.
    Onwards & upwards,
    Eddie

  • How do I change the number formatting within a Cell Table in Microsoft Word?

    Hi, I was wondering if someone could help me out on an issue I've been having... I work for an accounting firm and we do a lot of financial statements. 
    I was wondering if we would be able to treat a cell table in Microsoft Word 2007 like I would a cell table in Microsoft Excel. Meaning, I would like to change the formatting of the numbers in the table to the "Accounting" (number) format so it
    aligns by the decimal point and use the $ signs and () for negative numbers.  We do use the link tables feature, however, most of our balancing pages just can't be done in Excel because of the way the text is written. It would be much harder to format
    the text if it were to be typed in Excel. We have also tried  creating an Excel sheet within Microsoft Word but it is the same as linking the tables... Again, a text formatting issue.  The only option is to use tables within Word but how do we change
    the number formatting to a "accounting" (number) format where the numbers would align with the decimal point and use () for the negative numbers. Is there ANY option for us to do this other than manually entering this information in using tabs?  
    If there are no options other than entering it in manually, please consider this as an option for your next software update. I believe that a LOT of people out there will be interested in this feature... My manager and I just attended a webinar on Microsoft
    Advanced Word Tips Tricks and Techniques and 75% of the attending people had this question but no answer.
    Thank you very much for your help!!!!!

    Word does not really have number formatting for table cells. You can align cell contents on the decimal point, though, by setting a so-called decimal tab stop.
    Option 1:
    - Select the cells for which you want to do this.
    - Display the ruler.
    - Click the Tab box on the left hand side of the ruler until the box contains an inverted T with a dot.
    - Click in the ruler where you want the decimal tab.
    Option 2:
    - Select the cells for which you want to do this.
    - Click the arrow in the lower right corner of the Paragraph group on the Home tab of the ribbon.
    - Click the Tabs... button in the lower left corner of the dialog.
    - Specify a tab position in the box, e.g. 1.5".
    - Select the 'Decimal' radio button under 'Alignment'.
    - Click Set.
    - Click OK.
    You will have to type the numbers as they should appear, including the $ for currency and the ( ) for negative numbers.
    Regards, Hans Vogelaar

  • Autonomous Trigger / Mutating Table Problem

    We have a specific problem in one of our applications being developed where by the database needs to enforce a specific business requirement.
    We need to use a database trigger to enforce some data integrity which involves more than one table as such cannot use standard constraint. The integrity has to be maintained in the database as the DML statements may be coming from a Java application or PL/SQL code as such we need the logic all in one place.
    The problem being that within the trigger we need to examine the state of the table the trigger is associated with as well as one other table. Obviously using a trigger on a table that is being affected by DML statements causes the dreaded mutating table problem.
    One suggested solution to this was to make the trigger or the code the trigger called autonomous. This allows the trigger to execute by only showing the trigger the original state of the table before any of the DML statements have affected it.
    The problem is this seems to work for single row DML statements but not for multi row DML statements. In multi row the trigger only sees the original state of the table, not the state of the table plus the changes made by any other actions in the same DML statement.
    Below I have shown an example of what I'm seeing.
    I have grossly simplified the example code below to only refer to a single table and use stupidly simple logic
    I do realise i appear to be implementing uniqueness in my own PL/SQL code, this is purely for the example.
    CREATE TABLE mutate_test
    id INTEGER NOT NULL,
    value VARCHAR2(255) NOT NULL
    ALTER TABLE mutate_test ADD CONSTRAINT pk_mutate_test PRIMARY KEY(id);
    ALTER TABLE mutate_test ADD CONSTRAINT ck_mutate_test CHECK (value = UPPER(value));
    CREATE OR REPLACE FUNCTION duplicate_found(in_value IN mutate_test.value%TYPE) RETURN BOOLEAN IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    v_value_found INTEGER;
    BEGIN
    SELECT COUNT(*)
    INTO v_value_found
    FROM mutate_test
    WHERE value = in_value;
    IF v_value_found > 0 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    END;
    CREATE OR REPLACE TRIGGER tr_mutate_test BEFORE INSERT OR UPDATE ON mutate_test
    FOR EACH ROW
    BEGIN
    IF duplicate_found(:new.value) = TRUE THEN
    RAISE_APPLICATION_ERROR(-20000,'Duplicate value found');
    END IF;
    END;
    INSERT INTO mutate_test (id,value) VALUES (1,'CLIFF');
    INSERT INTO mutate_test (id,value) VALUES (2,'SULA');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 already has a value of CLIFF
    INSERT INTO mutate_test (id,value) VALUES (3,'CLIFF');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 is already set to CLIFF
    UPDATE mutate_test SET value = 'CLIFF' WHERE id = 2;
    COMMIT;
    SELECT * FROM mutate_test;
    UPDATE mutate_test SET value = 'CLIFFORD' WHERE id = 1;
    COMMIT;
    SELECT * FROM mutate_test;
    INSERT INTO mutate_test (id,value) VALUES (3,'RONNY');
    INSERT INTO mutate_test (id,value) VALUES (4,'TIM');
    INSERT INTO mutate_test (id,value) VALUES (5,'MONIQUE');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Wanted result would be row 1 would be updated from CLIFFORD to CLIFF
    -- and the others raise errors, or all of them raise errors.
    UPDATE mutate_test SET value = 'CLIFF' WHERE id IN (1,3,4);
    COMMIT;
    SELECT * FROM mutate_test;

    This is all from a University application that deals with eLearning.
    Shell = Mapping from the system to an external eLearning application, ie: unique id of the Blackboard course shell, or WebBoard board.
    Term = Academic term
    Sector = University sector, ie: Higher Education, TAFE, etc..
    Resource = eLearning tool, ie: Blackboard, WebBoard, etc..
    Resource Level = Whether the resource is being offered at a Course or Program level
    Resource Mapping = Association of a resource to shell
    What we are trying to achieve is that shells cannot be used across sector boundaries.
    The real table structure is (grossly simplified again)
    CREATE TABLE sector (sector_pk INTEGER PRIMARY KEY);
    CREATE TABLE sector_pattern (sector_pk INTEGER REFERENCES sector(sector_pk), pattern CHAR(2) NOT NULL UNIQUE CHECK (pattern = UPPER(pattern)));
    CREATE TABLE term (term_pk INTEGER PRIMARY KEY, term CHAR(4) NOT NULL UNIQUE CHECK (term = UPPER(term)));
    CREATE TABLE resource_level (resource_level_pk INTEGER PRIMARY KEY, term_pk INTEGER REFERENCES term(term_pk));
    CREATE TABLE shell_detail (shell_detail_pk INTEGER PRIMARY KEY);
    CREATE TABLE resource_mapping (resource_mapping INTEGER PRIMARY KEY, resource_level_pk INTEGER REFERENCES resource_level(resource_level_pk), shell_detail_pk INTEGER REFERENCES shell_detail(shell_detail_pk));
    Based on the Ask Tom article linked I'd liked to use a MATERIALIZED VIEW on the following query
    SELECT DISTINCT rm.shell_detail_pk,sp.sector_pk
    FROM resource_mapping rm, resource_level rl, term t, sector_pattern sp
    WHERE rm.resource_level_pk = rl.resource_level_pk
    AND rl.term_pk = t.term_pk
    AND SUBSTR(t.term,3,2) = sp.pattern;
    Then apply a UNIQUE constraint on that VIEW.
    But I'm receiving a
    SQL Error: ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    I'm not sure how to create the MATERIALIZED VIEW LOG entries for the above VIEW.
    Any ideas anyone? ;)
    Need to do some more reading and research but as Tom says
    "I'm asking around about the future of "SQL" as far as enhancments go like that
    (will update when I get some feedback), but -- you are not limited to triggers
    (in fact, I would avoid triggers as it is virtually IMPOSSIBLE to implement
    cross row/cross object constraints with them!!!! at least correctly)"
    So I think i'll give up on the TRIGGER approach as it doesn't meet our requirements.

  • Mutating table problem help required

    Hi. I am rather hoping someone will be able to help me with this problem.
    I have two tables, sa and mv. Create script below:
    create table mv (
    moduleId Char(2) CONSTRAINT ck_moduleId CHECK(moduleId in ('M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8')),
    credits Number(2) CONSTRAINT ck_credits CHECK(credits in (10, 20, 40)),
    constraint pk_mv primary key(moduleId)
    create table sa (
    stuId Char(2) CONSTRAINT ck_stuId CHECK(stuId in ('S1', 'S2', 'S3', 'S4', 'S5')),
    moduleId Char(2),
    constraint pk_sa primary key(stuId, moduleId),
    constraint fk_moduleid foreign key(moduleId) references mv(moduleId)
    And the scripts below is to insert data into both:
    insert into mv VALUES('M1', 20)
    insert into mv VALUES('M2', 20)
    insert into mv VALUES('M3', 20)
    insert into mv VALUES('M4', 20)
    insert into mv VALUES('M5', 40)
    insert into mv VALUES('M6', 10)
    insert into mv VALUES('M7', 10)
    insert into mv VALUES('M8', 20)
    insert into sa VALUES('S1', 'M1')
    insert into sa VALUES('S1', 'M2')
    insert into sa VALUES('S1', 'M3')
    insert into sa VALUES('S2', 'M2')
    insert into sa VALUES('S2', 'M4')
    insert into sa VALUES('S2', 'M5')
    insert into sa VALUES('S3', 'M1')
    insert into sa VALUES('S3', 'M6')
    Now for the actual problems.
    Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
    Just one or the other. I have created a single trigger, but if fails because of the mutating table problem.
    The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table.
    Many thanks in advance for any assistance.

    Use a statement level trigger:
    Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
    SQL> create or replace trigger sa_trg
      2  after insert or update on sa
      3  declare
      4  c number;
      5  begin
      6    select count(distinct moduleId) into c
      7    from sa
      8    where stuid = 'S1'
      9    and moduleId in ('M5','M6');
    10    if c > 1 then
    11       raise_application_error(-20001,'S1 on both M5 and M6!!');
    12    end if;
    13  end;
    14  /
    Trigger created.
    SQL> select * from sa;
    ST MO
    S1 M1
    S1 M2
    S1 M3
    S2 M2
    S2 M4
    S2 M5
    S3 M1
    S3 M6
    8 rows selected.
    SQL> insert into sa values ('S1','M5');
    1 row created.
    SQL> insert into sa values ('S1','M6');
    insert into sa values ('S1','M6')
    ERROR at line 1:
    ORA-20001: S1 on both M5 and M6!!
    ORA-06512: at "SCOTT.SA_TRG", line 9
    ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'
    The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table
    SQL> create or replace trigger sa_trg
      2  after insert or update on sa
      3  declare
      4  c number;
      5  begin
      6    select count(distinct moduleId) into c
      7    from sa
      8    where stuid = 'S1'
      9    and moduleId in ('M5','M6');
    10    if c > 1 then
    11       raise_application_error(-20001,'S1 on both M5 and M6!!');
    12    end if;
    13 
    14    select count(*) into c from (
    15    select stuid
    16    from mv, sa
    17    where sa.moduleid=mv.moduleid
    18    group by stuid
    19    having sum(credits)>120);
    20 
    21    if c > 0 then
    22       raise_application_error(-20002,'A student cannot have more than 120 credits!!');
    23    end if;
    24 
    25  end;
    26  /
    Trigger created.
    SQL>   select stuid, sum(credits)
      2  from mv, sa
      3  where sa.moduleid=mv.moduleid
      4  group by stuid;
    ST SUM(CREDITS)
    S3           30
    S2           80
    S1          100
    SQL> insert into sa
      2  values ('S1','M4');
    1 row created.
    SQL>   select stuid, sum(credits)
      2  from mv, sa
      3  where sa.moduleid=mv.moduleid
      4  group by stuid;
    ST SUM(CREDITS)
    S3           30
    S2           80
    S1          120
    SQL> insert into sa
      2  values ('S1','M7');
    insert into sa
    ERROR at line 1:
    ORA-20002: A student cannot have more than 120 credits!!
    ORA-06512: at "SCOTT.SA_TRG", line 20
    ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'Max
    http://oracleitalia.wordpress.com

  • SAPSCRIPT: How change background color cell/table

    Hi!
    How can I change background color cell/table in Sapscript?
    Thanks very much!

    Hi ,
    Normally we use Scripts and smartforms for submitting the output to customers or for tax purpose  and so on,,in such case we wont submit in differnt color other than white and black,so formatting in other colors is not possible in Script and smartforms.
    Please let me know if have any issues on this.
    Thanks and regards,
    Rajeshwar

  • Table Problems (Cell Shading and Default Format from EDD and Template)

    I have two problems related to tables using Structured FrameMaker (Version 10), whilst in-processing XML.
    I've designed two different table formats in my Template; Format A with black shading - 30% for THead and 3% for row, and Format B with blue shading - 30% for THead and 3% for row.
    If I create a structured document from scratch and insert a table, I get the required Black (30%) and Black (3%) shading.   If I then insert an informaltable, I get the required Blue (30%) and Blue (3%) shading.
    Although I've given the two table types different default formats in the EDD - Format A for table and Format B for informaltable - when I open the XML file (normally) from within FrameMaker I notice that all the tables default to Format A (black shading).   When I then import my EDD table should stay as Format A and informaltable should change to Format I.   This doesn't happen; they all stay at Format A.
    I can change informaltable by manually applying Format I, this worksI.  Obviously, with long documents which might have hundreds of tables we can't afford the time and manpower to do such things one at a time by hand.
    Do any of the Structure gurus have a fix for this, or can someone give me a hint of what I might be doing wrong?
    The second, but related question was a general one.   I see that Adobe says
    "Tables
    FrameMaker table formats are only partially integrated with the structure model. The content of
    a FrameMaker table is always fully structured, but the control over cell border ruling is limited and
    there is no structure format control over cell shading."
    I believe it could be useful to apply cell shading on an individual cell basis (although I'm not sure whether this is possible at the XML level - where someboddy might give an element an attribute of, say, shading (with options, such as, green, red, blue, yellow all at, say, 30%, with a default of red, for example.
    I've seen that there has been mention of plugins to achieve cell shading in structure; does anyone have an experience with such things, more to the point, can anyone point me in the right direction?   I don't mind paying fo a solution which I can implement myself.
    Any help or advice would be much appreciated.
    Regards
    Chris

    Hi,
    could you please provide some details on the EDD, RWR and some example XML?
    My wild guess goes into the direction of the RWR not containing enough information that get written out into XML.
    We're using table formatting with shaders too (using an attribute to control the specific formatting of each table) and it works like a charm in FM9 and FM11 when roundtripping.
    The context rules are used in the table group (i.e. tgroup element). This might already solve the issue .
    Cheers Alex

  • Table cell align problem

    I am using checkbox in my table using tablecellrenderer.i am able to align the checkbox to left.but it's showing center position when u click & hold.how to do that?
    thanka in advance

    You would have to provide your own cell editor that is left-aligned, as well as the renderer.

  • JComboBox table cell renderer problem

    The following program demonstrates a difference in behavior of table cell editor combobox based on whether the combo box is editable or not. If the ComboBox is editable, then the first click into the table cell starts the edit and shows the popup, whereas if the combobox is not editable then it takes 2 clicks into the cell to cause the popup to become visible. I am trying to achieve the 1 click popup behavior while keeping the combobox not editable. Run the following program, and click on various cells, the top table requires 2 clicks for a popup, and the bottom table only 1. The only difference is the editablility of the combobox. (This is windows l&f)
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.DefaultCellEditor;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTable;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    public class JTableComboBoxCellEditorTest {
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception e){e.printStackTrace();}
              DefaultTableModel tableModel = new DefaultTableModel(
                        new Object[][] {{"1","2"},{"2","3"},{"3","1"} },
                        new Object[]{"Column1","Column2"}
              final JComboBox renderer = new JComboBox(new Object[]{"1","2","3"});
              TableCellRenderer cellRenderer = new TableCellRenderer() {
                   public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col){
                        renderer.setSelectedItem(value);
                        return renderer;
              JTable table1 = new JTable(tableModel);
              final JComboBox badEditor = new JComboBox(new Object[]{"1","2","3"});
              badEditor.setEditable(false);
              table1.setDefaultEditor(Object.class, new DefaultCellEditor(badEditor));
              table1.setDefaultRenderer(Object.class, cellRenderer);
              table1.setRowHeight(24);
              JTable table2 = new JTable(tableModel);
              final JComboBox goodEditor = new JComboBox(new Object[]{"1","2","3"});
              goodEditor.setEditable(true);
              table2.setDefaultEditor(Object.class, new DefaultCellEditor(goodEditor));
              table2.setRowHeight(24);
              table2.setDefaultRenderer(Object.class, cellRenderer);
              JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,new JScrollPane(table1), new JScrollPane(table2));
            JFrame f = new JFrame("Table Test");
            f.getContentPane().add(split,BorderLayout.CENTER);
                f.setBounds(100,100,500,500);
            f.addWindowListener(new WindowAdapter() {
                 public void windowClosing(WindowEvent e) {
                      System.exit(0);
            f.setVisible(true);
    }

    Setting a renderer for first column:
    assetTable.getColumnModel().getColumn(1).setRenderer(tableRenderer);Your custom renderer must honor the selection color and border or otherwise the first column will not look selected. You should subclass DefaultTableCellRenderer:
    public class AssesTableRenderer extends DefaultTableCellRenderer  {
      public Component getTableCellRendererComponent(...) {
        // default renderer uses a label
        JLabel label = (JLabel)super.getTableCellRendererComponent(...);
        // decide icon to use
        Icon icon = ...;
        label.setIcon(icon);
       return label;
    }

  • Table Cell Renderer Problem

    I've created a JTable and filled it with data. I created my own header renderer so that I could have more control over the font of the header. I did the same with the cells of the table. Before I created the cell renderer, the cell and row selection (the highlighting of the selections) worked fine. Once I created and implemented the cell renderer, I can set the font the way I want, but the cell no longer highlights the selected rows. It's selecting the rows (my System.out.println in getTableCellRendererComponent() comes back with data). I'm not sure what I'm doing wrong. Here's some of the code....
    runTable = new JTable(tableModel);
    runTable.setBackground(Color.white);
    runTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    CellRenderer cellRenderer = new CellRenderer();
    // Set column 1's header
    String[] header1 = {"Time"," Of ","Day"};
    TableColumn col1 = runTable.getColumnModel().getColumn(0);
    col1.setHeaderValue(header1);
    col1.setCellRenderer(cellRenderer);
    String[][] parms = zoomplot.zmenubar.getParmSel();
    TableColumn col;
    for (int i = 0; i < parms.length; i++) {
    String[] header = new String[3];
    header[0] = parms[0];
    header[1] = " (" + parms[i][1] + ") ";
    header[2] = "Rate " + parms[i][2];
    col= runTable.getColumnModel().getColumn(i + 1);
    col.setHeaderValue(header);
    // col.setMaxWidth(100);
    col.setCellRenderer(cellRenderer);
    class CellRenderer extends JLabel
    implements TableCellRenderer {
    Color background = null;
    public CellRenderer() {
    // setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // setOpaque(false);
    public Component getTableCellRendererComponent(
    JTable table, Object value,
    boolean isSelected, boolean hasFocus,
         int row, int col) {
    removeAll();
    invalidate();
    add(Box.createVerticalGlue());
    setText((String)value);
    setFont(Utils.courierBold11);
    setHorizontalAlignment(SwingConstants.CENTER);
    setAlignmentX((float)0.5);
    if (isSelected) {
    this.setBackground(Color.black);
    // System.out.println("Row " + row + ", Col " + col + " is selected");
    return this;
    public void setBackground(Color back) {
    background = back;
    super.setBackground(back);
    I even tried to "manually" set the highlighting in getTableCellRendererComponent() ...
    if (isSelected) {
    this.setBackground(Color.black);
    but that didn't work either. Any Ideas..... Thanks.....

    When creating a custom renderer it is generally easier to extend the DefaultTableCellRenderer as it already has the custom code to do row highlighting, border selection etc. Also it has been optimized to paint faster.
    In your particular case it looks like your don't even need to do that. Just create a DefaultTableCellRenderer and change a few of its properties. Something like:
    // Override default renderer for a specific column
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment( JLabel.CENTER );
    centerRenderer.setFont(...);
    table.getColumnModel().getColumn(2).setCellRenderer( centerRenderer );

  • Aligning the Text in Centre for MultiLine Cells in JTable

    Hi;
    Does anyone know how I could make a java table that has multiline text cells AND this multiline text is aligned to center? I tried to extend JTextArea and to implement TableRenderer - multiline was OK but it did not do anything on setHorizontalAlign. If I extend DefaultTableRender than I can align the text to center but I got no multiline...
    Any ideas?
    Kindly to provide me a solution for this its urgent.

    Hi;
    Thanks for the reply,on using Text Area as renderer i.e using Multi-Line cells in JTable, i achieved the objective of displaying the text on multiple lines in the cell."In my Table there are 5 columns and i'm setting renderer on 3rd and 5th column,If the text is too large in column 5 it automatically gets wrapped off for all the cells in column 5.For column 3 my text is not so large as compared to column 5 and due to which the Text in the column 3 starts from the top for all the cells i.e (the first row in column 3 is parallel to first row in column 5 ),Now the problem is i can't display the text in the center of all cells for Column 3 .
    Thanks in advance

  • Labview 2013 report generation toolkit word 2010 insert table problem

    Hi,
    I am currently evaluating LV2013 with respect to the report generation toolkit for use with word 2010. My Vi/program won't insert the correct table and gives me an error message. see below:-
    Exception occured in Microsoft Word: The requested member of the collection does not exist.Help Path is wdmain11.chm and context 25421 in NI_ReportGenerationToolkit.lvlib:Word_Insert_Table​.vi->NI_Word.lvclass:Append Text Table to Report.vi->Word Table save.vi
    I have since run the following word example.vi provided by NI within LV2013 office examples:- Growable table.vi. this gives me the same error!
    Exception occured in Microsoft Word: The requested member of the collection does not exist.Help Path is wdmain11.chm and context 25421 in NI_ReportGenerationToolkit.lvlib:Word_Insert_Table​.vi->NI_Word.lvclass:Append Text Table to Report.vi->Growable table.vi
    It would seem that regardless of my own Vi there is a fundamental problem in the office example vi.
    I have found examples of a similar problem in LV2011/2012 but the work around code doesn't seem to match the LV2013 vi's code for a direct replacement.
    Can anyone help/shed some light on this? 
    Thanks in advance,
    Dan.

    Because the upgrade of Word from 2007 to 2010 I needed to upgrade an existing application from LabVIEW 2009 to 2013. This didn't work because of the insert table error. I discovered that the problem is the vi called "Word_Insert_Table.vi" located in the ..Program Files (x86)\National Instruments\LabVIEW 2013\vi.lib\addons\_office\_wordsub.llb. There is a "Cut" command implemented, this command removes the created cell instead of clearing it. Therefore the table will be filled half and then returnes with an error. I have removed this command. I have posted the changed vi (LV 2013).
    Attachments:
    Word_Insert_Table.vi ‏30 KB

  • Table problems in ie explorer

    Hi everyone,
    Just made a site (www.prodetail.ie) and was testing it in
    firefox during design but now when i look at it in ie explorer
    there's two problems, as you'll see, the menu on the left is too
    wide and the menu above the flash is suspended, it isnt sitting at
    the bottom of the table.
    Can anyone have a quick look at the code and tell me why that
    is happening in ie explorer but it is ok in firefox.
    Thanks

    >but from looking at the services
    > page is it not possible to see the difference between
    that and whatever is
    > in
    > the home page thats making the menu cell wider than it
    should be?
    But it's not just the services page - it's all of them in IE.
    I'm sorry, I
    just can't help you until you fix the basic errors then I'm
    sure somebody
    will be able to help with the rest of it.
    > i'm not hmtl competent really so fixing those sort of
    problems is
    > difficult.
    It's actually really difficult for us too. You really -
    REALLY need to fix
    your site definition before anything else and sort out the
    files that are
    pointing to your hard drive. Have you read what Murray
    pointed you to? If so
    can you tell us how you defined the site?
    Jo
    "neil.pb" <[email protected]> wrote in
    message
    news:g2pd5r$2qv$[email protected]..
    > i'm not hmtl competent really so fixing those sort of
    problems is
    > difficult.
    > But, and this could be because of the above, but from
    looking at the
    > services
    > page is it not possible to see the difference between
    that and whatever is
    > in
    > the home page thats making the menu cell wider than it
    should be?
    >

  • Cell alignment problems

    hi, im currently working on a website with dreamweaver, its
    only the 2nd html site ive ever made.
    both sites have been photography portfolios, so involve
    thumbnailed galleries. i figured it would be easiest to use tables
    to create the pages, as the the images are different sizes (some
    landscape, some portrait etc). i used css for properties of cells.
    problem is, when i move from one page to another in the
    browser (seems to be every browser, but some are worse than
    others), the cells appear to move. some of them have borders so
    this is quite obvious.
    am i missing something glaringly obvious? i find it so
    frustrating, i have tried adjusted the cell widths through css and
    single cell properties but neither seem to make the slightest
    difference. it appears the content that is in each cell determines
    the width of it in the browser, how can i control this so i can
    maintain uniform alignment throughout the site?
    many thanks in advance for any advice whatsoever

    With a single table like that, you'll experience the size
    shifts. You
    may want to use a single nested table for the content.
    Outer table - 3 rows
    top row, colspan 2
    middle row, thin left cell for navbar, wide right cell to
    hold nested table
    bottom row, colspan 2
    Set explicit widths for the middle row cells.
    In the middle row right cell, place a nested table with the
    page content.
    Another option is to go "tableless" and just use CSS for the
    layout.
    (PS - I didn't even notice the buttons on the left for a
    while. I stared
    dumbly at the page wondering how to get to the next page. The
    buttons
    are so dim they are difficult to see against the black
    background.
    Depending on the angle of my LCD screen, sometimes they
    disappear entirely.)
    Alec
    Adobe Community Expert

Maybe you are looking for