Does JIDE provide a JTable like component?

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Does JIDE provide a JTable like component?

Postby rohan26may » Wed Oct 01, 2008 12:10 am

I need a fancy looking JTable component. Does Jide provide such component or a remedy so that I can make my JTable look Fancy?
Attached JTable.bmp is how my JTable looks currently and row.bmp is how I want my JTable rows to look like so that It's better readable to the customer.

Can you please suggest me a solution?
rohan26may
 
Posts: 6
Joined: Thu Sep 25, 2008 1:51 am

Re: Does JIDE provide a JTable like component?

Postby JIDE Support » Wed Oct 01, 2008 6:37 am

The row.bmp file doesn't come through. Could you try to attach it again?

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37263
Joined: Sun Sep 14, 2003 10:49 am

Re: Does JIDE provide a JTable like component?

Postby rohan26may » Thu Oct 02, 2008 8:34 pm

I have attached the files again. Please find them.
Attachments
row.jpg
This is how I want my JTable's rows/cells to look like (i.e. with shaded colors)
row.jpg (4.9 KiB) Viewed 28541 times
JTable.JPG
This is how my JTable looks like.
JTable.JPG (58.32 KiB) Viewed 28543 times
rohan26may
 
Posts: 6
Joined: Thu Sep 25, 2008 1:51 am

Re: Does JIDE provide a JTable like component?

Postby JIDE Support » Thu Oct 02, 2008 10:52 pm

You can pretty much do all those using CellStyle feature provided in JIDE Grids. Please refer to demos and developer guide for more information.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37263
Joined: Sun Sep 14, 2003 10:49 am

Re: Does JIDE provide a JTable like component?

Postby rohan26may » Sun Oct 05, 2008 9:23 pm

Hey,
Thanks a lot for help.
Please tell me one thing. I saw the shaded CellStyles. But I want to confirm from you that can we have shaded colors of my own choice or there are limitations (like only few styles)??

If I can use colors of my choice then I'm interested in buying your product. :)

Regards,
Rohan
rohan26may
 
Posts: 6
Joined: Thu Sep 25, 2008 1:51 am

Re: Does JIDE provide a JTable like component?

Postby JIDE Support » Sun Oct 05, 2008 10:25 pm

Please refer to GradientStyleTableDemo.java under examples\G17. StyleTable. It has the complete source code to show you how to do it (by extending cell style feature). You have complete control over the colors. Note this demo shows how to use a gradient. If you just need a plain color, CellStyle has that supported already so you don't need to extend CellStyle as GradientStyleTableDemo did.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37263
Joined: Sun Sep 14, 2003 10:49 am

Re: Does JIDE provide a JTable like component?

Postby rohan26may » Sun Oct 05, 2008 11:06 pm

Hi,

I need to demo the cellstyle effects to my client before I purchase the product. So can you somehow give me some limited jars required for this feature so that I can build a POC for the same and demo it to the client?

If you can't, please sugget me any other alternative.

Regards,
Rohan
rohan26may
 
Posts: 6
Joined: Thu Sep 25, 2008 1:51 am

Re: Does JIDE provide a JTable like component?

Postby JIDE Support » Sun Oct 05, 2008 11:08 pm

Do you know we have full functioned eval package that you can download and build your demo?

viewtopic.php?f=5&t=10

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37263
Joined: Sun Sep 14, 2003 10:49 am

Re: Does JIDE provide a JTable like component?

Postby rohan26may » Mon Oct 06, 2008 4:27 am

Hi,

I tried referring GradientStyleTableDemo.java file but I couldn't successfully create the table that I wanted.
Please see attached. That is what I want to achieve. Can you please shed some light on how can I get only that. (Possibly provide me the exact code :) )
The file has lot of code that I dont understand what its doing. Kindly assist.

Regards.
Attachments
1.JPG
1.JPG (10.81 KiB) Viewed 28509 times
rohan26may
 
Posts: 6
Joined: Thu Sep 25, 2008 1:51 am

Re: Does JIDE provide a JTable like component?

Postby rohan26may » Mon Oct 06, 2008 4:54 am

I tried following program, but the cells are not getting colored...


import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.TableCellRenderer;

