How to find Specifiq header column in JTable

sir
i use the following
table.getTableHeader().setBackground(Color.red);
but i want to change the color of specfiq column
how can i do
thanks

I have not tried this but hopefully this helps
JTable e;
e.getColumnModel().getColumn(chooseAcolumn).setHeaderRenderer(YourRenderer);
public class YourRenderer extends DefaultTableCellRenderer implements TableCellRenderer
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int column)
        //Do what you want....
        this.setText((obj==null)?"":obj.toString());
        this.setBackgroundColor(Color.red);
        return this;
I haven't tested this hopefully this gives you a direction..

Similar Messages

  • How can i make hidden column in JTable

    hi, how can i make hidden column in JTable,
    basically i have a ID field in JTable, i have to use this ID , but i also dont want to show this ID in JTable.
    any idea how ??

    staiji its not working
    i did this :
    first :
    TableColumnModel columnModel =
    usersTable.getColumnModel();TableColumn column =
    columnModel.getColumn(1);
    usersTable.removeColumn(column);
    then when i trying to get this :
    Integer userId =
    (Integer)usersTable.getValueAt(UserBrowser.this.usersTa
    le.getSelectedRow(), 0);
    it not give me ID column's value .
    i have a column in JTable like :
    ID | Username | First name | Last name
    i want to hide ID column , but get this ID's value
    when user clicks on JTable row.Hi, if you would read the documentation about JTable.getValueAt(...) you will find, that there is a significant difference between this method and the datamodels getValueAt(...) method. JTables getValueAt(...) method interprets column-index as index in its TableColumnModel - in your TableColumnModel there is no column any longer that holds ID values, therefore you were not able to get it by JTable.getValueAt(...). Do not use these methods for the purpose you want it for - you will also get the wrong values, if the user has repositioned columns - the column index is always interpreted as index in the currently used TableColumnModel and IS NOT A MODELINDEX.
    greetings Marsian

  • How to find out Head of own organisational unit in organisation

    How to find out Head of own organisational unit in organisation
    Hierarchy after giving the transaction oopoma_crm?

    Hi,
    try RH_GET_LEADER
    Then you'll get the CP. Then get the BP number, that should be CRM_CENTRALPERSON_GET.
    Regards
    Andreas

  • How to find the header and item level status of a CRM contract ?

    Hi,
    Few questions
    A. How to find the header and item level status of a CRM contract ? My req is to select all the contract line items which are in CLOSED status.
    B. How to get the BPs associated with a contract ?
    Anyone have the list of CRM tables and the relation amongst them. Please mail me in [email protected]

    CRMD_ORDERADM_H     Contains the Header Information for a Business Transaction.
    Note:
    1.     It doesn’t store the Business Partner
           responsible for the transaction. To 
           get the Partner No, link it with
           CRM_ORDER_INDEX.
    2.     This table can be used for search
           based on the Object Id(Business
           Transaction No). 
    CRMD_CUSTOMER_H     Additional Site Details at the Header Level of a Business Transaction
    CRMD_LINK     Transaction GUID set for all the Business Transactions
    CRMD_ORDER_INDEX     Contains Header as well as Item details for a Business Transaction.
    Note:
    1.     It doesn’t store the Business 
          Transaction No (Object ID).
          To get the Business Transaction No  
          link the table with
          CRMD_ORDERADM_H
    2.   This table can be used for search
          based on the Partner No
    CRMD_ORDERADM_I     Stores the Item information for a Business Transaction. The scenarios where we have a Contract Header and within contract we have Line Items for the contract, this table can be useful.
    E.g. Service Contracts
    CRMD_CUSTOMER_I     Additional Site Details at the Item Level of a Service Contract
    Pl.reward points.......

  • How can find out LONG column database?

    Hi,
    in my database ORA-1461 error occured
    01461, 00000, "can bind a LONG value only for insert into a LONG column
    how can find out LONG column in my database ?

    DESCRIBE
    The description for tables, views, types and synonyms contains the following information:
    each column's name
    whether or not null values are allowed (NULL or NOT NULL) for each column
    datatype of columns, for example, CHAR, DATE, LONG, LONGRAW, NUMBER, RAW, ROWID, VARCHAR2 (VARCHAR), or XMLType
    precision of columns (and scale, if any, for a numeric column)
    Extract of the link;
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12019.htm#SQPUG040
    Secondly with reference to the error;
    Do not try to insert LONG datatypes into other types of columns.
    Hope this helps.
    Adith

  • How to find out the columns which has 16 digit credit card number

    Hi All,
    I have a requirement where in i need to find out the columns which has 16 digit credit number in it and create a report with owner, table name and column name.
    The issue is that the credit card number can be entered in any columns of any table of any schema. For example the credit card number can be entered in any description field(eg: The number is 4001412134642881), in that case i need to filter only the numbers and do the LUHN check to validate the credit card number.
    Please provide me a suggestion on how to scanl the values of all the columns to know the column which has credit card number.
    Regards,
    Raj.

    Tell me this - how the hell do you have a database with credit card number data and NOT know which columns of which tables contain credit card numbers? (and how on earth is this data NOT encrypted!?)
    How is what you want to do, NOT a fishing expedition to hack a database that may or may not be storing credit card details?
    And do you honestly think that we should simply trust that once you have extracted these numbers, performed a Luhn algorithm to verify these as credit card numbers, you are not going to fraudulently use these credit card numbers!?
    I have marked your posting as an attempt to hack an Oracle database for fraudulent use of credit card data. I hope that your OTN account is terminated soon and trust that your too much of a coding idiot to actually succeed in this endevour.

  • How to find out the column causing the error while doing update or insert

    I'm getting the below error when attempt to update or insert a long string that is more than its defined length in the DB2. For example in table the column length is defined as 50, however from UI the data for that column is more than 50 chars.
    {color:#ff0000}**Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTAT**
    **E: 22001, SQLERRMC: null**
    **at com.ibm.db2.jcc.b.hh.b(hh.java:1369)**
    **at com.ibm.db2.jcc.b.hh.c(hh.java:1356)**{color}
    The above issue can be fixed by setting maxlength in the UI itself. However in my case, there is a backend program trying to insert or update load of records. If the exact column name causing the error is known, it will be helpful to load the data properly in the next attempt.
    I have worked around it using SQLWarning and DataTruncation, but couldn't find the solution yet.
    Any help on this issue will be really appreciated.

    Medraf wrote:
    what is validator? Is it like validation.xml in struts? Are you suggesting like defining set of validation rules in the xml and apply the same for each record before doing any update or insert in DB? If so, then I could implement this validation logic in my backend code, however it may take more time to complete the batch prcoess.
    How you implement doesn't matter.
    However given a schema generating code for such validation is trivially simple at least for field types and sizes. Relationships are harder but those can be handled via custom rules.
    Alternatively I'm looking for some kind of API in JDBC or Hibernate which gives the detailed sql exception message containing the error info like the column name and the reason for failure while update or insert. If not possible, then validation logic needs to be implemented.Having seen something similar in Oracle years ago I seriously doubt that you are going find it magically appearing in JDBC/hibernate. There might be warning on the SQLException (see the java docs for SQLException) but I wouldn't count on it. Other than that the only possibility is making some sort of call in db2 itself that tells you the error. Only problem with that is it might require the context which might not be available once you see the error (presuming, especially for performance, that you are using batch processing.)
    As a start figure out how to find out using only db2 (docs and/or db2 forums.)

  • How to find out Particular column value in DB

    Hi All,
    I have to find out Particular column value in DB .can U tell me the Query for that.

    There is one way:
    Re: How to write the Query

  • How to find exact error column name

    hi all ,
    My requirement is as follows .
    I am trying to add a record into temp_emp table inside plsql block ,after executing it i am getting ORA-01438: value larger than specified precision allowed for this column error .I want to find for which column the error is coming .
    In the below example i clearly know that deptno column precision is 2 and i am inserting bigger value that is why i am getting error .
    let us consider a scenario where i am trying to insert 40 colunm values into table and one column is causing the problem , how to find that column alone .
    SELECT * FROM V$VERSION
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0    Production
    TNS for Solaris: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    CREATE  TABLE
    temp_emp
      empno  NUMBER(4),
    ename VARCHAR2(15),
    job  VARCHAR2(10),
    deptno NUMBER(2)
    DECLARE
       v_empno    NUMBER (4);
       v_ename    VARCHAR2 (15);
       v_job      VARCHAR2 (10);
       v_deptno   NUMBER (2);
    BEGIN
       INSERT INTO temp_emp
                   (empno, ename, job, deptno
            VALUES (1234, 'ABC', 'CLERK', 1000
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (   SQLCODE
                                || DBMS_UTILITY.format_error_backtrace
                                || SQLERRM
    END;
    /finally I want column name in the error message .
    Thanks,
    P Prakash

    Oracle does not provide the column information in the error message and I don't know of any way to do so outside of developing something convoluted. For example:
    SQL> DECLARE
      2     te_row temp_emp%ROWTYPE;
      3  BEGIN
      4
      5     te_row.empno  := 1234;
      6     te_row.ename  := 'ABC';
      7     te_row.job    := 'CLERK';
      8     te_row.deptno := 1000;
      9
    10     INSERT INTO temp_emp
    11          VALUES te_row;
    12  END;
    13  /
    DECLARE
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: number precision too large
    ORA-06512: at line 8Also, that EXCEPTION block has a bug in it (no RAISE or RAISE_APPLICATION_ERROR).
    Edited by: Centinul on May 3, 2012 8:23 AM

  • How to find the partition column in a partitioned table

    Hi,
    I have a partition table and I need to find out what column was used to partition the table. Range partition.
    Thanks,
    Maria Sanchez

    select *
    from dba_part_key_columns

  • How to find a head code in any user-exits

    i want to find a head coding in  all user-exits

    You can use the standard SAP program RSRSCAN1 to find any hardcoded string.Just give in the program name and the string and it will find all occurences of the string in the program.

  • How to find primary constraint column

    How can i get the column names of the primary keys if i know the CONSTRAINT_NAME, and CONSTRAINT_TYPE = "P" in the user constraints of the table name.
    thanx in advance
    utsab

    Hi,
    Have you tried using the table USER_CONS_COLUMNS ?
    This has information about columns in constraint definitions.
    Hope this helps.
    Sujatha.

  • Stumped as to how to freeze a header column

    In Numbers '09 I select the left-most column (in grey, so I presume that makes it a "header" column) but the header button offers only "repeat header columns on each page", not "freeze header columns". Similarly the Table menu offers the choice of "repeat" but not "freeze" headers. What am I doing wrong?
    Thanks

    Look in the toolbar
    OR
    In the table inspector

  • How to Find Two Matching Columns in Two Table(to create a JOIN)

    Hi Guys!
    I just wondering if it is possible to have a SQL query to find two matches columns in two table to create any type of joins?!
    Let's say I have two tables CUSTOMER + INVOICE is it possible to run a SQL query to find two join able columns without scanning the tables visually?!
    Best Regards,

    Well, there's the Data Dictionary you could query for foreign key columns/constraints.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:661009003696

  • How to freeze row and column in JTable

    Hi,
    I need to freeze first two rows and columns in a large JTable. I found ways to freeze either a row or a column, but not both at the same time.
    Can any of you help ?
    Found this code which allows freezing a col. Similar method can be used to freeze column
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JViewport;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableModel;
    public class FrozenTablePane extends JScrollPane{
    public FrozenTablePane(JTable table, int colsToFreeze){
    super(table);
    TableModel model = table.getModel();
    //create a frozen model
    TableModel frozenModel = new DefaultTableModel(
    model.getRowCount(),
    colsToFreeze);
    //populate the frozen model
    for (int i = 0; i < model.getRowCount(); i++) {
    for (int j = 0; j < colsToFreeze; j++) {
    String value = (String) model.getValueAt(i, j);
    frozenModel.setValueAt(value, i, j);
    //create frozen table
    JTable frozenTable = new JTable(frozenModel);
    //remove the frozen columns from the original table
    for (int j = 0; j < colsToFreeze; j++) {
    table.removeColumn(table.getColumnModel().getColumn(0));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //format the frozen table
    JTableHeader header = table.getTableHeader();
    frozenTable.setBackground(header.getBackground());
    frozenTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    frozenTable.setEnabled(false);
    //set frozen table as row header view
    JViewport viewport = new JViewport();
    viewport.setView(frozenTable);
    viewport.setPreferredSize(frozenTable.getPreferredSize());
    setRowHeaderView(viewport);
    setCorner(JScrollPane.UPPER_LEFT_CORNER, frozenTable.getTableHeader());
    }

    Hi,
    I need to freeze first two rows and columns in a large JTable. I found ways to freeze either a row or a column, but not both at the same time.
    Can any of you help ?
    Found this code which allows freezing a col. Similar method can be used to freeze column
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JViewport;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableModel;
    public class FrozenTablePane extends JScrollPane{
    public FrozenTablePane(JTable table, int colsToFreeze){
    super(table);
    TableModel model = table.getModel();
    //create a frozen model
    TableModel frozenModel = new DefaultTableModel(
    model.getRowCount(),
    colsToFreeze);
    //populate the frozen model
    for (int i = 0; i < model.getRowCount(); i++) {
    for (int j = 0; j < colsToFreeze; j++) {
    String value = (String) model.getValueAt(i, j);
    frozenModel.setValueAt(value, i, j);
    //create frozen table
    JTable frozenTable = new JTable(frozenModel);
    //remove the frozen columns from the original table
    for (int j = 0; j < colsToFreeze; j++) {
    table.removeColumn(table.getColumnModel().getColumn(0));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //format the frozen table
    JTableHeader header = table.getTableHeader();
    frozenTable.setBackground(header.getBackground());
    frozenTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    frozenTable.setEnabled(false);
    //set frozen table as row header view
    JViewport viewport = new JViewport();
    viewport.setView(frozenTable);
    viewport.setPreferredSize(frozenTable.getPreferredSize());
    setRowHeaderView(viewport);
    setCorner(JScrollPane.UPPER_LEFT_CORNER, frozenTable.getTableHeader());
    }

Maybe you are looking for