Set row height in JTable
i would like to hide, show row/s in the JTable. I try it with setRowHeight but it affect all rows.
is it possible to do it ? what shoud i rewrite(add) to create this functionality?
i use JDK1.2.2 :-(
thanks Tomas
The other way is to modify your table model class:
Let the getValueAt method return only the rows you need and the getRowsCount method return the needed row count.
It may be done in respect to some condition of the table
Best regards,
Martin
Similar Messages
-
How to set row height for each row
Hi
i am trying to set rowheight of row in a JTable using setRowHeight(row,rowheight)
it is not affecting on Table.but if i use setRowheight(rowheight) it applying
entire table ,please help me to solve this problem
after setRowHeight(row,rowheight), i am calling firechanged() method also ,i t will not affecting please hemp me
how to set row height at runtime in a JTableOk fine... do one thing... post ur code here let me check and tell u....
Ciya..... -
I am trying to display some rows in a JTable in a different color regardless of selection status. The row color criteria would be from data from the object in the row, i.e., given a certain status of a record, I would want to show it as red instead of black.
A few optimizations:
class StatusColorRenderer
extends DefaultTableCellRenderer
public StatusColorRenderer()
// super(); not needed, call by default
setOpaque(true);
// DefaultTableCellRenderer returns itself as a CellRenderer Component, it extends JLabel so you can call setOpaque on it
// since this method is called at every paint for every cell it should be HIGHLY optimized
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
Component c = super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column);
MyObjectClass myObject = ( MyObjectClass ) myTableModel.getMyVector().elementAt(row);
<SomeClass> myStatus = myObject.getTheStatus();
if ( myStatus.compareTo(Status.BAD_STAT) == 0)
c.setForeground(Color.red);
else if (myStatus.compareTo(Status.IN_PROGRESS) == 0)
c.setForeground(Color.green);
else if ( myObject.getOtherFactor().compareTo(OtherFactors.NOT_DEFAULT) == 0)
c.setForeground(Color.blue);
else
c.setForeground(Color.black);
// c.repaint(); NEVER DO THAT
return c;
StatusColorRenderer myRenderer = new StatusColorRenderer();
// only one instance of the renderer
for ( int i = myTableModel.getColumnCount() - 1 ; i >= 0 ; i-- )
//column = myTable.getColumnModel().getColumn( i );
myTable.setDefaultRenderer( myTable.getColumnClass( i ),
myRenderer );
}Comment:
AbstractTableModel and DefaultTableModel.getColumnClass method returns Object.class, it is used by the JTable to setup the editor and the renderer of a column
so if you're using the DefaultTableModel and JTable without overriden getColumnClass, you can set a generic renderer for your JTable by using:
myTable.setDefaultRenderer( Object.class, myRenderer ); -
Set row height and column witdh in Report Designer
All,
Is there any way to enter value of a row height or a column width by numbers, instead of dragging them, which I find stupid, especially if several rows should have same height (or several columns same width). I looked for something like Properties-Size/Width/Height but didn't find any. Did I miss anything?
Cheers!
/RBFor those who come from other programming language specially web development, designer or Analyzer looks stupid, but it is very powerful tool. If you need to manage the width and height, then please explore the options in Table Interfaces, there you will be able to use your programming skills.
thanks.
Wond -
Adjusting row height in JTable
hi:
i think i have a tricky one.. i have a Jtable where the cell renderers extend JTextArea. I set the column width, but because the cells can contain any amount of text, i have to adjust each row width to accomodate the text. i used the FontMetrics methods like stringWidth or getStringBounds to get the width of the string and then divide it by the column width to know how many rows this particualar cell will span, and it is working to some extent by not very accurately. any idea if this is a correct way to do it??
thanks...not really.. this is already set, but a cell in a JTable doesn't adjust it's rowHeight automatically.. i had to loop thru all of the rows to do that myself.. any other suggestions??
-
How to set row height of the row in the interactive report?
Some of the values in the columns of my interactive report are wrapped up changing the height of the row to 2 or 3 characters.
Is there any way to change it? I would like to have all rows set to 2 characters height.
RobertAdd the following style sheet to the page HTML Header.
<style>
table.apexir_WORKSHEET_DATA td {
height: 2.8em;
</style> -
Setting row count to JTable RunTime
I am creating JTable at RuTime. I want to set the default 1 row for the Table
df = new DefaultTableModel();
jTable1.setModel(df);
//add Columns to Table
for(int i=0; i<chars.size(); i++)
TableColumn col = new TableColumn();
col.setHeaderValue(.....);
col.setPreferredWidth(...);
jTable1.addColumn(col);
jTable1.updateUI();
df.setRowCount(1); //Problematic code . if remove this line everithing works fine
The above code does't work properly(the last line) Nothing displays on the screen and it's seems to doing processing in loop ...
Plese provide the solution I reqires this urgently............what does "Problematic code" mean? Why can't people just post the error messag/exception? do you think we are prophets?
-
Dynamically adjust table row height based on data in column
Hi all,
I'm using JDeveloper 11.1.1.5.0 and have a requirement for a table to adjust the height of its rows depending on the data in the columns. One of the columns in the table is a rich text description field and I have the 'rows' property set to 13. This field could have twenty lines of text/images or just one. The users would like the page to show all twenty lines of text without having to scroll but the table has the same height for all the rows (that I set to 13) and provides a scroll bar when the data exceeds this size. My users do not like to scroll, and want the height of each row to be determined by the data in it. I looked at a few options and also did a search online, but was unable to find anything to fulfill this requirement. Do you know of how I could change the height of each row in the table so that it fits the data that it holds?
I have an example of my table at: <b>Table with Set Row Height</b>
As you see, the picture has to be scrolled so that the whole picture is visible. The user requirement is to adjust the row height to show the full picture. Ideally the next two rows would shrink, but that would be a nice to have.
Thanks in advance for any pointers or help.Hi Frank,
Thank you for replying to my question, I truly appreciate your help.
I tried to use the autoHeightRows to adjust the height of my rows but was unsuccessful. If I understand the autoHeightRows property correctly, this is used for setting the height of the whole table. If this is incorrect and it can be used for setting the height of individual rows in the table, please correct me. I have the 'Rows' property of the richTextEditor set to 13 and this is the height that I would like to make dynamic based on the data.
My users requirement is for the height to be big enough for the data in each row of the table (the table has a description column and the height of each row should be determined by the data contained in it). I updated my <u><b>Screen Shot</b></u> to show the desired layout and what is currently being generated though ADF (http://www.flickr.com/photos/87583386@N05/) .
I have three rows in the example (in actuality these are around 50) and the text in each row can vary. The users would like to see the full text/image in each row without having to scroll each row. Currently my table is within Panel Box, which is inside a PanelGroupLayout-Scroll which is in a PanelStretchLayout. I tried to put the table by itself with the autoHeightRow modifications you suggested but thsi did not help either. I am using JDeveloper 11.1.1.6.
Is this possible with an ADF Table? If it is, is the autoHeight property the only one that I am setting incorrectly? If not, is there another component I can use to get the desired functionality? My users are very strict about this requirement and will not accept the application without this.
Thanks, -
How to set the row height in a JTable
Is there a way to set the height of a row (actually all rows) in a JTable?
I have tried setting the font to be bigger but then the cells are not big enough.Use "rowHeight" method of JTable class.
For more information about JTable class, please read the API documentation at http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTable.html
/Sreenivasa Kumar Majji.
Is there a way to set the height of a row (actually
all rows) in a JTable?
I have tried setting the font to be bigger but then
the cells are not big enough. -
Hi,
1. Can we adjust variable row height for each row,
2. Also as we adjust the column widht, can we adjust the row height by dragging,
3.Suppose i have JTextArea as a cell renderer , how can i display all the text in a row with out having to use a scroll bar,
AshishThat's a lot of questions..... but here are your answers:
1. Can we adjust variable row height for each row,Yes, use JTable's setRowHeight method to set the height of each row.
2. Also as we adjust the column widht, can we adjust the row height by dragging,You should be able to adjust the column width by clicking the mouse on the edge of the column header and drag. There is no automatic provision for changing the row height that way -- you'll have to add a mouse listener to the rowheader and write your own code to perform the resizing.
3.Suppose i have JTextArea as a cell renderer , how can i display all the text in a row with out having to use a scroll bar, You'll have to figure out how many rows (based on the sum of the individual row's height) the textarea occupies (taking into consideration the font that you used to render the textarea). I have my own way of doing things but if you search this forum, you'll find a lot of discussion on how to do it.
;o)
V.V. -
JTable and adjusting Row height
Hi,
How to make a row height adjustable, like user can click on the row and drap to increase the height of the row,
Also if i have JTextArea as cell rendere how do i dynamically adjust the row height to display all the text
AshishThat's a lot of questions..... but here are your answers:
1. Can we adjust variable row height for each row,Yes, use JTable's setRowHeight method to set the height of each row.
2. Also as we adjust the column widht, can we adjust the row height by dragging,You should be able to adjust the column width by clicking the mouse on the edge of the column header and drag. There is no automatic provision for changing the row height that way -- you'll have to add a mouse listener to the rowheader and write your own code to perform the resizing.
3.Suppose i have JTextArea as a cell renderer , how can i display all the text in a row with out having to use a scroll bar, You'll have to figure out how many rows (based on the sum of the individual row's height) the textarea occupies (taking into consideration the font that you used to render the textarea). I have my own way of doing things but if you search this forum, you'll find a lot of discussion on how to do it.
;o)
V.V. -
How do you set the font color for a specific entire row inside a JTable?
How do you set the font color for a specific entire row inside a JTable?
I want to change the font color for only a couple of rows inside a JTable.
I've seen some ways to possibly do this with an individual cell.
Clarification on changing the font color in an individual cell would be helpful too if
there is no easy way to do this for a row.hai,
Try out with this piece of code.Create your table and assign the renderer to each column in the table.
CellColorRenderer m_CellColorRenderer = new CellColorRenderer();
for(int i=0;i<your_JTable.getColumnCount();i++)
your_JTable.getColumnModel().getColumn(i).setCellRenderer(m_CellColorRenderer);
class CellColorRenderer extends JLabel implements TableCellRenderer
CellColorRenderer()
setOpaque(true);
setHorizontalAlignment(LEFT);
setVerticalAlignment(CENTER);
setBackground(Color.white);
setForeground(Color.black);
protected void setValue(Object value)
setText((value == null) ? "" : value.toString());
public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected, boolean hasFocus, int row,int column)
if(isSelected == true)
setForeground(Color.red);
else
setForeground(Color.black);
setValue(value);
return this;
regards,
bala -
How to bind JTable row height to the maximum height of a the columns
Suppose i have a JTable. data setup is done. Thing is whenever data font size increases table row height should change. How?
Add a PropertyChangeListener to the table to listen for a font change event. Then use the setRowHeight() method of the table.
-
How to set height of JTable Header ?
How to set height of JTable Header and set the text to another size ?
You can set the font of the header as you can for any component. The font will dictate the preferred height of the header. If you don't like the preferred height, you can set that as well.
// add table to a scroll pane or the header will not appear
JTable table = new JTable(...);
container.add(new JScrollPane(table));
// get a reference to the header, set the font
JTableHeader header = table.getTableHeader();
header.setFont(new Font(...));
// set the preferred height of the header to 50 pixels.
// the width is ignored by the scroll pane.
header.setPreferredSize(new Dimension(1, 50));Mitch Goldstein
Author, Hardcore JFC (Cambridge Univ Press)
[email protected] -
How to set an Excel row height to 0
Using the Office Web API how would one set an Excel row height to 0 or other number?
I would think this is possible since I am able to narrow the row height using a mouse in the same way one does on the Excel client.Hi JimBassett,
What do you mean by "Office Web API"? I assume you mean the "JaveScript API for Office". If so, I'm afarid the current Office Javascript API did not provide the method to set the height of a cell.
If this is a feature you want to include in future versions of Office Javascript API, please sbumit a feedback to Office Development Platform Uservoice.
http://officespdev.uservoice.com
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
Maybe you are looking for
-
USB2 doesn't work. Only USB3 work.
Hello, I've a new DELL vostro 3350 with 2 usb2 and one usb3/e-sata connector but only the last seem working, the other 2 port doesn't work like they doesn't exist. i post my dmesg and lsmod output dmesg: [ 0.000000] Initializing cgroup subsys cpuset
-
How to disable the Taskbar in Windows 8.1 completely...??
can any one help me in disabling the taskbar completely in a windows 8.1 tablet.
-
Unable to open up pdf xls file on my computer ? what should I do ?
UNABLE TO OPEN UP PDF XLZ DOWNLOAD ON MY COMPUTER . i CURRERTLY HAVE ADOBE READER. WHAT SHOULD i DO.
-
WAD Report delaying to display output
Hello, WAD report taking 6 min time to display the output but the same report displaying output in 1 min 50 sec when I executed in BEx Analyzer The Same BEx report I incorporated in WAD but it's delaying to display the output. What might be the caus
-
Hi Tim, I am using SP5 not SP4, and workflow also enters in received mode after launched. But after that it goes to TRASH, and this behaviour only comes when i add some new fields to main table. is this the only reason for trash sta