import com.jidesoft.grid.AbstractStyleTableModel;
import com.jidesoft.grid.CellStyle;
import com.jidesoft.grid.CellStyleTable;
import com.jidesoft.grid.RendererWrapper;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.swing.JideSwingUtilities;


/**
* @version 1.0 12/25/98
*/

public class JideTableExample extends JFrame {

/**
*
*/
private static final long serialVersionUID = -6984627985903179581L;


public static class GradientCellStyle extends CellStyle {
private Color _startColor;
private Color _endColor;
private boolean _isVertical = true;

public Color getStartColor() {
return _startColor;
}

public void setStartColor(Color startColor) {
_startColor = startColor;
}

public Color getEndColor() {
return _endColor;
}

public void setEndColor(Color endColor) {
_endColor = endColor;
}

public boolean isVertical() {
return _isVertical;
}

public void setVertical(boolean vertical) {
_isVertical = vertical;
}
}


public static class GradientLabel extends JLabel {
/**
*
*/
private static final long serialVersionUID = -5317280973961718687L;
private Color _startColor;
private Color _endColor;
private boolean _isVertical = true;

public GradientLabel() {
}

public GradientLabel(Icon image) {
super(image);
}

public GradientLabel(Icon image, int horizontalAlignment) {
super(image, horizontalAlignment);
}

public GradientLabel(String text) {
super(text);
}

public GradientLabel(String text, int horizontalAlignment) {
super(text, horizontalAlignment);
}

public GradientLabel(String text, Icon icon, int horizontalAlignment) {
super(text, icon, horizontalAlignment);
}

public Color getStartColor() {
return _startColor;
}

public void setStartColor(Color startColor) {
_startColor = startColor;
}

public Color getEndColor() {
return _endColor;
}

public void setEndColor(Color endColor) {
_endColor = endColor;
}

public boolean isVertical() {
return _isVertical;
}

public void setVertical(boolean vertical) {
_isVertical = vertical;
}

@Override
protected void paintComponent(Graphics g) {
if (getStartColor() != null && getEndColor() != null) {
JideSwingUtilities.fillGradient((Graphics2D) g, new Rectangle(0, 0, getWidth(), getHeight()), getStartColor(), getEndColor(), isVertical());
}
super.paintComponent(g);
}
}


final String SEPARATOR = "SEPARATOR";

public JideTableExample() {
super("Block ComboBox Example");




StyleTableTableModel _tableModel = new StyleTableTableModel();
CellStyleTable _table = new CellStyleTable(_tableModel) {
/**
*
*/
private static final long serialVersionUID = -3215234241347396496L;
private Color _saveStartColor;
private Color _saveEndColor;

//@Override
protected void customizeRendererComponent(int row, int column, Component component, CellStyle cellStyle) {
super.customizeRendererComponent(row, column, component, cellStyle);

Component rendererComponent = component;
//boolean isRendererWrapper = false;
if (rendererComponent instanceof RendererWrapper) {
rendererComponent = ((RendererWrapper) rendererComponent).getActualRenderer();
if (rendererComponent != null) {
//isRendererWrapper = true;
}
else {
rendererComponent = component;
}
}

if (rendererComponent instanceof GradientLabel && cellStyle instanceof GradientCellStyle) {
if (((GradientCellStyle) cellStyle).getStartColor() != null) {
if (_saveStartColor == null) {
_saveStartColor = ((GradientLabel) rendererComponent).getStartColor();
}
((GradientLabel) rendererComponent).setStartColor(((GradientCellStyle) cellStyle).getStartColor());
}
if (((GradientCellStyle) cellStyle).getEndColor() != null) {
if (_saveEndColor == null) {
_saveEndColor = ((GradientLabel) rendererComponent).getEndColor();
}
((GradientLabel) rendererComponent).setEndColor(((GradientCellStyle) cellStyle).getEndColor());
}
((GradientLabel) rendererComponent).setVertical(((GradientCellStyle) cellStyle).isVertical());
}
}

@Override
public void releaseRendererComponent(TableCellRenderer renderer, int row, int column, Component component) {
super.releaseRendererComponent(renderer, row, column, component);

Component rendererComponent = component;
//boolean isRendererWrapper = false;
if (rendererComponent instanceof RendererWrapper) {
rendererComponent = ((RendererWrapper) rendererComponent).getActualRenderer();
if (rendererComponent != null) {
//isRendererWrapper = true;
}
else {
rendererComponent = component;
}
}

if (rendererComponent instanceof GradientLabel) {
((GradientLabel) rendererComponent).setStartColor(_saveStartColor);
_saveStartColor = null;
((GradientLabel) rendererComponent).setEndColor(_saveEndColor);
_saveEndColor = null;
((GradientLabel) rendererComponent).setVertical(true);
}
}
};

getContentPane().setLayout(new FlowLayout());
getContentPane().add(_table);

setSize(400, 400);
setLocation(100, 100);
setVisible(true);
}

public JideTableExample(Color color) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {/*
super("Block ComboBox Example");


JideButton button = new JideButton("Do Nothing!");


button.setOpaque(true);
button.setBackground(color);
//button.setContentAreaFilled(true);
//button.setRequestFocusEnabled(false);
//button.setFocusable(false);

JTable table = new JTable(3,3);
TableColumn column = new TableColumn();
table.addColumn(column);



getContentPane().setLayout(new FlowLayout());
getContentPane().add(button);
getContentPane().add(table);

setSize(300, 100);

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
setVisible(true);
*/}


public static void main(String args[]) {
LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
//LookAndFeelFactory.installJideExtension(LookAndFeelFactory.ECLIPSE3X_STYLE);
//LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);
//LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2003_STYLE);
JideTableExample frame = new JideTableExample();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}


class StyleTableTableModel extends AbstractStyleTableModel {
/**
*
*/
private static final long serialVersionUID = 5969297678460142483L;
protected final Color BACKGROUND1 = new Color(253, 253, 244);
protected final Color BACKGROUND2 = new Color(150, 230, 255);
protected final Color BACKGROUND3 = new Color(210, 255, 150);

public int getRowCount() {
return 5;
}

public int getColumnCount() {
return 5;
}

@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}

public Object getValueAt(int rowIndex, int columnIndex) {
return "" + rowIndex + "," + columnIndex;
}

GradientCellStyle _cellStyle = new GradientCellStyle();
private int _pattern = 0;

@Override
public CellStyle getCellStyleAt(int row, int column) {
_cellStyle.setHorizontalAlignment(SwingConstants.CENTER);
_cellStyle.setIcon(null);
if (_pattern == 0) {
if (row % 2 == 0) {
_cellStyle.setStartColor(BACKGROUND1);
_cellStyle.setEndColor(BACKGROUND2);
}
else {
_cellStyle.setStartColor(Color.pink);
_cellStyle.setEndColor(Color.pink);
}
}
else if (_pattern == 1) {
if (row % 3 == 0) {
_cellStyle.setStartColor(BACKGROUND1);
_cellStyle.setEndColor(BACKGROUND2);
}
else if (row % 3 == 1) {
_cellStyle.setStartColor(BACKGROUND2);
_cellStyle.setEndColor(BACKGROUND3);
}
else {
_cellStyle.setStartColor(null);
_cellStyle.setEndColor(null);
}
}
else if (_pattern == 2) {
if (column % 2 == 0) {
_cellStyle.setStartColor(BACKGROUND1);
_cellStyle.setEndColor(BACKGROUND2);
_cellStyle.setVertical(false);
}
else {
_cellStyle.setStartColor(null);
_cellStyle.setEndColor(null);
_cellStyle.setVertical(true);
}
}
else {
if (row % 2 == column % 2) {
_cellStyle.setStartColor(BACKGROUND1);
_cellStyle.setEndColor(BACKGROUND2);
}
else {
_cellStyle.setStartColor(null);
_cellStyle.setEndColor(null);
}
}
return _cellStyle;
}


@Override
public boolean isCellStyleOn() {
return _pattern != 4;
}



}
}
rohan26may
 
Posts: 6
Joined: Thu Sep 25, 2008 1:51 am

Re: Does JIDE provide a JTable like component?

Postby JIDE Support » Mon Oct 06, 2008 7:00 am

We have radio button to change the _pattern field to different values. But in your code, it is always 0.That's the reason not working. Note isCellStyleEnabled method. It always return false in your code. You can manually change the _pattern value to 0 to 4 and then compile and run to see the difference.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37263
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 7 guests