Changing JTable column names
I have a JTable where the user can right click on the table header to change what data is displayed. When the user selects different data to display, I would like to change the column name to reflect this. What is the best way to do this?
TIA
ZeroFK
table.getColumnModel().getColumn(???).setHeaderValue(???).
Similar Messages
-
How to change the column names in display
Hi,
I want to change the columns names and give the display names as more User friendly..
How should I acheive this in WebI reports.
Regards,
BOBHi,
the columns names are normal text fields. Just selecdt to edit your report , go to the editor panel and select the column header you want to modify. You can enter the text you want to display
Regards,
Stratos -
How to change the column name as bold in adf table
Hi,
How can I change the column name with bolder style and blue colour in adf Table?
I changed the color and font weight in af:column properties, but its effecting the data in that column but not with the column Header Text property.(i have given column name in header text).
can any one have any idea how to do this?
and I have taken panel tabbed layout and in that i'm displaying this table.
but this table has scroll beneath of it to show all columns.
but i want to display all columns (for this, page should have scroll at the bottom side).
how can I achieve this???Hi,
Add the following CSS Code to the custom skin css file that is to be created as per the suggestions above.
*af|column::column-header-cell{*
color:Blue;
font-weight:bold;
This would ensure that all the table column headers are blue in color and bolder font style through-out the application.
By the way, what version of JDeveloper are you using?
Thanks,
Navaneeth -
Hi experts,
I have used tableview in BSP . In the output it displays the column name as per the table which i have referred. I want to change the name of the column. How Should i do that.. anyone plz explain me with an example.
Thanks in Advance
Edited by: Vijay Babu Dudla on Apr 28, 2009 12:59 AMHi ,
If you want to change the column name, you can put your code following:
<htmlb:tableViewColumn columnName = " "
*title = " put the cloumn name here"*
</htmlb:tableViewColumn>
Please try.
Any doubt let me know.
Regards,
Chris Gu
Edited by: Gu Chris on Apr 28, 2009 5:26 AM
Edited by: Gu Chris on Apr 28, 2009 5:26 AM
Edited by: Gu Chris on Apr 28, 2009 5:27 AM -
Change the column names programatically
Hi All,
is it possible to change the column name in a table programatically?? my req is like this..I ve a table which contains 60 columns. out of these 60 columns 53 columns signifies the 53 weeks of the year. so i ve to display the date in the column headers. How can i achieve this?
Thanks in advance,
SreeColumn prompts can be modified through the OAF Personalization screens. This will ensure you are declaratively setting the values.
Regards,
Prabodh. -
Changing the column names displayed via an ODBC driver
Hi we are just starting to used Crystal Reports to improve the reporting capabaility of a legacy application, we can access the data fine using an ODBC driver. What we want to do is change the column names that are displayed within Crystal Reports so they are more user friendly and not in techno speak,, so that the users can create their own reports. Do we need to used Business Objects to setup a Universe to do this, is their a simple cheaper method sorry if this post is in the wrong section
Can you set up "views" in your database? That would probably be the easiest way to do this.
-Dell
- A computer only does what you told it to, not what you thought you told it to!</p> -
Hi,
I have a "viewcontaineruielement" which displays an ALV. Now i want to change the column names.
Please give an detailed answer.
ThanksHi Adil
Ple refer this.
data:
lr_alv_usage type ref to if_wd_component_usage,
lr_if_controller type ref to iwci_salv_wd_table,
lr_config type ref to cl_salv_wd_config_table,
lr_column type ref to cl_salv_wd_column,
lr_header type ref to cl_salv_wd_column_header,
lr_column_settings type ref to if_salv_wd_column_settings,
ls_column type salv_wd_s_column_ref,
lt_columns type salv_wd_t_column_ref,
Instantiate the ALV Component
lr_alv_usage = wd_this->wd_cpuse_alv_display( ).
if lr_alv_usage->has_active_component( ) is initial.
lr_alv_usage->create_component( ).
endif.
Get reference to model
lr_if_controller = wd_this->wd_cpifc_alv_display( ).
lr_config = lr_if_controller->get_model( ).
To get the dropdowns displayed you need to set the table to editable by using below statement
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
Set the UI elements.
lr_column_settings ?= lr_config.
lt_column = lr_column_settings->get_columns( ).
********-- Header Settings--*************
lr_column = lr_column_settings->get_column( 'VBELN' ).
lr_column->set_position( '1' ).
lr_header = lr_column->get_header( ).
lr_column->set_width( '2' ).
lr_column->Set_width( '2' ).
lr_header->set_text( 'Invoice No' ).
lr_header->set_tooltip( 'Invoice No' ).
lr_header->set_ddic_binding_field( ). -
What is the correct syntax to change a column name. say
ID VARCHAR2(10)
to
ID_NO VARCHAR2(10)You can alternatively do this:
Connect as sys user and run the following script:
SELECT obj# from obj$
where name = 'Your_Table_Name';
SELECT col# from col$
where obj# = obj# from previous query
and name = 'your_column_name which you want to rename';
update col$ set name = 'your_new_name'
where obj# = obj# from the first query
and col# = col# from previous query;
Alter system flush shared_pool;
connect as your user and you will see the change there.
Hope this helps
Rajeev -
Change in column name in REUSE_ALV_FIELDCATALOG_MERGE
Hi Everyone,
In my requirement I need to change the column name in the internal table t_fieldcat. But where can i find the way to change the names of column in REUSE_ALV_FIELDCATALOG_MERGE
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'YV_TAB'
CHANGING
ct_fieldcat = t_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.Hi,
you can do it in different ways, please try
1) Build field catelog
CLEAR wa_fieldcat.
wa_fieldcat-tabname = tab_name
wa_fieldcat-fieldname = 'Field Name'
wa_fieldcat-seltext_l = 'Field Text'.
wa_fieldcat-outputlen = 15.
APPEND wa_fieldcat TO it_fieldcat.
2) Create a structure with required fileds and create new data element refer with standard domain. Then you can give your require text in the Field Label tab. pass this structure to the FM.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'internal_tab_name'
i_structure_name = 'structure_name'
i_inclname = sy-repid
CHANGING
ct_fieldcat = it_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. -
Can I change the Column Name without losing data and change the sequence
Dear Experts,
I want to change the column name without changing the sequence and dont want lose the data.Oracle Version : ?
Example Based on 10g.
SQL> conn scott/tiger
Connected.
SQL> create table col1 as select * from all_objects where rownum <= 100;
Table created.
SQL> alter table col1 add constraints col1_pk_objid primary key(object_id);
Table altered.
SQL> desc col1
Name Null? Type
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
SQL> alter table col1 rename column object_id to object_no;
Table altered.
SQL> desc col1;
Name Null? Type
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_NO NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
SQL> column column_name format a30
1 select column_name,constraint_name
2 from user_cons_columns
3 where table_name = 'COL1'
4* and owner = 'SCOTT'
COLUMN_NAME CONSTRAINT_NAME
OBJECT_NO COL1_PK_OBJID
SQL>
also go through
http://www.dizwell.com/prod/node/65
Message was edited by:
user52 -
How to change JTable column header text
How do you set the text in the JTable column headers? I know you can create a JTable specifying the text in an array:
<li>JTable(Object[][] rowData, Object[] columnNames)
But if you create the JTable specifying a TableModel,
<li>JTable(TableModel dm)
the header text defaults to "A", "B", "C", etc. I cannot figure out how to access the text in the header names so it can be changed to something useful. I know how to get the JTableHeader for the table, but it does not seem to have methods for actually setting header values.I'm sure that model allows you to specify header values so you don't have to do so manually. I would be very surprised if it didn't override the default getColumnName() method to provide a reasonable names.She wasn't writing the class, but [url http://forums.oracle.com/forums/thread.jspa?messageID=9200751#9200751]outlining a design for me to implement. And, based on a previous comment I had made, I think she assumed I wanted the new design to look as much like the old as possible. There were no headers in the original design, which wasn't even a table.
Anyway, this works:
final static String statisticsColumnNames[] = {
"Type", "Count",
"Red QE", "Green QE", "Blue QE", "Average QE",
"Distance"
qErrors = new QEBeanTableModel();
JTable errorTable = new JTable(qErrors);
TableColumnModel tcm = errorTable.getColumnModel();
for (int col = 0; col < statisticsColumnNames.length; col++)
tcm.getColumn(col).setHeaderValue(statisticsColumnNames[col]);
It looks like setHeaderValue() on the TableColumn is what I was looking for.Again, only used if you are dynamically changing the values at run time or you don't like the defaults provided by the Bean-aware model.I coded the above before I read your last post. The QEBeanTableModel is extremely specific to my program. I.e. I cannot imagine it being used anywhere else. Would it still be better to implement a getColumnName() within the table model? Looking at your [url http://www.camick.com/java/source/RowTableModel.java]RowTableModel.java source, I can see that it would not be difficult to do so.
Just decided to add the getColumnName() method. This whole sub-project is based on implementing a clean modern design (and learning about Java Beans). You've clearly stated twice that the method I have implemented is for dynamic header values only, which has already answered what I asked last paragraph. -
How can I change a column name in table (JDeveloper 10.1.3.3)?
I'd like to change a table column name, for example instead of "FirstName" I'd like "Name".
Here is the preview: http://img208.imagevenue.com/img.php?image=86575_firstname_122_578lo.JPG
Thank You in advance!Now I have following problem: When I change "Label text" to column which has "Combo box" (Department insted of DepartmentId) I do not have my combo box anymore, just DepartmentId (Number). I have created binding... (DepartmentId -> Department Name) Why is this happening?
http://img151.imagevenue.com/img.php?image=47670_firstname_122_862lo.JPG
Can I change my attribute name in data model?
BTW I use ADFBC Swing
Sorry on my bad English ...
thank you
Message was edited by:
user638810
Message was edited by:
user638810
Message was edited by:
user638810 -
JTable column names with custom model
I'm having problems with column names in a JTable which uses a custom model. For some reason, the colums are being shown as A, B, C etc. The data, however, displays fine.
This is the code which constructs the table.
MyTableModel tableModel = new MyTableModel(myArrayList);
myTable = new JTable(tableModel);
myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myTable.setFillsViewportHeight(true);This is the class, MyTableModel
class MyTableModel extends AbstractTableModel {
private ArrayList<Account> data;
private String[] colNames = {"", "Name","Type","Group","Created","Modified"};
public MyTableModel(ArrayList<Account> data) {
this.data = data;
public int getRowCount() {
return data.size();
public int getColumnCount() {
return 6;
public Object getValueAt(int row, int col) {
Account account = (Account)data.get(row);
switch(col) {
case 0:
return account.getIcon();
case 1:
return account.getName();
case 2:
return account.getType();
case 3:
return account.getGroup();
case 4:
return account.getDateCreated();
case 5:
return account.getDateModified();
default:
return "";
public String getColumName(int index) {
System.out.println("N:"+colNames[index]);
return colNames[index];
}When the table is displayed, nothing's displayed to the console, but I'd have thought getColumnName would print the current column name. Am I missing something obvious?Oh great. I'll go back under my rock.
Thanks =) -
JTable, column names not appearing!
I am using the following code:
Vector columnNames = new Vector();
Vector data = new Vector();
try
// Connect to the Database
Common.Data.DataAccesser da = new Common.Data.DataAccesser();
Connection connection = da.getConnection();
// Read data from a table
String sql = "Select * from schedule1";
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
// Get column names
for (int i = 1; i <= columns; i++)
columnNames.addElement( md.getColumnName(i) );
// Get row data
while (rs.next())
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++)
row.addElement( rs.getObject(i) );
data.addElement( row );
rs.close();
stmt.close();
catch(Exception e)
System.out.println( e );
// Create table with database data
JTable table = new JTable(data, columnNames);
jPanel2.setLayout(new java.awt.BorderLayout());
jPanel2.add(table, BorderLayout.CENTER);I know its a bit messy, wat im tryin to do is add the table to the panel. the rows are showing perfectly but the column names do not show! Can anyone help?1) Please ask Swing questions in the Swing forum.
2) Don't forget to specifically make the table header display. You do this by adding the table header to the jpanel in the borderlayout NORTH position, and you get the table header by calling getTableHeader. Have a look here for instance:
http://forum.java.sun.com/thread.jspa?threadID=5235339&tstart=0 -
JTable Column Names Not Displaying
Hi there
I create a JTable by passing the JTable constructor my custom TableModel which extends AbstractTableModel.
For column names I have a String[] containing the column names in my custom TavleModel and have coded the TableModel methods accordingly.
For some reason when I run the code the table is displayed, but the column names are not!?!
Any advance is appreciated!Sorted!
After looking at sample code in the JTable tutorial, it seems the table likes/needs to be added to a JScrollPane, as once I did this the column headings started appearing.
e.g. JScrollPane scrollPane = new JScrollPane(table);
Maybe you are looking for
-
Hi experts: I got a problem while using graphic function (GRAPH_MATRIX_3D) to create chart, but I find the function can only create column(bar) chart and the maximal column is 6. As per the customer's request, they want to view the chart in line ch
-
Burned DVD's have momentary pixelation
Hi When I export my project from FCPX everything is perfect. When I use IDVD to add theme and chapters there is pixelation for 2 minutes on the burned DVD at the exact same spot of my project every time. Even though the source is 100% it keeps occurr
-
Synchronous JDBC adapter(receiver side) with stored procedure
Hi experts, Can some database processing logic be included in receiver JDBC (synchronous) adapter...to put it simply I have synchronous JDBC adapter in the receiver side..Using this JDBC adapter I want to get some response back from the table.. The r
-
import java.awt.*; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; public class GridBagLayoutDemo2{ final static boolean shouldFill=true; final static boolean shouldWeightX=true
-
Plz.. Help me to get database field for Rate/Hour
I have the requirement to get the Rate/Hour for Actual Labor ,OT Labor and WE Labor etc. <b>I am passing Activity types to AFVC-LARNT to get different types of Labor</b> .But i don't know the Database Table Field to get this Rate/Hour . please sug