This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes TableRow background color problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "TableRow background color problem" Watch "TableRow background color problem" New topic
Author

TableRow background color problem

Rambo Rambabu
Greenhorn

Joined: Jul 12, 2002
Posts: 21
Hi, we are writting applet based siwng application. Once user logs in using the applet, a separate MainWindow frame is opened with a menu etc, which looks like any regular stand alone application
We are using VAJ 4.0 for developing and deploying in WebSphere4.0. For standalone testing we run the applet by selecting (within VAJ) this applet and Run Main Option. When running in this way every thing looks fine for JTable rows. ie rows have white background color and black text.
When we run the same using the browser which opens up a main window frame, the table rows have gray background.
Can anyone tell how to get white background while running under applet mode also...
I am attaching code snippets I am using for background color...
thanks in advance,
-- rambo
---------
For table: OrderDetailsScrollPaneTable.setBackground(new java.awt.Color(204, 204, 204));

For tablecolumns:
DefaultTableCellRenderer localCellRenderer;
localCellRenderer = new DefaultTableCellRenderer();
localCellRenderer.setName("localCellRenderer");
localCellRenderer.setFont(new Font("sansserif", 0, 12));
localCellRenderer.setBorder(LineBorder.createBlackLineBorder());
localCellRenderer.setBackground(Color.white);
localCellRenderer.setForeground(Color.black);
lastNameTableColumn = new javax.swing.table.TableColumn();
lastNameTableColumn.setCellRenderer(localCellRenderer);
--------------------------------
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
the DefaultCellRenderer is a JLabel which normally it transparent (opaque == false). if you call
renderer.setOpaque(true);
explicitely, the renderer will paint the background.

public void setOpaque(boolean isOpaque)
If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through.
The default value of this property is false for JComponent. However, the default value for this property on most standard JComponent subclasses (such as JButton and JTree) is look-and-feel dependent.

I suppose, VAJ runs you app using another lokk and feel (windows look & feel?), while the browser uses motif.
Chantal
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: TableRow background color problem