DefaulTableModel row headers
hi All,
URGENT REQUIREMENT PLEASE HELP ME
I have a table of type DefaultTableModel .The table has rowheaders and columnheaders which are dynamically generated from the DB.
On action i want to add/remove a rowheader which should be update the rowheaders in the UI without affecting the table.
Thanks in advance
FullofJAva
I have a JTable of DefaultTableModel and this table is having rowheaders and columnheaders and they will be created dynamically using the data from DB and i have a checkbox and on selection of the checkbox iam deleting 2rows from the table but i am not able to remove the rowheaders??? So in this regard i need some help
Similar Messages
-
Add JTable Row Headers At The End Of The Rows(At Right)?
hi all
i got this example for adding JTable Row Headers,but it adds the headers at the left(beginning of the row)
and i want to add the headers at the end of the row(at right),any ideas how to do that?
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.AbstractListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
* @version 1.0 11/09/98
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
RowHeaderRenderer(JTable table) {
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
setText((value == null) ? "" : value.toString());
return this;
class RowHeaderExample extends JFrame {
public RowHeaderExample() {
super("Row Header Example");
setSize(370, 150);
ListModel lm = new AbstractListModel() {
String headers[] = { "Row1", "Row2", "Row3", "Row4"};
public int getSize() {
return headers.length;
public Object getElementAt(int index) {
return headers[index];
DefaultTableModel dm = new DefaultTableModel(lm.getSize(), 4);
JTable table = new JTable(dm);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setRowHeight(18);
JList rowHeader = new JList(lm);
rowHeader.setFixedCellWidth(50);
rowHeader.setFixedCellHeight(18);
rowHeader.setCellRenderer(new RowHeaderRenderer(table));
JScrollPane scroll = new JScrollPane(table);
scroll.setRowHeaderView(rowHeader);
getContentPane().add(scroll, BorderLayout.CENTER);
public static void main(String[] args) {
RowHeaderExample frame = new RowHeaderExample();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.setVisible(true);
}fixed by:
list.setBackground(table.getTableHeader().getBackground());here's the full code:
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
* @version 1.0 11/09/98
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
JTable table;
RowHeaderRenderer(JTable table) {
this.table = table;
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
list.setBackground(table.getTableHeader().getBackground());
setText((value == null) ? "" : value.toString());
return this;
class RowHeaderExample extends JFrame {
public RowHeaderExample() {
super("Row Header Example");
setSize(370, 150);
setLocationRelativeTo(null);
DefaultListModel lstModel = new DefaultListModel();
lstModel.addElement("Row 1");
lstModel.addElement("Row 2");
lstModel.addElement("Row 3");
lstModel.addElement("Row 4");
DefaultTableModel dm = new DefaultTableModel(lstModel.getSize(), 4);
JTable table = new JTable(dm);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setRowHeight(18);
JList rowHeader = new JList(lstModel);
rowHeader.setFixedCellWidth(50);
rowHeader.setFixedCellHeight(18);
rowHeader.setCellRenderer(new RowHeaderRenderer(table));
JScrollPane scroll = new JScrollPane(table);
scroll.setRowHeaderView(rowHeader);
table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
getContentPane().add(scroll, BorderLayout.CENTER);
public static void main(String[] args) {
RowHeaderExample frame = new RowHeaderExample();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.setVisible(true);
} -
How do I get the Layout Guides (A,B,C column headers and 1,2,3 Row Headers) to print on my spreadsheet? They are invaluable for discussing the data with my clients over the phone.
They appear while I am editing, but don't print with the spreadsheet. I know how to do it in Excel, but I am transitioning to Numbers. I can't imagine I have to type them into their own columns and rows. It must be a difference in vernacular that I can't find the solution in the User Guide. Can anyone help?Hi ktjobauer,
Numbers is not Excel and Excel is not Numbers. Numbers is WYSIWYG (at least in File > Print and the actual printout).
I can't imagine I have to type them into their own columns and rows.
No, you don't. You can use the charm of Numbers to create cell references for your Excel clients.
In this Numbers Table, I have added some extra Columns that you can hide later.
Column B =COLUMN(A2)
Column C =HLOOKUP(B2,'Table 1-1' :: $1:$2,2,FALSE) [explanation later]
Column D =ROW(B2)
Column E =C2&D2
Add those formulas to the first Body Row (below the Header Row) and Fill Down.
Column C refers to another Table which you need only create once, to convert a Column number to a letter:
and so on from 1-26, A-Z.
You can move the second Table to another Sheet to hide it. Formulas will automatically adjust to keep the links between Sheets.
Now in the first Table, select and Hide Columns B,C,D. Formulas will continue to work with hidden cells:
Regards,
Ian. -
How to create a datatable with row headers and column headers
Hi,
I am trying to create a two dimensional datatable which has both column headers and row headers. using <h:datatable> i could create a datatable with only column headers.
Thanks in advanceAre you saying that you want a column with only th's? You could also just apply some CSS on that specific column that its rows look like headers.
-
Row Headers in Cross Tab Report -Crystal Report XI
I am trying to create a cross tab report. The report has 4 rows and the columns get generated based on the value of a database field.
I have 2 questions
Question 1 : I want the rows to have headers. I insert text objects in the report and when I run the report in crystal, the headers are displaying as required. But when I export to excel, the headers are displayed after the data. How can I create row headers and get them exported to excel as row headers.
Question 2: I am creating the column based on a database field. The field is of text data type. The sorting for this filed is 1. abc ,10. abc , 11.abc , 2.abc , 3.abc ; etc where abc is a text string. How can I sort the columns so that the columns appear as 1.abc, 2.abc, 3.abc etc.
I tried using the specified order sorting, but when I check the list of values that it creates to select the values, it is truncating the values. I can only see part of the values from the database.
Please Help!!!I don't have Crystal in front of me so I will try to do this from memory. If you right click on a report object, there is option on one of the tabs (I think it is General) that says Display String with a corresponding X button. If you click on that, then you can enter a text expression that overrides the actual value of the report object.
In your case, if you want to add a static header text to the row data, you could try something like the following:
if Gender = "M"
then "Mr. " + CurrentFieldValue
else "Ms. " + CurrentFieldValue
where Gender is a field object in the report and CurrentFieldValue is the data object specified for rows in the cross-tab.
If you wanted to put header on the previous line, you could try something like this:
"Account ID" + chr(13) + CurrentFieldValue
where CurrentFieldValue is the account ID string.
Fuskie
Who expects this looks nothing like your actual report but hopefully it works as an example... -
How can I make the rolumn and row headers appear on the printed sheet?
I am working in Numbers'09. I want to print out my chart with the column letters and row numbers showing.
How can I make the rolumn and row headers appear on the printed sheet?g,
Those annotations are called "Labels", and they are only visible during editing when a cell selection is made within the table. If you need to have the labels on your final output, you can create labels in Text Boxes and position them adjacent to the table.
Jerry -
Row headers string in a multicolumn listbox
Hello!
I'm using multicolumn listbox block and I want to put row headers, but I don't Know how.
I'm using the node property block to put column headers...but I don't find for rows.
Someone knows what I have to do?
Thanks a lot!I don't think there is a row header property like the column header, you can leave the first row blank and white the headers in the first column so simulate it. You can create a simple subvi which takes a reference to the control and a string array and in a for loop set the string value of cell (0, i) to the value of the string[i] array input. As far as I know there is not a row header like there is a column hearer though. This is typical in spreadsheets where the rows are indexed and not named but the columns are.
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA -
I am using the fancy new printing capablities in java 1.5 to print my JTable and wow is it ever slick!
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.LANDSCAPE);
this.matrixJTable.print(JTable.PrintMode.NORMAL, null, null, true, set, false);Its just that easy. Way to go sun!
The one problem that I am encountering is that my row headers don't print. The problem is that JTables don't support row headers, you have to use a JScrollPane for that.
I need a way to print my JTable so that the row headers show up in the printout... and hopefully still use the warm and fuzzy new printing capabilities of JTable printing in java 1.5.
(ps/ Isn't it time to add row header support to JTables?)The problem is that JTables don't support row headers, you have to use a JScrollPane for that.Well technically JTable's don't really support column headers either. It is a seperate component (JTableHeader). A JTable will automatically add its table header to the table header area of a JScrollPane. (but you don't have to use a jscrollpane to see the column headers, it is just the quickest and easiest way).
Really shouldn't be hard to implement a row header and manually add it to the scroll panes row header area or use a BorderLayout and put your row header in the WEST and put your table in the CENTER if you don't want a scroll pane.
Of course this won't help you with your printing issue. -
How to make Column and Row headers bold in Web template?
Hi Experts,
I have a web application with a query in it. Now I would like to know how I could make the column and row headers of this webquery in bold font? I havent found any properties in any web item to make this possible. It looks like the only way to do this is CSS, but i dont have any experience with style sheets.
Are there easier ways to do this?
Thanks in advance.
Rgds,
RichardTried this for fun using JavaScript. It appears to work, but is pretty much a hack, and I didn't test it thoroughly.
Place this in a function that is called during onload of the page:
var eleid='';
for(var ct=0;ct<1000;ct++) {
eleid='ANALYSIS_interactive_mc'+ct+'_tv';
if (document.getElementById(eleid)) {
if(document.getElementById(eleid).parentNode.className=='urLayoutPadless') {
document.getElementById(eleid).style.fontWeight='bold'; -
Is there any way to have run time menu only for the row headers and not the whole of the table?
Thanks,
RiteshEvent Structure -> Mouse Down on Table Event -> Button
Message Edited by Eugen Graf on 09-25-2008 04:52 AM
LabVIEW Portal
Attachments:
Button.png 7 KB -
Forcing data to appear as row headers
How do I force a list of values from the SR Area to appear listed as row headers even if there's no data for that row? I tried writing a code to pick up the SR# for it and assign a null value in the # of SRs column so that it doesn't get counted in the totals. However, this will defy our business process since the report is required weekly and I can't be creating weekly SR's for the sole purpose of creating "dummy" data to force the row headers to show.
So you actually want to outer join the LOV, to the fact table, or not?
In this case I would advise you the following.
Create one request with the actual data of that week, holding only the LOV values that have data.
For example:
LOV Value 1____10
LOV Value 4____12
LOV Value 6____8
In the second request add all the LOV Types and use no fact but a dummy column, holding the formula: CAST(NULL as INT).
LOV Value 1____NULL
LOV Value 2____NULL
LOV Value 3____NULL
LOV Value 4____NULL
LOV Value 5____NULL
LOV Value 6____NULL
Then use a UNION to combine both requests.
Then you should get the following result:
LOV Value 1____10
LOV Value 1____NULL
LOV Value 2____NULL
LOV Value 3____NULL
LOV Value 4____12
LOV Value 4____NULL
LOV Value 5____NULL
LOV Value 6____8
LOV Value 6____NULL
This is still not what you want because you now need to remove the double records.
You can do this by using the pivot table view, which will result in the following table:
LOV Value 1____10
LOV Value 2____NULL
LOV Value 3____NULL
LOV Value 4____12
LOV Value 5____NULL
LOV Value 6____8
Regards,
Stijn -
How to freeze column and row headers of a table
How to freeze column and row headers of a table in jsp and javascript. An example is available in
http://www.massless.org/_tests/grid1/ pls help to find a solutionj
Thanks in anticipation
SreejeshAt least I don't stop you from that. I also don't see any benefits in this topic.
Success. -
Is there a way to create row headers for flex datagrid instead of column header?
No, not really. You can lock the first column so it won't scroll
horizontally -
JTable Multi Level Row Headers
Hi All
does any one know what's the better way to create MultiLevel Row Headers in JTable.
for Ex.
|- Hot
|- Drinks--------|
| |- Cold
Food-------|
| |- Soft
| - Fruits-------|
|- Hard
and it goes on....to the n level.
Is there any predefined classes available in Swing for this functionality.
Thanks in Advance
Kiran.Rwhere did you find this ?
http://www2.gol.com/users/tame/swing/examples/JTableExamples1.html
That has some pretty hardcore examples!
-jonathan -
Suppress Repeating Row Headers in FR
Does anyone know if FR allows for the suppression of repeating row headers much like you can do in IR. Thanks in advance for any assistance.
disregard, I was able to find the suppress repeat row headers in the property pane.
Maybe you are looking for
-
Hi Forum, I have a question concerning LSMW with Creditors. My task is to import Creditor Data from a old system into SAP. Every Creditor hold at least one Bank Account Data ( Bank code number, Country, Bank account number), in some cases a creditor
-
How to call bapi_transaction_commit in my sessionBean when icreated sales o
hi, how to call bapi_transaction_commit when i am creating salesorder by BAPI_SALESORDER_CREATEFROMDAT2. After Callng that bapi i want to commit the transaction For that i want to know how to call Transationbapi
-
Error when i increase the SGA to more that 1GB
I have a server with 8 GB of memory running server 2003. i have 2 instances on the server, everytime i try to increase the SGA for any instance to more than 1GB the instances doesn't restart. the error message is 'Memory realm already exists' among o
-
I upgraded to OS 10.8.5 and i have lost 4 major applications
I just discovered that I no longer have Photoshop, Appleworks, Microsoft Word , Version tracker Pro, Popcorn, and a Bridge game I play all of the time. WHAT IS UP WITH THAT? I have no program to write with anymore, I can't edit my photos, copy DVDs
-
how do I access recorded meetings? when I click on the 'meetings' tab it says I don't have permission