Sortable jtable with jcombo having different values

Hi,
I have a contacts list with name, addrerss etc., and telephone numbers where each contact can have several telephone numbers.
The data is stored in a Derby DB in two tables with a PK and FK relationship. I need to load all the Contact fields in to a JTable where one of the columns will be the JCombos with telephone number(s) for that paticular contact.
I have studied two neat sample code segments posted by a senior mrmber "camickr" at;
[http://forum.java.sun.com/thread.jspa?forumID=57&threadID=637581 |http://forum.java.sun.com/thread.jspa?forumID=57&threadID=637581 ]
Also another by " skdaga " at;
[http://forums.sun.com/thread.jspa?threadID=749031&messageID=4284078|http://forums.sun.com/thread.jspa?threadID=749031&messageID=4284078]
both are solid working examples.
My problem is that I need to let the user to sort the table by columns and also filter by a text box entry. Meaning, the Combo boxes cannot have a fixed row index.
Could someone advice if this is possible or I should use some other approach.
Thanking you in advance,

Hi camickr;
Many thanks for your kind reply. I have managed to slightly modify your code to load the combos of individual telephone numbers dynamically.
I have done so by returning a TableCellEditor from the public TableCellEditor getCellEditor(int row, int column) method, in place of storing the
DefaultCellEditor dce1 = new DefaultCellEditor( comboBox1 ); etc., in an ArrayList.
It goes as this. Following method is called by the return statement.
private TableCellEditor createCellEditorWithCombo(int contactId) {
        JComboBox cmbNumbers = new JComboBox( <passed a Vector here thro' a PreparedStatement from the DB>);
        DefaultCellEditor editor = new DefaultCellEditor(cmbNumbers);
        return (TableCellEditor)editor;
    }The contactId of course could be easily desiphered from the "row" parameter then and there.
I will follow your advice on the sorting part (on which I am yet to read the API fully) and get back with the result. Btw, I use the JDK 1.6u7 with Netbeans 6.1
Thanking you once again for your great contributions,
ViKARLL
NB: By the way;
camickr wrote:
Well, if you look at my example you will note it uses the convertColumnIndexToModel(...). So you need to do the same thing for the row.It looks like you are referring to a diffrent post by you, since your example I worked on does not contain this method ??
Edited by: ViKARLL on Sep 13, 2008 4:19 AM

Similar Messages

  • Adding a parameter with comma separated having different values

    i want to add a parameter with comma separated having different values of a column. e.g i have column having values from 10000 to 99999. i want to create report for the selected values of 11111,12111,131111 etc. This selection can be one or more values as desired. Second problem is restricting the records as per parameter.

    Reports doesn't allow multi-selection of a parameter in its parameter form. You need to use Oracle*Forms or an HTML Form to front end more advanced parameter form options.
    However, you could have multiple parameters and combine their selections into a single parameter in the after parameter form trigger. This would at least allow you to give the user the option for selecting up to 'n' parameters. The single parameter would have to be of type "character" and you probably want to add appropriate quotes around the values in the after parameter form trigger.
    Second problem is restricting the records as per parameter. Once you've got the comma seperated values into a single parameter (say p_myValues with a default value of '') then you can just use a lexical parameter to restrict the values as in:
    select * from emp
    where to_char(empno) in (&p_myValues)

  • Count of rows having different values

    SQL>  select  * from med;
    CERT  REC  PRIM RACE
    100    10   EN   USA
    100    11   EN   USA
    100    12   EN   USA
    100    13   SP   MX
    200    14   SP   MX
    200    15   SP   MX
    6 rows selected.
    SQL>  select  * from sub;
    CERT  REC PRIM RACE
    100    10   EN   USA
    100    11   EN   USA
    100    12   EN   USA
    100    13   SP   MX
    200    14   SP   MX
    200    15
    6 rows selected.
    SQL> select  * from den;
    CERT  REC  PRIM RACE
    100    01   EN   USA
    100    02   EN   USA
    100    03   EN   USA
    100    04   SP   MX
    200    06   SP   MX
    (cert,rec) uniquly identifies a person;
    In Den table rec =med.rec-9 or rec =sub.rec-9 which implies
                med       sub     den
    (cert,rec)=(100,10)=(100,10)=(100,01)How can I find out how many people in the table where the PRIM and RACE hold different values.?

    Hi,
    Perhaps this ,
    with med as (
    select 100 CERT,   10 rec,   'EN' prim,   'USA' race from dual union all
    select 100  ,  11,   'EN',   'USA' from dual union all
    select 100  ,  12,   'EN',   'USA' from dual union all
    select 100  ,  13,   'SP',   'MX' from dual union all
    select 200  ,  14,   'SP',   'MX' from dual union all
    select 200  ,  15,   'SP',   'MX' from dual )
    sub as (
    select 100 CERT,    10 rec ,  'EN' prim,   'USA' race from dual union all
    select 100,    11 ,  'EN',   'USA' from dual union all
    select 100,    12 ,  'EN',   'USA' from dual union all
    select 100,    13 ,  'SP',   'MX' from dual union all
    select 200,    14 ,  'SP',   'MX' from dual union all
    select 200,    15, null, null  from dual )
    den as (
    select 100 cert,    01 rec,   'EN' prim,  'USA' race from dual union all
    select 100,    02,   'EN' ,  'USA'from dual union all
    select 100,    03,   'EN' ,  'USA'from dual union all
    select 100,    04,   'SP' ,  'MX'from dual union all
    select 200,    06,   'SP' ,  'MX'from dual )
    ----- sample data
    select cert, prim, race ,count(rec) rec
    from (
    select *
    from med
    union all
    select *
    from sub
    union all
    select *
    from den
    group by cert, prim, race
    ORDER BY 1,2,3
          CERT PR RAC        REC
           100 EN USA          9
           100 SP MX           3
           200 SP MX           4
           200                 1HTH
    SS

  • Release strategy for PR with materials having different prices

    Hai Gurus
    Can we make a release strategy for a variant configured material ?
    I mean create a strategy in such a way that price is critical factor and the materials what ever we choose for the PR has different characteristics dependencies like for example ( A chair having different characteristics like color, material ( like steel, leather etc) and other features like wheels etc and whatever characteristics we choose has a different price.......... so when v come to the release strategy it has to be approved by the next level if it reaches $ 1000 and so on.
    please help me out in this issue

    Hello Arif Mansuri
    thanks for your reply, yes I have taken it as total value only. The scenario is I am asked to use three different characteristics ( total value, materials, MRP Controller) and assign them to a class and if the customer picks any number of different materials and if the price is more than 1000 then it has to reach to the next level for approval. i thought i am suppose to use object dependencies here......... can we do this in a normal release order if so how would be the strategy played here?
    thanks for your time

  • Finding fields having different values

    Hi
    There are two internal tables with same structures, each holding single record. However, the values of those records are different.
    I need to find out the fields in which the values are different.
    How can I perform this.
    Could any one help?
    Thanks
    Divya

    Hello Divya
    You could do a field-by-field comparison, e.g.:
    " Read single record of each itab into work area
    FIELD-SYMBOLS:
      <ld_fld1>   TYPE ANY,
      <ld_fld2>   TYPE ANY.
    DO.
      ASSIGN COMPONENT syst-index OF STRUCTURE ls_record1 TO <ld_fld1>.
      ASSIGN COMPONENT syst-index OF STRUCTURE ls_record2 TO <ld_fld2>.
      CHECK ( syst-subrc = 0 ).  " assign worked
      IF ( <ld_fld1> NE <ld_fld2 ).
      ENDIF.
    ENDDO.
    Or you may use a more generic approach which will work for all records of itabs having the same structure. This approach gives you new, modified and deleted records: [Comparing Two Internal Tables - A Generic Approach|https://wiki.sdn.sap.com/wiki/display/Snippets/ComparingTwoInternalTables-AGeneric+Approach]
    Regards
      Uwe

  • Updating a JTable with an array of values

    Ther is a constructor that allows for the cretion of the table with an iniital array of values. However subsequent updates of blocks of data- say you received an array of updated data form a database- reuiqre you to update ince cell at a time. Is ther any way fo updating a whole block at once. I should point out that I am asking this because I am using JTables in the Matlab programming environment where arrays are the basic unit and looping through is a comparatively slow process

    Yes, you can extend the AbstractTableModel and write a method for updating a whole block.
    lets say you've got a Vector with Float[] arrays as elements to hold a 2D array of Float. The you could write:
          TableModel dataModel = new AbstractTableModel() {
                public int getColumnCount() { return col_names.size(); }
                public int getRowCount() { return data.size();}
                public Object getValueAt(int row, int col) {
                   return ((Float)((Float[])data.elementAt(row))[col]).toString();
                public String getColumnName(int col) {
                 return ((String)col_names.elementAt(col));
                public Class getColumnClass(int col) {
                 return String.class;
                public boolean isCellEditable(int row, int col) {
                  return true;
                public void setValueAt(Object aValue, int row, int col) {
                   try {
                     Float fv = Float.valueOf((String)aValue);
                    ((Float[])data.elementAt(row))[col] = fv;
                   } catch (Exception ex) {
                public void setBlock(Float block[][], int row, int col) {
                   // copy the Arrays with System.arrayCopy into data
          };PS: I don't know, if the above is correct written, havn't test this. But I hope you can recognize the idea behind it.
    wami

  • GR having different values for same quanitity

    Hi All,
        We have a Scheduling Agreement for which different GRs are posted through Inbound Delivery. The problem is, for two different GRs which were posted on the same day(for diifferent batches) having the same quanity, the GR values are different at decimal places. ie. 0.01 EUR difference.
    Scheduling Agreement : Target Qty - 326,700.000ST ;   143.35 EUR per 1000ST
    Quantiy
    Amount
    Goods Receipt 1
    7425 ST
    1064.37 EUR
    Goods Receipt 2
    7425 ST
    1064.38 EUR
    So, here, the actual amount should be 1064.37EUR (7425 x 0.14325 = 1064.37375) after roundong off to two decimal places.
    Please suggest. Thanks in advance.
    Regards,
    Rosh

    Hi,
    This will happen due to small difference of exchange rate even though there is not changes applied to exchange rate in system.
    The un-expected exchange rate difference posted during GRN is very well explained in below KBA.
    The KBA explains the real situation why this difference are caused and corresponding way to handle this type of situation.
    KBA:  1686557 - Unexpected exchange rate difference during goods receipt
    Rgds,

  • JList with items having different fonts

    Hi,
    Does anyone know how I can create a list of items, and have some of them shown in bold?
    JList only uses the one font for all its items.
    Regards,
    Paul

    To pass font info to the renderer you have 2 choises:
    1) extend JList, so that your one has some property defining the font (based on the index) and a render using it (like a Vector<Font>)
    2) put objects of a specific complex type in the list, each containing the label and the font; having the render (extending the default one) like +if (instanceof myType){ ... } else return super.getListCellComponent...+ (or whatever the name of the method, I don't remember)
    One last thing: defaultRenderer returns JLabels so you can use html in it. I guess you can use default renderer populating list with strings like +<html><font ..>value+. This only works fine if the index is self-explanatory in your logic, otherwise losing logic, plus the effort to 'extract' the actual info from formatted html value, aren't worth having not to write a very simple renderer.
    Bye.

  • JTable with row header plus value extraction from headers

    Hi, I am trying to do the following:
    Short Version-
    1. Create a table that has both row and column headers
    2. Allow the user to mouse over any of these headers such that doing so will display an image I have produced on a panel. (I already know how to create the image and how to display it, I'm just not sure how to associate it with a particular row or column header)
    3. Make the row headers look as much as possible like the column headers.
    Slightly Longer Version-
    Column headers will be labled A-H (maximum) while row headers will be labled 1-12 (maximum). Either can be less, however, depending on user input. After the table has been realized, the user will move the mouse over say, header 'H' and when they do, a JPEG image will appear on another panel and a tooltip will appear above the cell showing a formula. This happens when either row or column headers are moused over.
    Currently, I am using the following code from the O'reilly Swing book as a baseline for experimentation but any help you can offer will be appreciated. I'm fairly new to the JTable world... :-(
    TableModel tm = new AbstractTableModel(){
                   String data[] = {"", "a", "b", "c", "d", "e"};
                   String headers [] = {"Row #", "Column1", "Column2", "Column3", "Column4", "Column5"};
                   public int getColumnCount(){ return data.length;}
                   public int getRowCount() { return 1000;}
                   public String getColumnName(int col){ return headers[col];}
                   public Object getValueAt(int row, int col){
                        return data[col] + row;
              //creates a column model for the main table. This model ignores the first
              //column added and sets a minimum width of 150 pixels for all others
              TableColumnModel cm = new DefaultTableColumnModel(){
                   boolean first = true;
                   public void addColumn(TableColumn tc){
                        if(first) {first = false; return;}
                        tc.setMinWidth(150);
                        super.addColumn(tc);
              //Creates a column model that will serve as the row header table. This model
              //picks a maxium width and stores only the first column
              TableColumnModel rowHeaderModel = new DefaultTableColumnModel(){
                   boolean first = true;
                   public void addColumn(TableColumn tc){
                        if(first) {
                             tc.setMaxWidth(tc.getPreferredWidth());
                             super.addColumn(tc);
                             first = false;
              JTable grid = new JTable(tm, cm);
              //set up the header column and hook it up to everything
              JTable headerColumn = new JTable(tm, rowHeaderModel);
              grid.createDefaultColumnsFromModel();
              headerColumn.createDefaultColumnsFromModel();
              //make sure the selection between the main table and the header stay in sync
              grid.setSelectionModel(headerColumn.getSelectionModel());
              headerColumn.setBorder(BorderFactory.createEtchedBorder());
              headerColumn.setBackground(Color.lightGray);
              headerColumn.setColumnSelectionAllowed(false);
              headerColumn.setCellSelectionEnabled(false);
              JViewport jv = new JViewport();
              jv.setView(headerColumn);
              jv.setPreferredSize(headerColumn.getMaximumSize());
              //to make the table scroll properly
              grid.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
              //have to manually attach row headers but after that, the scroll pane
              //keeps them in sync
              JScrollPane jsp = new JScrollPane(grid);
              jsp.setRowHeader(jv);
              jsp.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, headerColumn.getTableHeader());
              gridPanel.add(jsp, BorderLayout.NORTH);

    There a number of nice examples on JTable: http://www.senun.com/Left/Programming/Java_old/Examples_swing/SwingExamples.html
    Hope you could find something suitable ...
    Regards,
    Anton.

  • SBS profiles with Pcs having different version of office

    Hi.
    Have a situation , where we want to alter all the user profiles to run from our SBS2011 Server.
    We have 15 PC's - But have 18users. Some of our users are part time , so not are all there at the same time. They want to Hot Desk ..
    All are Running Windows 7 (64 bit).
    We have 12 Machines running Office 2010
    But we have just purchased 3 new ones, which have got Office 2013.
    I can see a situation where a User will log on with an older machine ,(with Office 2010 installed) one day - then logon to one of the newer machines (with office2013 installed), at some time in the future.
    I wonder how the server profle will be able to handle this ?
    Any suggestions
    Thank You
    Jim
    Jim

    Hi Tris.
    Thank you for coming back- appreciated.
    The issue is the path from where Office runs.
    I have set up a test system , using Office 2010 and Office 2007
    I setup 2 machines - both with Win 7
    Machine 1 has Office 2007
    Machine 2 had Office 2010
    I would like to be able to put shortcuts on the Desktop / or Pin to the taskbar the office programs- Excel , Word etc.
    However Office 2010 - runs from c:\program files\microsoft office\office14
    Where as Office 20007 runs from  c:\program Files\microsoft office\Office12
    If I logon to Machine 1 and Put either a shortcut or Pin the app to the task bar, for say Word, when I log on to Machine 2 - The Shortcut/ Taskbar  Word - has an "invalid" error.
    Which is understandable as it it trying to load a program whuich is not installed on that machine.
    Thats my problem..
    Im sure there must be a solution - But I cant think of a way around it.
    Hopefully somebody can.
    Thanks again.
    Regards
    Jim
    Jim

  • Aperture shot is recorded at different values in output file

    Dear Lens users,
    Please explain why the aperture values which I used in my images for my sets that I used to profile my lenses, are showing up in the output data, in the .LCP file, as having different values. For instance, at f2.8 which I used for several lens image sets, the aperture value is listed as "2.970854" and not as 2.8. Likewise for my shot aperture of f8, the aperture value listed in the output .LCP file is 6.00000.
    There must be some technical explanation of why the apertures shown on the aperture ring(when there is one) or camera screen, traditional apertures thought of as f2.8, f4, f5.6, etc., are stated within the data files as other values, close but not the same.
    Thanks, Debra

    Thank you phototrek and T.Phanngam.
    I do not see the value "FNumber" in any of my profile .LCP Files, unfortunately, I only see only the ApertureValue(I also used "Search" for "FNumber").
    T.Phanngam - thanks very much for the pdf file on the technical white paper on the Lens Profile Creator - I have not seen this document before. I am printing it to read it thoroughly.
    Thanks to both for replies,
    Debra

  • [svn:bz-trunk] 13716: since include-read-only is a server global setting, we can't have two channels with different value.

    Revision: 13716
    Revision: 13716
    Author:   [email protected]
    Date:     2010-01-22 09:26:12 -0800 (Fri, 22 Jan 2010)
    Log Message:
    since include-read-only is a server global setting, we can't have two channels with different value.  remove the test for the include-read-only false.  update the service-config.xml as well.
    Modified Paths:
        blazeds/trunk/qa/apps/qa-regress/WEB-INF/flex/services-config.mods.xml
        blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/remotingService/dataTypes/ReadOn lyTest.mxml

    You can give this a try on your Ultimate machine.  While these are said to be for Vista, I used it on my Win 7 machine just fine and it fixed the problems I was having.  Hope it works for you.
    The problem is that Vista, by default, will only use NTLMv2 for authentication, which is not supported by Mac OS X's Windows Sharing service.
    The other problem is the Minimum Session Security for NTVLM SSP based Clients.
    To get around this:
    1.     In Vista, open the Control Panel
    2.     Switch to "Classic" view
    3.     Double-click Administration Tools
    4.     Double-click Local Security Policy
    5.     Or Secpol.msc
    6.     Expand "Local Policies" and select "Security Options"
    7.     Alternate : Type secpol.msc to get editor up then
    8.     Locate "Network Security: LAN Manager Authentication Level" in the list and double-click it.
    9.     Change the setting from "Send NTMLv2 response only" to "Send LM & NTLM - use NTLMv2 session if negotiated"
    10.     Network Security: Minimum session security for NTLM SSP Based (including secure RPC) Clients
    11.     Change the setting from "require 128 bit" to unchecked (No Minimum)
    12.     Click OK
    the real difference between vista and windows 7 procedure is 10 and 11

  • One jsp one form tag having 3 different values

    <tr>
    <td width="120%" align="right" bgcolor="#FFFFFF" colspan="4" >
    <input type="submit" value="Submit" name="Submit">
    <input type="submit" value="Delete" name="Delete">
    <input type="submit" value="Approve" name="Approve">
    </td>
    </tr>
    In Jsp have one form having 3 button with 3 different values.
    My problem is on 3 button have 3 different action called.
    i face this problem very curisal.
    So plz give me reply its very urgent
    Thanks in Advance

    Do it with javascript.
    Rather than: <input type="submit" value="Submit" name="Submit"> use a <input type="button" name="submit" value="Submit" onclick="checkClick();" />
    Then your javascript function - "checkClick" and set an indicator as to which button was clicked and then invoke the submit function.

  • PDF for multiple users with different values

    Is there a way to create a PDF to be sent to multiple users but have different values in the PDF? For expample employee A's offer letter is for $50/hour while employee B's offer letter is for $55/hour. But they have the same offer letter just with different values.
    I have Enterprise EchoSign and FormsCentral.
    Thank you!

    Hi,
    Thanks for asking, but FormsCentral currently does not support this.
    Perry

  • Mass changes of Material Master field with different values

    Hi,
    How to change a field in Material Master for more than thousand materials. I think MM17 can only be used for mass changes of materials with same values. I need to upload different values for different materials. Is there any other way to do this.
    Thanks,
    K R Vishnu Kumar

    Hi Kumar.
    I think you have to use LSMW for mass updation for Material Master fields with different values.
    Regards,
    Rahul.

Maybe you are looking for

  • Itunes was not installed correctly Error 7 (Windos error 998)

    Hello, has anyone an idea to assist. Can't get rid of the problem with itunes 11.0.4.4. Quick Time works properly. Tried to repair as well as uninstall and install again. Messages remains at start of itunes. Your assistance will be appreciated very m

  • Table link between contract document and billing document

    Hi, Please let me know the table link between contract data and its billing plan nnumber. Regards, bhaarathi.

  • Delay in loading web pages using wireless after 10.5.6 update.

    I've read the posts for the 10.5.5 updates, but I have been recently experiencing this problem after updating to 10.5.6. It is seemingly a DNS problem because of the delay in "Looking up" and "Waiting for" in Firefox, but I do not have DNSchanger tro

  • BPM - Interact with external system

    Hi Experts, We are implementing a project with BPM Suite Version 1.1.1.6 (PS5). A requirement is the following things:   - The BPM process begins through a human task.   - Upon completion of the human task, the flow must interact asynchronously with

  • Not Prompting for Parameters in .jsp page

    Post Author: montgomm CA Forum: General We have defined an input parameter to our report and it will successfully prompt for the input parameter within the designer preview.  However, once we build a .jsp page to contain the report and load it to our