JTable rows gets white with invisible text

I m using a JTable with custom colorRender....(part of the implementation given below)....Sometime all row's text becomes invisible but if you copy this text and paste it into MS-Excel it will successfully copy to excel cells. Furthermore when this problem occurs Java Clinet Console also become distorted and nothing is displayed over there
public Component getTableCellRendererComponent(JTable table,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int row,
      int column)
       try
          Color bgrd = null;
          Color fgrd = null;
          Font fnt = null;
          if (isSelected)
               column = table.convertColumnIndexToModel(column);
               // Get the colors from the provider
               FontColorInfo FCInfo = ColorProvider.getFontColorInfo(row, column);
               if (FCInfo != null)
                   bgrd = new Color( 255 - FCInfo.getBGColor().getRed(),
                                            255 - FCInfo.getBGColor().getGreen(),
                                            255 - FCInfo.getBGColor().getBlue()); //FCInfo.getBGColor().getBlue();
                  fgrd = new Color(  255 - FCInfo.getFGColor().getRed(),
                                            255 - FCInfo.getFGColor().getGreen(),
                                            255 - FCInfo.getFGColor().getBlue()); //FCInfo.getFGColor();
                  fnt = FCInfo.getFont();
                  doBlinkCurrentRow = FCInfo.getDoBlink();
    else
      // Adjust for columns moving around
      column = table.convertColumnIndexToModel(column);
      // Get the colors from the provider
      FontColorInfo FCInfo = ColorProvider.getFontColorInfo(row, column); //doesnt depend upon col yet
      if (FCInfo != null) {
        fgrd = FCInfo.getFGColor();
        bgrd = FCInfo.getBGColor();
        fnt = FCInfo.getFont();
        doBlinkCurrentRow = FCInfo.getDoBlink();
    Component c = //super.getTableCellRendererComponent(table, value, isSelected,hasFocus, row, column);
        delegate.getTableCellRendererComponent(table, value, isSelected,
                                               hasFocus, row, column);
    /////////   for Column Header
    if (row < 0) {
      c.setBackground(table.getBackground());
      c.setForeground(table.getForeground());
      c.setFont(table.getFont());
    else { // Set the component colours of body cells from configurations
      if (bgrd != null && fgrd != null) {
        if (blnBlink && doBlinkCurrentRow && blnSwap) {
          c.setForeground(bgrd);
          c.setBackground(fgrd);
        else {
          c.setBackground(bgrd);
          c.setForeground(fgrd);
      if (bgrd == null && fgrd == null) { //empty rows
        c.setBackground(ColorProvider.getDefaultBackGroundColor());
        c.setForeground(ColorProvider.getDefaultForeGroundColor());
      if (fnt != null) {
        c.setFont(fnt);
    JLabel jCellVal = (JLabel) c; //as cells are JLabels
    if (value instanceof CellInfo) {
      jCellVal.setText( ( (CellInfo) value).text);
      jCellVal.setIcon( ( (CellInfo) value).icon);
    else {
      jCellVal.setText( (value == null) ? "" : value.toString());
      jCellVal.setIcon(null);
    if(row < 0) //headers
      jCellVal.setHorizontalAlignment(JLabel.CENTER);
    else
      jCellVal.setHorizontalAlignment(JLabel.LEFT);
    return c;
  catch(Exception ex)
  return null;
}

What I was pointing you is that the tutorial and also API explains tha the JTable uses only a single renderer instance, at the first level rendering table data, to render all cells of the table.
>
public class DefaultTableCellRenderer (implementation note)
The table class defines a single cell renderer and uses it as a as a rubber-stamp for rendering all cells in the table;
>
So be careful with your DefaultTableCellRenderer variable values which can (when erroneous algo) keep value of a previous rendered cell.
- doBlinkCurrentRow
- blnBlink
- blnSwap
Why this code ???
                 if (blnBlink && doBlinkCurrentRow && blnSwap) {
                   c.setForeground(bgrd);
                   c.setBackground(fgrd);
                 else {
                   c.setBackground(bgrd);
                   c.setForeground(fgrd);
To discover the bad line in you code, go step by step to identify the bad code in your rendering algo.

Similar Messages

  • My screen get white with horizontal lines

    Hello,
    I have an Ibook G3; I bought it in october 2002 in France. A fiew days ago, I took it with me to school, and there all of a sudden the whole screen was white, with many horizontal lines. The system was not responding anymore. But after that, it worked fine again. It happens now more often. I don't know if it's worth to repair, since I don't have any warranty anymore. What could the problem be?
    Thanks.

    Hi, and welcome to Apple Discussions.
    It sounds like you may be having logic board problems. Enough dual USB G3 iBooks suffered from this problem that Apple began the iBook Logic Board Repair Extension Program in January of 2004. Check out the FAQ page and if the symptoms look familiar, give Apple a call. If your iBook qualifies, it's a free fix.
    If you are past the three-year time limit, ask to speak to Customer Relations and ask them to please make an exception to the three-year limit in your case.
    Good luck!

  • New Rows in WAD with Free text characteristic

    I have created an input ready query and one of the characteristic (based on InfoObject 0POSTXT) created is to enter a free text for the given row.  In row selection there are also few more characteristics with master data already created.
    If I use BEx I am in position to enter free text and choose relevant master data for remaining characteristic and plan for my key figures, Works perfectly fine.
    I have now created a new WAD template assigning the input ready query and when I execute the same I am not in position to enter the free text for my text characteristic.  In WAD Application I am forced to choose the value from the available F4 help otherwise I get the invalid value error.  So BEx works fine but not the WAD.
    Any ideas what piece of configuration I am missing?  Any help is highly appreciated.  I have already selected Key (in value Display), in access type of value selection I tried all options with no luck.
    Regards,
    Sachin

    Hello Sachin,
    enter values for characteristics without master data table is only possible in BEx Analyzer.
    Also in BI Planning Functions one can create values for characteristics without master data table.
    For the BEx Web Analyzer this is not implemented; this feature is on the list of possible further developments. It not yet clear whether and when features from the this list will be developed.
    Regards,
    Marc
    SAP NetWeaver RIG

  • How do i change the background display to white with black text. It is white text on blackbackground right now

    Why is my screen display black background with white text?  How can i change back to black text on white background?

    Change it in Settings > General > Accessibility.

  • Table row height expansion with rotated text

    I am using InDesign CS 4 on a Windows XP Home Edition computer. I am transcribing Gregorian chant using an opentype chant font (http://www.marello.org/projects/caeciliae). I have set up a table which is rotated 90 degrees counter clockwise so that the text and music notation appear in separate columns with each syllable of the chant having its own row. The text and music are rotated 90 degrees clockwise by cell style so that they appear normally on the page.
    Everything I have described so well has worked out very well. One inconvenient thing, however, is that when the text is rotated in the way I describe the rows do not automatically expand, even though I have them set to a minimum height lower than the actual height. When I have the text un-rotated, the rows do automatically expand. Can anyone tell me if I am doing something wrong?

    It's an exceptionally convoluted process that looks something like this:
    NSTextStorage *textStorage = [[NSTextStorage alloc] initWithString: title];
    NSTextContainer *textContainer = [[NSTextContainer alloc] initWithContainerSize: NSMakeSize(FLT_MAX, FLT_MAX)];
    NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
    NSFont *menuFont = [NSFont menuFontOfSize: [NSFont systemFontSize]];
    NSRect stringRect;
    [layoutManager addTextContainer: textContainer];
    [textStorage addLayoutManager: layoutManager];
    [textStorage addAttribute: NSFontAttributeName value: menuFont range: NSMakeRange(0, [textStorage length])];
    [textContainer setLineFragmentPadding: 0.0];
    [layoutManager glyphRangeForTextContainer: textContainer];
    stringRect = [layoutManager usedRectForTextContainer: textContainer];
    You'll probably want to use a different font and a more reasonable size for the text container.

  • JTable - row selection not working + change the text format

    Hi All,
    I have written a code to display Jtable with 2 columns, 1 column to display image+text and other is multiline.
    I have used 2 different cell renderer for achiveing the same.
    Please advice on the following:
    @ When I click on row, only one column gets selected. How to fix this?
    @ Data to be displayed in rows is fetched from database. And on some STATUS value row should be in bold text or plain text. I have achieved this but withou logic to iterate over it.
    @ When user right clicks on the row allow them to set text in the row as bold or plain.(Just like we do with mails in outlook box)
    Below is the code:
    Hi All,
    I have written a code to display Jtable with 2 columns, 1 column to display image+text and other is multiline.
    I have used 2 different cell renderer for achiveing the same.
    Please advice on the following:
    @ When I click on row, only one column gets selected. How to fix this?
    @ Data to be displayed in rows is fetched from database. And on some STATUS value row should be in bold text or plain text. I have achieved this but withou logic to iterate over it.
    @ When user right clicks on the row allow them to set text in the row as bold or plain.(Just like we do with mails in outlook box)
    Below is the code:package jtab;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.util.Vector;
    import javax.swing.ImageIcon;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import jtab.TestIcon.iconRenderer;
    public class SampleJtable {
         JFrame frame;
         JTable table;
         JScrollPane panel;
         JPopupMenu popupMenu ;
         public static void main(String[] args) {
              SampleJtable sample = new SampleJtable();
              sample.loadGUI();
         public void loadGUI(){
              frame = new JFrame("Sample Program for Font and ImageIcons");
              frame.setContentPane(panel);
              frame.setSize(550,250);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
         public SampleJtable(){
              BufferedImage images[] = new BufferedImage[1];
              try{
                   images[0] = javax.imageio.ImageIO.read(new File("C:/go.gif"));
              }catch(Exception e){
                   e.printStackTrace();
              final Object data [][] = {{"Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe \n P",new ImageStore(images[0],"Bourquin Rene")},
                        {"Auftrag \n test \n \n 1957,Grenchen Kaufe \n N",new ImageStore(images[0],"Bourquin Rene")}};
              String colIds [] ={"Beschrebung","Von"};
              DefaultTableModel model = new DefaultTableModel(data, colIds) {  
    public Class getColumnClass(int column) {  
    return data[0][column].getClass();
              /*Vector<Object> rowData1 = new Vector(2);
              rowData1.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
              rowData1.add(new ImageStore(images[0],"Bourquin Rene"));
              Vector<Object> rowData2 = new Vector(2);
              rowData2.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
              rowData2.add(new ImageStore(images[0],"Bourquin Rene"));
              Vector<Vector> rowData = new Vector<Vector>();
         rowData.addElement(rowData1);
         rowData.addElement(rowData2);
              Vector<String> columnNames = new Vector<String>();
         columnNames.addElement("Beschrebung");
         columnNames.addElement("Von");     
              DefaultTableModel model = new DefaultTableModel(rowData, columnNames) {  
              table = new JTable(model);
              table.setDefaultRenderer(ImageStore.class, new ImageRenderer());          
              table.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new LineCellRenderer());
              table.setRowHeight(84);
              panel = new JScrollPane(table);
              panel.setOpaque(true);
         class ImageRenderer extends DefaultTableCellRenderer {  
         public Component getTableCellRendererComponent(JTable table,
         Object value,
         boolean isSelected,
         boolean hasFocus,
         int row, int column) {  
         super.getTableCellRendererComponent(table, value, isSelected,
         hasFocus, row, column);
         ImageStore store = (ImageStore)value;
         setIcon(store.getIcon());
         setText(store.text);
         return this;
         class ImageStore {  
         ImageIcon icons;
         String text;
         int showingIndex;
         public ImageStore(BufferedImage image1,String s) {
         icons = new ImageIcon(image1);
         showingIndex = 0;
         text = s;
         public ImageIcon getIcon() {  
         return icons;
         public void toggleIndex() {  
         showingIndex = (showingIndex == 0) ? 1 : 0;
         class LineCellRenderer extends JEditorPane implements TableCellRenderer {
              public LineCellRenderer() {           
              setOpaque(true);
              setContentType("text/html");          
              public Component getTableCellRendererComponent(JTable table, Object value,
              boolean isSelected, boolean hasFocus, int row, int column) {
              //System.out.println("Whats in value = "+ value.toString());
              String [] strArray = value.toString().split("\n");
              String rtStr = null ;
              System.out.println("TYPE+ "+ strArray[strArray.length-1].toString());
              String val = strArray[strArray.length-1].toString().trim();
              if (val.equalsIgnoreCase("N")){
                   System.out.println("TYPE+ IS NEW");
                   rtStr = "<html><head></head><body><b><div style=\"color:#FF0000;font-weight:bold;\">" + strArray[0] + "</div>" +
                             " <div style=\"color:#0000FF;font-weight:bold;\">" + strArray[1] + "</div>" +
                             "<div style=\"color:#0000FF;font-weight:bold;\">" + strArray[2] + "</div>" +
                             "<div style=\"color:#0000FF;font-weight:bold;\">" + strArray[3] + "</div>" +
                             "</b></body></html>";
              else {
                   System.out.println("TYPE+ IS PENDING");
                   rtStr = "<html><head></head><body><div style=\"color:#FF0000;\">" + strArray[0] + "</div>" +
                   " <div style=\"color:#0000FF;\">" + strArray[1] + "</div>" +
                   "<div style=\"color:#0000FF;\">" + strArray[2] + "</div>" +
                   "<div style=\"color:#0000FF;\">" + strArray[3] + "</div>" +
                   "</body></html>";
              setText(rtStr);
              return this;

    Posting code again........
    package jtab;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.util.Vector;
    import javax.swing.ImageIcon;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import jtab.TestIcon.iconRenderer;
    public class SampleJtable {
    JFrame frame;
    JTable table;
    JScrollPane panel;
    JPopupMenu popupMenu ;
    public static void main(String[] args) {
    SampleJtable sample = new SampleJtable();
    sample.loadGUI();
    public void loadGUI(){
    frame = new JFrame("Sample Program for Font and ImageIcons");
    frame.setContentPane(panel);
    frame.setSize(550,250);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    public SampleJtable(){
    BufferedImage images[] = new BufferedImage[1];
    try{
    images[0] = javax.imageio.ImageIO.read(new File("C:/go.gif"));
    }catch(Exception e){
    e.printStackTrace();
    final Object data [][] = {{"Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe \n P",new ImageStore(images[0],"Bourquin Rene")},
    {"Auftrag \n test \n \n 1957,Grenchen Kaufe \n N",new ImageStore(images[0],"Bourquin Rene")}};
    String colIds [] ={"Beschrebung","Von"};
    DefaultTableModel model = new DefaultTableModel(data, colIds) {
    public Class getColumnClass(int column) {
    return data[0][column].getClass();
    /Vector<Object> rowData1 = new Vector(2);
    rowData1.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
    rowData1.add(new ImageStore(images[0],"Bourquin Rene"));
    Vector<Object> rowData2 = new Vector(2);
    rowData2.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
    rowData2.add(new ImageStore(images[0],"Bourquin Rene"));
    Vector<Vector> rowData = new Vector<Vector>();
    rowData.addElement(rowData1);
    rowData.addElement(rowData2);
    Vector<String> columnNames = new Vector<String>();
    columnNames.addElement("Beschrebung");
    columnNames.addElement("Von");
    DefaultTableModel model = new DefaultTableModel(rowData, columnNames) {
    table = new JTable(model);
    table.setDefaultRenderer(ImageStore.class, new ImageRenderer());
    table.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new LineCellRenderer());
    table.setRowHeight(84);
    panel = new JScrollPane(table);
    panel.setOpaque(true);
    class ImageRenderer extends DefaultTableCellRenderer {
    public Component getTableCellRendererComponent(JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected,
    hasFocus, row, column);
    ImageStore store = (ImageStore)value;
    setIcon(store.getIcon());
    setText(store.text);
    return this;
    class ImageStore {
    ImageIcon icons;
    String text;
    int showingIndex;
    public ImageStore(BufferedImage image1,String s) {
    icons = new ImageIcon(image1);
    showingIndex = 0;
    text = s;
    public ImageIcon getIcon() {
    return icons;
    public void toggleIndex() {
    showingIndex = (showingIndex == 0) ? 1 : 0;
    class LineCellRenderer extends JEditorPane implements TableCellRenderer {
    public LineCellRenderer() {
    setOpaque(true);
    setContentType("text/html");
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    //System.out.println("Whats in value = " value.toString());
    String [] strArray = value.toString().split("\n");
    String rtStr = null ;
    System.out.println("TYPE " strArray[strArray.length-1].toString());
    String val = strArray[strArray.length-1].toString().trim();
    if (val.equalsIgnoreCase("N")){
    System.out.println("TYPE IS NEW");
    rtStr = "<html><head></head><body><b><div style=\"color:#FF0000;font-weight:bold;\">" strArray[0] "</div>"
    " <div style=\"color:#0000FF;font-weight:bold;\">" strArray[1] "</div>"
    "<div style=\"color:#0000FF;font-weight:bold;\">" strArray[2] "</div>"
    "<div style=\"color:#0000FF;font-weight:bold;\">" strArray[3] "</div>"
    "</b></body></html>";
    else {
    System.out.println("TYPE+ IS PENDING");
    rtStr = "<html><head></head><body><div style=\"color:#FF0000;\">" strArray[0] "</div>"
    " <div style=\"color:#0000FF;\">" strArray[1] "</div>"
    "<div style=\"color:#0000FF;\">" strArray[2] "</div>"
    "<div style=\"color:#0000FF;\">" strArray[3] "</div>"
    "</body></html>";
    setText(rtStr);
    return this;
    }

  • Getting ClassCastException When Trying To Color JTable Row?

    hi there
    i'm trying to set color for JTable Rows Using the method prepareRenderer
    and get the values of the second column which contains integer values
    and if it contain 0 integer value set the color row as red
    its already works and the row with 0 is set to red but when i try to select any cell in the table
    i'm getting
    java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integerat prepareRenderer
    although the second row which i'm trying to test it's values is Integer not String????????????
    here's the code:
    import javax.swing.border.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.JFrame;
    public class Column_Filter {
      static JTable table;
    static DefaultTableModel dtm;  
        public static void main(String[] args) {
             String[]columns={"Name","Number","Price"};
             Object[][]data={  {"a",new Integer(5),new Integer(200)}
             ,{"b",new Integer(7),new Integer(400)}
             ,{"c",new Integer(0),new Integer(100)}
             ,{"d",new Integer(8),new Integer(800)}
             ,{"e",new Integer(3),new Integer(300)}         
             dtm=new DefaultTableModel(data,columns);
                        table=new JTable(dtm){
                      public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
                             public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                        Component c = super.prepareRenderer(renderer, row, column);
                        if (!c.getBackground().equals(getSelectionBackground()))
                             Integer type = (Integer)getModel().getValueAt(row, 1);
                             if(type!=null)                                                            
                             c.setBackground(type==0 ? Color.RED : Color.WHITE );
                        else
                        c.setBackground(Color.white);
                        return c;
             TableColumnModel columnModel = table.getColumnModel();
             TableColumn col1 = columnModel.getColumn(1);         
             col1.setCellEditor(new TableEditor());
             TableColumn col2 = columnModel.getColumn(2);
             col2.setCellEditor(new TableEditor());
             table.setPreferredScrollableViewportSize(new Dimension(280,160));
             JScrollPane scroll=new JScrollPane(table);
             JLabel label=new JLabel("Column Stuff",JLabel.CENTER);
             JPanel panel=new JPanel();
             panel.add(scroll);
            JFrame frame=new JFrame("Column Stuff");
            frame.add(label,BorderLayout.NORTH);
            frame.add(panel,BorderLayout.CENTER);
            frame.setSize(300,300);
            frame.setResizable(false);
            frame.setVisible(true);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 table=new JTable();     
                   table.setModel(new DefaultTableModel(new Object [][][] {},new String [] {"Name", "Number","Price"}) {
                Class[] types = new Class [] {
                    java.lang.String.class, java.lang.String.class,java.lang.String.class
                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
          class TableEditor extends DefaultCellEditor
              TableEditor()
                   super( new JTextField() );               
                setClickCountToStart(0);
              public boolean stopCellEditing()
                        String editingValue = (String)getCellEditorValue();
                    if(!editingValue.equals("")){
                 try
                int i = Integer.parseInt(editingValue);
                catch(NumberFormatException nfe)
                ((JComponent)getComponent()).setBorder(new LineBorder(Color.red));       
                getComponent().requestFocusInWindow();      
                JOptionPane.showMessageDialog(null,"Data Input Error","Error",JOptionPane.ERROR_MESSAGE);
                return false;          
                    else{                                             
                     getComponent().requestFocusInWindow();
                     fireEditingCanceled();
                     JOptionPane.showMessageDialog(null,"Data Input Error","Error",JOptionPane.ERROR_MESSAGE);
                  return false;              
                   return super.stopCellEditing();
                   public Component getTableCellEditorComponent(
                   JTable table, Object value, boolean isSelected, int row, int column)
                   Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
                   ((JComponent)c).setBorder(new LineBorder(Color.BLACK));
                   return c;
         }

    hi again camickr
    i changed the stopCellEditing as you mentioned
    changed the getCellEditorValue to return an integer
    and give exception and error message if the value can't be converted into integer(non numeric)
    but the problem is when i run the program and change the value in any cell with numeric values
    or with non numeric or not changing the value and press enter
    it give the error message meaning it cannot convert the value to integer
    even if enter an int or don't change the value ????????
    here's what i did
    import javax.swing.border.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.JFrame;
    public class Column_Filter {
      static JTable table;
    static DefaultTableModel dtm;  
        public static void main(String[] args) {
             String[]columns={"Name","Number","Price"};
             Object[][]data={  {"a",new Integer(5),new Integer(200)}
             ,{"b",new Integer(7),new Integer(400)}
             ,{"c",new Integer(0),new Integer(100)}
             ,{"d",new Integer(8),new Integer(800)}
             ,{"e",new Integer(3),new Integer(300)}         
             dtm=new DefaultTableModel(data,columns);
                        table=new JTable(dtm){
                      public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
                             public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                        Component c = super.prepareRenderer(renderer, row, column);
                        if (!c.getBackground().equals(getSelectionBackground()))
                             Integer type = (Integer)getModel().getValueAt(row, 1);                                                            
                             c.setBackground(type==0 ? Color.RED : Color.WHITE );
                        return c;
             TableColumnModel columnModel = table.getColumnModel();
             TableColumn col1 = columnModel.getColumn(1);         
             col1.setCellEditor(new TableEditor());
             TableColumn col2 = columnModel.getColumn(2);
             col2.setCellEditor(new TableEditor());
             table.setPreferredScrollableViewportSize(new Dimension(280,160));
             JScrollPane scroll=new JScrollPane(table);
             JLabel label=new JLabel("Column Stuff",JLabel.CENTER);
             JPanel panel=new JPanel();
             panel.add(scroll);
            JFrame frame=new JFrame("Column Stuff");
            frame.add(label,BorderLayout.NORTH);
            frame.add(panel,BorderLayout.CENTER);
            frame.setSize(300,300);
            frame.setResizable(false);
            frame.setVisible(true);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 table=new JTable();     
                   table.setModel(new DefaultTableModel(new Object [][][] {},new String [] {"Name", "Number","Price"}) {
                Class[] types = new Class [] {
                    java.lang.String.class, java.lang.Integer.class,java.lang.Integer.class
                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
          class TableEditor extends DefaultCellEditor
              TableEditor()
                   super( new JTextField() );               
                setClickCountToStart(0);
              public boolean stopCellEditing()
                   try
                        Integer editingValue = (Integer)getCellEditorValue();
                   catch(ClassCastException exception)
               //when i enter any value in any cell this code is executed even i enter an int or don't change the value
                ((JComponent)getComponent()).setBorder(new LineBorder(Color.red));       
                getComponent().requestFocusInWindow();      
                JOptionPane.showMessageDialog(null,"Data Input Error","Error",JOptionPane.ERROR_MESSAGE);
                return false;
                   return super.stopCellEditing();
                   public Component getTableCellEditorComponent(
                   JTable table, Object value, boolean isSelected, int row, int column)
                   Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
                   ((JComponent)c).setBorder(new LineBorder(Color.BLACK));
                   return c;
         }

  • Photos from the Internet will not load correctly. I get white boxes with blue question marks inside. This has only been happening for the past 3 weeks so I'm not sure why it is happening.

    Photos from the Internet will not load correctly. I get white boxes with blue question marks inside. This has only been happening for the past 3 weeks so I'm not sure why it is happening.

    Yes - email &amp; text work fine but when I use something like Google Images or search a blog with imbedded photos I get the empty white boxes with question marks.  If I click the question mark it opens the photo but I can't possibly do that for EVERY image on EVERY page I search!?!?!  I've rebooted the iPad &amp; my wireless card several times but neither action helped.  Have any clue what I should do now?

  • White space gets introduced in rich text

    Hi,
    We are rendering a form using Output service API. The form contains some fields with Rich text.
    We are able to render rich text on the form but an extra white space gets introduced in the rich text sentences if the text contains Bold, Italics or Underlined letters without any space.
    If either of the two formatting (Bold, Italics, Underline) is done to the letters of a sentence without any space, this problem arises.
    We need to retain the Rich text formatting without any extra space being introduced. The form is a non-interactive form.
    I have attached the screenshot for the same.
    Please suggest a solution.

    Hello,
    Could you please check if "Sticky Footer" is enabled in File>Site properties?
    If yes, does unchecking it helps?
    Regards,
    Sachin

  • How to get exact match when working with Oracle Text?

    Hi,
    I'm running Oracle9i Database R2.
    I would like to know how do I get exact match when working with Oracle Text.
    DROP TABLE T_TEST_1;
    CREATE TABLE T_TEST_1 (text VARCHAR2(30));
    INSERT INTO T_TEST_1 VALUES('Management');
    INSERT INTO T_TEST_1 VALUES('Busines Management Practice');
    INSERT INTO T_TEST_1 VALUES('Human Resource Management');
    COMMIT;
    DROP INDEX T_TEST_1;
    CREATE INDEX T_TEST_1_IDX ON T_TEST_1(text) INDEXTYPE IS CTXSYS.CONTEXT;
    SELECT * FROM T_TEST_1 WHERE CONTAINS(text, 'Management')>0;
    The above query will return 3 rows. How do I make Oracle Text to return me only the first row - which is exact match because sometimes my users need to look for exact match term.
    Please advise.
    Regards,
    Jap.

    But I would like to utilize the Oracle Text index. Don't know your db version, but if you slightly redefine your index you can achieve this (at least on my 11g instance) :
    SQL> create table t_test_1 (text varchar2(30))
      2  /
    Table created.
    SQL> insert into t_test_1 values ('Management')
      2  /
    1 row created.
    SQL> insert into t_test_1 values ('Busines Management Practice')
      2  /
    1 row created.
    SQL> insert into t_test_1 values ('Human Resource Management')
      2  /
    1 row created.
    SQL>
    SQL> create index t_test_1_idx on t_test_1(text) indextype is ctxsys.context filter by text
      2  /
    Index created.
    SQL> set autotrace on explain
    SQL>
    SQL> select text, score (1)
      2    from t_test_1
      3   where contains (text, 'Management and sdata(text="Management")', 1) > 0
      4  /
    TEXT                             SCORE(1)
    Management                              3
    Execution Plan
    Plan hash value: 4163886076
    | Id  | Operation                   | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |              |     1 |    29 |     4   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_TEST_1     |     1 |    29 |     4   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | T_TEST_1_IDX |       |       |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("CTXSYS"."CONTAINS"("TEXT",'Management and
                  sdata(text="Management")',1)>0)
    Note
       - dynamic sampling used for this statementJust read that you indeed mentioned your db version in your first post.
    Not sure though if above method is already available in 9i ...
    Message was edited by:
    michaels

  • Does anyone know how to get a white line across text like the USA basketball logo?

    does anyone know how to get a white line across text like the USA basketball logo?

    Draw the shape which is to be knocked out (a line in the example) in a layer above the logo. The colour doesn't matter because it will be made invisible.
    Double-click in the space to the right of the layer's name in Layers panel to open its Layer Style window where advanced blending can be modified.
    Set Fill Opacity to zero and Knockout to "Deep" or "Shallow" depending on whether the knockout should be limited to a containing Group.

  • How do I get Front Row to work with Lion?

    Hello fellow Mac users,
    How do I get Front Row to work with Lion? I have an iMac 27 inch computer and is the sole entertainment provider for my bedroom. I refuse to put a TV in my room and wanted to know how to get Front Row to work again on my mac? It seems that the upgrade to Lion erased the app.
    I have quite a few movies and series that I bought off iTunes and is a shame that I can't use a media center app like Front Row on Lion.

    I kind of have the opposite problem. I need to know how to turn off my remote on the computer. I am using the remote for my Apple TV and it keeps making the volume on my Computer go up and down (with annoying sounds).
    There used to be a way to un-sync the remote with the comp but I cannot remember how and the Apple help is not much help! I have Lion.
    Thanks!
    Best,
    Tony

  • When I went to turn the desktop on, the start up sound came on.  Then the screen was white with an icon flashing. The icon is a file folder with a question mark on it.  I cannot get it to fully turn on.  HELP

    When I went to turn the desktop on, the start up sound came on.  Then the screen was white with an icon flashing. The icon is a file folder with a question mark on it.  I cannot get it to fully turn on.  HELP

    Run a disk repair tool on the hard disk or install a new OS.
    (59898)

  • Ipad screen is white. Restored it on iTunes. Press home and on switch goes black then back to white with no logo at all. Can't get past the white screen. This happened after running app updates. 16GB OS 7.1.1

    The ipad screen is white. Holding buttons didn't work so I restored it on iTunes. When I press home and on switch, the screen is white,  goes black then back to white with no logo at all. Can't get past the white screen. This happened after running app updates. Is there any fix besides going to Apple store? In iTunes on computer can see what is on there. 16GB OS 7.1.1

    FORCE IPAD INTO RECOVERY MODE
    1. Turn off iPad
    2. Turn on computer and launch iTunes (make sure you have the latest version of iTune)
    3. Plug USB cable into computer's USB port
    4. Hold Home button down and plug the other end of cable into docking port.
    DO NOT RELEASE BUTTON until you see picture of iTunes and plug
    5. Release Home button.
    ON COMPUTER
    6. iTunes has detected iPad in recovery mode. You must restore this iPad before it can be used with iTunes.
    7. Select "Restore iPad"...
    Note:
    1. Data will be lost if you do not have backup
    2. You must follow step 1 to step 4 VERY CLOSELY.
    3. Repeat the process if necessary.

  • I can not get into the iTunes store for the past two days.  I can do a search on the music in upper right corner.  However, the screen is white with "iTunes" in the middle when I do. Any suggestions?  Thank you.

    I can not get into the iTunes store for the past two days.  I can do a search on the music in upper right corner and get a drop down list.  However, the screen is then white with "iTunes" in the middle. Any suggestions?  Thank you.

    Check out this Apple article -> iTunes 10.5 for Windows: May see performance issues and blank iTunes Store
    If your computer has one of the LSPs listed you may have to reset winsock.
    If not, you may want to give this article a shot -> iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues

Maybe you are looking for

  • Itunes 10.5 Home share not working

    I recently updated to itunes 10.5, and now my home share doesn't work.  I can get a song to play from my computer on the tv, but not a video, and I can't access any of my media on the apple tv.  Windows 7 and apple TV 2.  It was working fine prior to

  • What's wrong about  "JSF that emits Ajax-widgets" on the server side?

    Hi, I just read this chat about Ajax on the server side and I wonder what this comment bellow means when we are building JSF application with Ajax: Another thing to consider is that in a pure Ajax application (i.e. one that's not a hybrid of a server

  • New Features for the Zen Mic

    So I have been buzzing around this board for the last week or so, reading up on my new Micro. And now that I have figured everything out and gotten the player to work with WMP0 properly (knock on wood) there are a few things that I would suggest to t

  • The battery of my hp compaq presario needs to be replace,where can i buy it and how much?thanks,..

    the battery of my hp compaq presario needs to be replace,where can i buy it and how much?thanks,..

  • SMTP Mail Adapter settings

    Hi Experts,   I have small doubt regarding SMTP Mail Adapter settings. Right now i am sending files in attachment to the Users through SMTP. But  now User needs in MIME type for which i can see settings in Security Parameter. I can see is S/MIME, whe