How to programmatically select a column in a JTable

Hi,
I'm writing a program which requires me to select a column in the JTable through code. The problem is that I could only find getSelectedColumn() function in JTable and no setSelectedColumn().
Please let me know if there is any workaround for this.
Regards,
Derreck

Hi,
table.setColumnselectionInterval(index0,index1);
The above line will suffice your requirement.
Cheers,
Gokul.

Similar Messages

  • How do I select multiple columns in a recordset

    I am very new to Dreamweaver/PHP/MYSQL
    I have created my recordset but I cant work out how I select multiple columns.
    How do I select multiple columns, I want to search for data that is spread over different columns.
    My recordset looks like this just now.
    SELECT *
    FROM names
    WHERE nameone = john
    I have 11 columns where the name john my or may not appear so how would I select all the columns. What would the recordset look like.
    As I have said I,m very new to this  and forgive me if what i have just said makes no sense.
    Thanks

    >I have 11 columns where the name john my
    >or may not appear so how would I select all
    >the columns. What would the recordset look like.
    You could try a Full-Text search (if mysql supports it) but on the surface, this sounds like a badly designed data structure. What does your database and table design look like?

  • How can i select other column values('-' separated) in group by function

    CREATE TABLE EMP (
         EMPNO NUMBER(4) NOT NULL,
         ENAME VARCHAR2(10),
         JOB VARCHAR2(9),
         SAL NUMBER(7)
    INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7369, 'SMITH', 'CLERK', 800);
    INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7499, 'SMITH', 'SALESMAN', 1600);
    INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7521, 'ALLEN', 'SALESMAN', 2400);
    In Output I want 3 columns : EMP,SUM(SAL),JOB(hyphenSeparated)
    Means i want my output like
    First row : SMITH,2400,CLERK-SALESMAN
    Second row : ALLEN,2400,SALESMAN
    I tried to write following sql : select ename,sum(sal) from emp group by ename
    But i want other colummn value in '-' separated. but group by is only allowing agreegated function.
    How can i select other column value using group by function.

    SQL>  select ename,sum(sal), listagg(job, '-') within group (order by job) as job  from emp group by ename;
    ENAME        SUM(SAL) JOB
    ALLEN            2400 SALESMAN
    SMITH            2400 CLERK-SALESMANnote: LISTAGG is a feature of 11.2

  • How set disable select matrix column header

    How set disable select matrix column header same Inventory-->Pick List Form
    Thanks Advance.

    Hi ,
    do u mean Price List Form Header...
    If Yes Means Try the Following,
    select case pVal.FormType
    case "155"
    Select Case pVal.Before_Action
    case True
    select case pval.ItemUid
    case "3"
    Select Case pVal.EventType
    Case SAPbouiCOM.BoEventTypes.et_CLICK
    if pval.row = 0  Then BubbleEvent = False : Exit Sub
    End Select
    End Select
    End Select
    Regards,
    Ganesh k

  • How to forbid to moving columns in a JTable

    Hi together,
    i have one simple question. How can i forbid, that columns can be moved in my Jtable?
    If anyone can help or may has a useful link, i would be glad.
    thanks
    BackUP

    Hi,yourTable.getTableHeader() .setReorderingAllowed(false);

  • How to programmatically select an item of a tree?

    I,
    I have a vi that I want to use only with a keyboard. There is a tree in this one. In this vi we can select an item, with the arrows of the keyboard, and put the color of the item background red or green.
    After a loop to put all red, (property node, ActiveItem->Line and ActiveCell->background color), the active item is the last of the tree, but the selected item isn't the same. If I set the Active Item to 0 after the loop, and then I press down arrow of the keyboard, the item selected will be the next after the one before the loop, and it's not from the start of the tree.
    (Sorry for the English)
    I want to select a Cell Prgrammatically but I didn't find anything in the property or Invoke nodes...
    Thanks a lot.
    Barto

    Here is the little program who illustrates my answer.
    Thanks for helping me.
    Barto
    Message Edité par Barto le 01-31-2007 07:55 AM
    Attachments:
    Tree problems.vi ‏16 KB

  • How could I display some columns in a JTable?

    Help, please:
    I got a Table data(using AbstractedTableModel), and I can display all rows and columns. How can I just display several columns and all rows? Should I delete some columns from table and fireChanges or what? but I need these columns later. Make sense? any ideas?
    Thanks for any helps.
    Royan

    this worked for me,
    import java.util.*;
    import java.io.*;
    import java.net.URL;
    import java.sql.*;
    import javax.swing.table.*;
    import javax.swing.*;
    public class HideTableColumns
          public HideTableColumns()
          private void initialize()
          DefaultTableModel m = new DefaultTableModel();
          try {
             java.util.Vector data = new java.util.Vector();
             java.util.Vector headers = new java.util.Vector();
             String s = "";
             headers.addElement( "OrderID" );
             headers.addElement( "CustomerID" );
             java.util.Vector datum = null;
             datum = new java.util.Vector();
             s = "OrderID";
             datum.addElement( s );
             s = "CustomerID";
             datum.addElement( s );
             data.addElement( datum );
             m.setDataVector( data, headers );
             for( int r = 0; r < m.getRowCount(); r++ )
                for( int c = 0; c < m.getColumnCount(); c++ )
                s = ( m.getValueAt( r, c ) ).toString();
                System.out.println( s );
          } catch( Exception e ) {
             System.out.println(e.getMessage());
             e.printStackTrace();
          JFrame f = new JFrame();
          JPanel p = (JPanel) f.getContentPane();
          JTable tb = new JTable( m );
          TableColumn col = tb.getColumnModel().getColumn(1);
          col.setPreferredWidth(0);
          col.setMinWidth(0);
          col.setMaxWidth(0);
          p.add( tb );
          f.pack();
          f.show();
          public static void main( String[] args )
          HideTableColumns d1 = new HideTableColumns();
          d1.initialize();
    }

  • How to change width of columns in a JTable component?

    I created JTable1 by dragging from DataControls. I tried to change column width by changing of EntityObject - Width. But it doesn't work. I tried to do it In table binding editor - it doesn't work too.
    Help pls.

    Hello Megadown,
    This is how you can change the width:
    TableColumn column = jTable1.getColumnModel().getColumn(0);
    column.setPreferredWidth(100);
    Regards
    Johan

  • How can I restrict the column dragging of JTable?

    I have a requirement like, if we have any editable cell in the JTable, we should not allow the user to drag the columns at all. I tried with setDragEnabled(false) ..but its not giving the proper out put..... can any one come up with a solution for this?

    table.getTableHeader().setReorderingAllowed(false)

  • Selecting multiple columns in a jtable

    whats up java programmers,
    i have a problem. i have a jtable with 8 columns. i set a mouse listener to the headers so when i click on one that column underneath the header is highlighted. my problem when i click on one header and then click on another both columns do not stay highlighted. can anyone help please
    matt
    [email protected]

    only way I know is to use
    setColumnSelectionInterval
    and
    addColumnSelectionInterval
    to specifiy which columns.

  • How to programatically select a row in TableBean and update its column?

    Hi,
    Can anyone help me on How to programmatically select a row in a TableBean and update its column?
    Thanks,
    Jon

    Hi,
    My requirement is I need to update a column in a particular row of the table using fire action...
    I have a datefield bean serve as birhdate and base on this I need to update the age column depending on the given dates..
    Here's my code under the Process form request for your reference...
    if (actionInMainPersonScreen.equals("changeDate"))
    String checkId = pageContext.getParameter("paramDatePersonId");
    OAFormValueBean depPerId = (OAFormValueBean)depTable.findIndexedChildRecursive("ChildPersonID");
    OAMessageTextInputBean depFName = (OAMessageTextInputBean)depTable.findIndexedChildRecursive("FirstName");
    OAMessageDateFieldBean dateBirth = (OAMessageDateFieldBean)depTable.findIndexedChildRecursive("BDay");
    OAMessageStyledTextBean age = (OAMessageStyledTextBean)depTable.findIndexedChildRecursive("Age");
    Date changeBDate = new java.util.Date();
    Date dateToday = new java.util.Date();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    changeBDate = (Date)dateBirth.getValue(pageContext);
    Calendar cal = Calendar.getInstance();
    ResultSet empAge = null;
    String newAge = null;
    OADBTransaction trans = personam.getOADBTransaction();
    System.out.println("BirthDate: " + changeBDate + " Date Today: " + sdf.format(dateToday));
    String expQuery = "SELECT Trunc((sysdate - To_Date('" + pageContext.getParameter("paramDateBirth") + "'))/365) compAge, Sysdate from dual";
    System.out.println("SQL: " + expQuery);
    PreparedStatement expPreparedStatement = trans.createPreparedStatement(expQuery ,1);
    try
    empAge = expPreparedStatement.executeQuery();
    } catch (SQLException e) {}
    try
    while (empAge.next())
    newAge = empAge.getString("compAge");
    age.setText(pageContext, newAge);
    empAge.close();
    } catch (SQLException e) {}
    regards,
    Jon

  • How to select all columns in a trigger?

    I add a "before delete" trigger on a table, in order to insert the records to a backup table before they are deleted.
    but I cannot write like this : insert into t_backup select * from :old;
    The table has more than 30 columns so I don't want to select them one by one, how can I select all columns?

    Yes, it is possible by writing something like this :
    where col1 = :old.col1; But it is not directly supported. First, we need a package to remember all the OLD records:.... and please see below link for complete code in action :
    http://www.dbforums.com/oracle/925729-trigger-back-up-data.html
    What I am doing here, just copying the code and replacing "emp" with "test" (The table name on which I am going to apply this using notepad find and replace):
    SQL> select * from test_backup;
    no rows selected
    SQL> select * from test;
             A
             1
             2
             4
             5
    SQL> select * from test_backup;
    no rows selected
    SQL>
    create or replace package test_trg_pkg as
      type test_type is table of test%ROWTYPE index by binary_integer;
      test_tab test_type;
    end;
    create or replace trigger test_bds before delete on test
    begin
      test_trg_pkg.test_tab.delete;
    end;
    create or replace trigger test_adr after delete on test
    for each row
    declare
      -- To allow us to select the old values
      pragma autonomous_transaction;
    begin
      select *
      into   test_trg_pkg.test_tab(test_trg_pkg.test_tab.COUNT+1)
      from   test
      where  a = :old.a;  <----- Here you have to give your column name.
    end;
    create or replace trigger test_ads after delete on test
    begin
      for i in 1..test_trg_pkg.test_tab.COUNT loop
        insert into test_backup values test_trg_pkg.test_tab(i);
      end loop;
    end;
    SQL> delete from test where a=1;
    1 row deleted.
    SQL> select * from test_backup;
             A
             1
    SQL> delete from test where a=2;
    1 row deleted.
    SQL> select * from test_backup;
             A
             1
             2
    SQL>Regards
    Girish Sharma

  • How to get Select All or select Multiple columns  in OOALV

    HI Experts
    i'm assignig internal table to dynamic internal table(FS_IST_TABLE) for to display the output.
    but i'm not geting the Select ALL Option. and i can't select multiple columns at a time.
    where i can select only one column.
    how can i select multiple columns.
    please any one help me.
    regrads,
    rathan.

    Hi,
      If we want to select the multiple columns in the alv by using ooabap
    so in the class CL_GUI_ALV_GRID  it is having one method SET_TABLE_FOR_FIRST_DISPLAY
    it is having one importing parameter IS_LAYOUT of type lvc_s_layo type
    and this structure contains one field SEL_MODE and set that field value as 'A'.
    then we can select the multiple rows in alv grid

  • How do you programmatically select TabBar VC within the MORE section?

    Can anyone help me figure out how to programmatically select a view controller that is beyond the main 4 tabs in a TabBarController? Usually you can use:
    tabBarController.selectedIndex = NSUInteger;
    but once you have more than 5 Tabs, you get the "More" tab as #5 and the others go into their own TableView. If you try to change selectedIndex to any # > 4 you get an NSRange error.
    I have tried the following workaround unsuccessfully:
    UIViewController *desiredVC = [[tabBarController.viewControllers] objectAtIndex:5];
    tabBarController.selectedViewController = desiredVC;
    where tabBarController is a UITabBarController;
    Still no go. Any help would be greatly appreciated.

    I came up with this solution:
    [self.tabBarController.moreNavigationController popToRootViewControllerAnimated:NO];
    [self.tabBarController setSelectedIndex:4];
    [self performSelector:@selector(selectMore:) withObject:newViewController afterDelay:0.1f];
    - (void) selectMore:(UIViewController *)controller
    [self.tabBarController.moreNavigationController pushViewController:controller animated:NO];
    It's does the job, but the "More..." list is shortly displayed before the newViewController is displayed.
    Is there another way to handle this problem?

  • Select Matrix Column

    How can I select a column programmatically?

    Hi dao,
    you can select the column and even a particular cell of that cloumn by using the following piece of code:
    oMatrix.Columns.Item(Column UID).Cells.Item(Row UID).Click(SAPbouiCOM.BoCellClickType.ct_Regular,0);
    Here,
    Column UID is the ID of the column you want to select, this is a string value.
    Row UID is the row number, this helps you to select a particular cell.
    You can find the row ID by using the following code in any event handler
    pVal.Row
    this code returns you the active row number.
    Regards,
    Prashant

Maybe you are looking for