Setting JcomboBox editor for a table cell

Hi,
I have a ComboBox editor for a cell in my table. I want to set this editor depending on the value of another column
qualifierTable.addMouseListener(new MouseAdapter(){
   public void mouseClicked(MouseEvent e){
    int selRow = qualifierTable.getSelectedRow();
    int selCol = qualifierTable.getSelectedColumn();
   if (someCondition)
            JComboBox comboBoxEditor = new JComboBox();
            comboBoxEditor.addItem("Private");
             comboBoxEditor.addItem("Protected");
             comboBoxEditor.addItem("Public");
             qualDataValueCol.setCellEditor(new DefaultCellEditor(comboBoxEditor));
             Object dataValue = comboBoxEditor.getSelectedItem();
                                      if (dataValue!= null)
             {                              qualifierTablemodel.setValueAt(dataValue, selRow, selCol);
}The problem is this sets the editor for all cells in the column. However I want the editor to revert to JTextField if this condition is not met. Where should I set it back. It does not work if I set it in the else part

Override the getCellEditor(...) method to return the appropriate editor. Something like this:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=637581

Similar Messages

  • How to set DDL lock for a table

    OCI,how to set DDL lock for a table?

    Oracle acquires a dictionary lock automatically on behalf of any DDL transaction requiring it. Users cannot explicitly request DDL locks. Only individual schema objects that are modified or referenced are locked during DDL operations. The whole data dictionary is never locked
    DDL locks fall into three categories: exclusive DDL locks, share DDL locks, and breakable parse locks.
    see this link
    http://www.sc.ehu.es/siwebso/KZCC/Oracle_10g_Documentacion/server.101/b10743/consist.htm#i5281

  • Setting icons in a JLabel table cell renderer

    I am using a JLabel as a renderer for one of the columns in a JTable
    Within the renderer class I use the following code to set the icon on the label. The icon is decided on the information for that particular cell which is held in the table model.
    <CODE>
    URL url = c.getResource("/images/icon.gif");
    this.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().getImage(url)));
    <CODE>
    When the icon gets set for one renderer it gets set for all other renderers as well. This does not happen when I set the text on one of the JLabel renderers.
    How can I make it so that the icon only gets changes for one of the renderers.

    You need to put this code into the getTableCellRendererComponent method. You should probably store all the possible icons at the class level otherwise you might end up loading an image each time a cell is rendered:
    public class MyTableCellRenderer extends DefaultTableCellRenderer
      protected Icon icon1;
      protected Icon icon2;
      protected Icon icon3;
      public MyTableCellRenderer()
        icon1 = new ImageIcon(c.getResource("/images/icon1.gif"));
        icon2 = new ImageIcon(c.getResource("/images/icon2.gif"));
        icon3 = new ImageIcon(c.getResource("/images/icon3.gif"));
      public Component getTableCellRendererComponent(...)
        if(...)
          setIcon(icon1);
        else if(...)
          setIcon(icon2);
        else if(...)
          setIcon(icon3);
        else
          setIcon(null);
        return super.getTableCellRendererComponent(...);
    }Hope this helps.

  • How to set title/text for ALV table column header in WD ABAP

    Hello,
    I am working in WDA using SALV_WD_Table to display data in table. I need to change the column header text, the obvious way is to get the column header and call the method SET_TEXT to set new text / title. However, this method does NOT work, it does not change the column header text. I also tried the SET_TOOLTIP, this one works, but SET_TEXT does not work. Anyone has idea why this not working and do you find any go-around solution?
    My version is NW 7.0
    Thank
    Jayson

    Hi jason ,
    For setting Heder text for your ALV table
    ip_confing type ref to CL_SALV_WD_CONFIG_TABLE.
    "set alv table header
      ip_config->if_salv_wd_table_settings~r_header->set_text( 'Test ALV Header functionality' ).
    first you have to hide the DDIC text and then try to set your own text .
    "modify columns
      LOOP AT lt_columns INTO ls_column.
        lr_column = ls_column-r_column.
        CASE ls_column-id.
          WHEN 'MANDT'.
            "hide this field
            lr_column->set_visible( cl_wd_abstr_table_column=>e_visible-none ).
           WHEN 'SEQNR'.
            "set header to different string
            lr_column->r_header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none )." use this line to hide ddic text
            lr_column->r_header->set_text( 'Position' ).     
        endcase.
      endloop.
    Regards
    Chinnaiya P

  • Set Attached File name to Table Cell

    Hello All,
    I have a scenario where:
    1. I have a dynamic table.
    2.Every Row has a Button for attaching the new File.
    3. When we add new Row to the Table, I want to get the attached file name in the corresponding cell. i.e Cell2 in following example.
    I have tried doing it this way
    The script which I'm using on Add button is
    app.execMenuItem(&quot;AddFileAttachment&quot;);
    var o = event.target.dataObjects;
    var n = &quot;&quot;;
    DataNode.Table1.Row1.Cell2.rawValue = &quot;&quot;;
    if (o !== null) {
              for (var i = 0; i < o.length; i += 1) {
                        n = o[this.parent.index].name;
    var countVal = (DataNode.Table1.Row1.instanceManager.count-1);
    xfa.resolveNode(&quot;DataNode.Table1.Row1[&quot;+countVal+&quot;].Cell2&quot;).rawValue = n;
      But I'm not able to display the attached file name in Cell2 of the Table.
    How can we do it?
    Thanks and Regards,
    Nikhil

    Hello All,
    I even tried doing the same using  http://eslifeline.wordpress.com/2009/04/06/adding-attachments-to-pdf-form/
    But I'm not able to add the file name to the table cell.
    Can anyone please guide me through this?
    Thanks and Regards,
    Nikhil Joshi

  • How Shall I programatically set  VO's  for Advanced Table?

    I have Advanced Table which display data from 3 different table under certain conditions.
    These 3 tables having same columns but different data.
    Here I have defined 3 VOs for this 3 tables.
    Now I want to programatically configure this VO to Advanced Table.
    Also...How shall i set View Attribute for Column in Advanced Table.
    I have written following code..but that didnt work...it is in processRequest()
    OAAdvancedTableBean tableBean = (OAAdvancedTableBean) webBean.findChildRecursive("SampleTable");
    if (tableBean!=null)
    System.out.println("Table Bean is Not Null");
    tableBean.prepareForRendering(pageContext);
    tableBean.setViewUsageName("EMCOpptyLevel1DataVO"); //EMCOpptyLevel1DataVO is name of VO
    OAMessageTextInputBean hours = (OAMessageTextInputBean)tableBean.findIndexedChildRecursive("hours1");
    hours.setViewUsageName("EMCOpptyLevel1DataVO");
    hours.setViewAttributeName("Hours");
    am.invokeMethod("initialize");// This will execute query on EMCOpptyLevel1DataVO
    }

    We have done it in the follwoing way. I have created one VO and this was with qry "select a,b from tab1;"
    I have written an public initialize(int condition){} method in VOImpl class. In the initialize method I used to change the qry of the VO something like this
    public initialize(int condition){
    if condition = 1
         setqry("select a,b from tab1");
         setFullSqlMode(FULLSQL_MODE_AUGMENTATION);
    if condition = 2
         setqry("select a,b from tab2");
         setFullSqlMode(FULLSQL_MODE_AUGMENTATION);
    Basically, I was using only one VO, but changing the qry on the VO dynamically depending on the condition. Depending on the condition I initialize my VO appropriately.

  • Stop looking for similar table cells

    How do I get Pages to stop displaying a drop down list with similar text every time I try to enter text into Table cells. I'm logging video interviews so every time I type a question is usually starts with What or why and I have to wait for Pages to display every sentence I've typed into the cells that started with What or Why? What is the deal??

    Welcome to Apple Discussions
    Go to Pages > Preferences > General & uncheck "Show auto-completion list" (it's at the bottom of the third section of the preferences).

  • Tutorial for hyperlinking table cell

    Anyone know where i might find a tutorial. Google bringing up
    nothing
    I want to be able to hyperlink table cells and change table
    cell background
    color on mouse over etc.
    I am really struggling with this therefore need a tutorial
    TIA

    Why do you need to hyperlink the *cell*?
    If you put a normal hyperlink in the cell, and use CSS to
    make that <a> tag
    display:block, then it will fill the cell, and make the whole
    thing
    clickable. Further it allows you to use the pseudo-class of
    a:hover to
    change the background color....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Andrew" <[email protected]> wrote in message
    news:e7bgvq$eog$[email protected]..
    > Anyone know where i might find a tutorial. Google
    bringing up nothing
    >
    > I want to be able to hyperlink table cells and change
    table cell
    > background color on mouse over etc.
    >
    > I am really struggling with this therefore need a
    tutorial
    >
    > TIA
    >

  • Customized JComboBox Editor for JTable

    Hi,
    I am new to swing development and have gotten my self stuck on an issue. Basically I have a JTable that is dynamically populated from the database, in which one of the columns has a customized JComboBox Renderer and Editor. The default values load up fine when the page loads up but when I selected a new value in the combo box and select a new row in the JTable, the combo box defaults back to the original value. How can I make sure that the new selection is maintain.
    Thanks, Anthony
    Here are my Driver, Renderer and Editor:
    excerpts from the Driver
    contract.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    keys = contractSelectedEvent.getKeys();
    String sql = contractSelectedEvent.getSchdSql(keys);
    table = contractSelectedEvent.getStatusTable(sql);
    table.setDefaultRenderer(CashFlow.class, new CashFlowRenderer());
    table.setDefaultEditor(CashFlow.class, new CashFlowEditor());
    public class CashFlowRenderer extends JComboBox implements TableCellRenderer {
    protected QueryComboBoxModel comboModel;
    /** Creates a new instance of CashFlowRenderer */
    public CashFlowRenderer() {
    super();
    comboModel = new QueryComboBoxModel("Select Ref_ID, Ref_Desc From Ref Where
    Ref_Typ_ID = 910 order by Ref_ID ");
    super.setModel(comboModel);
    public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row,
    int column) {
    if(value == null) {
    return this;
    if(value instanceof CashFlow) {
    //set the cashflow equal to the value
    CashFlow cashFlow = new CashFlow(((CashFlow) value).getCashFlow());
    setSelectedItem(cashFlow);
    else {
    //default the cashflow
    CashFlow cashFlow = new CashFlow();
    setSelectedItem(cashFlow.getCashFlow());
    return this;
    public boolean isCellEditable() {
    return true;
    public class CashFlowEditor extends JComboBox implements TableCellEditor {
    protected transient Vector listeners;
    protected transient String originalValue;
    protected QueryComboBoxModel comboModel;
    /** Creates new CashFlowEditor */
    public CashFlowEditor() {
    super();
    comboModel = new QueryComboBoxModel("Select Ref_ID, Ref_Desc From Ref Where Ref_Typ_ID = 910 order by Ref_ID ");
    super.setModel(comboModel);
    listeners = new Vector();
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    if(value == null) {
    return this;
    if (value instanceof CashFlow) {
    setSelectedItem(((CashFlow)value).getCashFlow());
    else {
    CashFlow cashFlow = new CashFlow();
    setSelectedItem(cashFlow.getCashFlow());
    table.setRowSelectionInterval(row, row);
    table.setColumnSelectionInterval(column, column);
    originalValue = (String) getSelectedItem();
    return this;
    public void cancelCellEditing() {
    fireEditingCanceled();
    public Object getCellEditorValue() {
    return (String)getSelectedItem();
    public boolean isCellEditable(EventObject eo) {
    return true;
    public boolean shouldSelectCell(EventObject eo) {
    return true;
    public boolean stopCellEditing() {
    CashFlow cashflow = new CashFlow((String)getSelectedItem());
    setSelectedItem(cashflow.getCashFlow());
    fireEditingStopped();
    return true;
    public void addCellEditorListener(CellEditorListener cel) {
    listeners.addElement(cel);
    public void removeCellEditorListener(CellEditorListener cel) {
    listeners.removeElement(cel);
    protected void fireEditingCanceled() {
    setSelectedItem(originalValue);
    ChangeEvent ce = new ChangeEvent(this);
    for(int i = listeners.size(); i >= 0; i--) {
    ((CellEditorListener)listeners.elementAt(i)).editingCanceled(ce);
    protected void fireEditingStopped() {
    ChangeEvent ce = new ChangeEvent(this);
    for(int i = listeners.size() - 1; i >= 0; i--) {
    ((CellEditorListener)listeners.elementAt(i)).editingStopped(ce);

    First off, I wouldn't subclass JComboBox to create a custom renderer/editor. I would have a renderer/editor component that makes use of a JComboBox. But that is just me.
    In order for setSelectedItem to work, the items in your combo box have to compare against each other correctly with equals(). Since you are creating new instances, your objects (even though they contain the same data) are going to be different instances and aren't going to be considered equal. Write your own equals() method in your CashFlow object that tests for equality based on the actual values in the objects and you should be fine.

  • How do I set column width for a table?

    I want to set the same width for all the columns in a particular table. Is there anyway of doing this without having to actually manually adjust each individual column?
    Thanks

    Select the column headers and drag across (A,B,C for example) then select between one of the columns (your pointer will change shape). Select and drag to the new width. All selected columns will change.
    Regards,

  • Setting a default for the Table Headings

    Hi all,
    the users are asking me if it's possible to set in the Table View of Answer the Display Column & Table Headings = As Table.Column as default. This option can be found in the Table View Properties and you can set the value just for the current request...
    Is there a way to set a default value for this option for all the requests?
    Thanks in advance.
    Nazza

    it's stupid, but it works in 9 & 10. probably v8 also, but I can't remember that far back. and it might not work in future releases.
    add this to the top of your script:
    set termout off echo off feed off pages 0 timing off verify off
    rem Determine if parameter 1 is defined. If not, default to "XXX"
    spool temp1.sql
    select 'select decode(instr(''-' from dual;
    def 1
    select ''',''symbol 1 is UNDEFINED''||chr(10)),0,''rem fine'',''define 1 = XXX'') from dual;' from dual;
    spool off
    spool temp2.sql
    @temp1
    spool off
    @temp2
    set termout on
    put your code here
    and of course, it leaves two files (temp1 and temp2) in the current directory. so, you can add o/s dependent delete statements via a host command. or just leave them. you're call.
    Message was edited by:
    shoblock
    forgot the "set" commands at the top
    AND...
    set termout back on at the end (along with echo or whatever else you want).
    and I changed from defaulting &1 to a value of "1", to a value of "XXX". should make it easier to follow (I hope).
    and finally, thanks to Ron who helped me figure this one out (many years ago)

  • How to set single parameters for two tables?

    SELECT GM.GRNNO,GM.GRNDATE,SUM(GS.APPROVED),SM.ISSUENO,SM.ISSUEDATE,GS.ITEMCODE,SUM(SS.ISSUEDQTY)
    FROM IMS_GRNM GM,IMS_GRNS GS, IMS_ISSUEM SM, IMS_ISSUES SS
    WHERE GM.GRNMSERIAL=GS.GRNSSERIAL
    AND SM.ISSUEMSERIAL=SS.ISSUESSERIAL
    AND GM.POSTED='T'
    AND SM.POSTED='T'
    AND GS.ITEMCODE=SS.ITEMCODE
    AND GS.ITEMCODE='01-01-02-019'
    AND *******
    GROUP BY GM.GRNNO,SM.ISSUENO,GM.GRNDATE,SM.ISSUEDATE,
    GS.ITEMCODE ORDER BY GM.GRNDATE,SM.ISSUEDATE;
    ******* here i have to select the data from both the tables between two parameters named :P_1 and :P_2.
    the date column in IMS_GRNM is named as GRNDATE.
    the date column in IMS_ISSUEM is named as ISSUEDATE.
    how to set such parameters???

    I think all you need is
    Where table1.column1 between :p1 and :p2
    and table2.column2 between :p1 and :p2

  • TM2-1100: Unable to set default rotation for slate/tabl​et mode

    I have a brand new TM2 Tablet (2nd Generation).
    When I put the screen into tablet/slate mode the display DOES automatically rotate, but it rotates 180 degrees, landscape rather than potrait.
    I can press the bezel rotate button 4 times to eventually get it to the proper potrait orientation, but I have owned several other tablets and never had to do this... They always either rotated to portrait (90 or 270 degrees) automatically or allowed me to set how it would rotate when put in tablet/slate mode.
    Googling this rotation issue found many similar complaints, even by major industry reviews of the TM2. Some people on the 1st generation TM2 were able to correct this by installing older HP Quick Launch Button software and changing the registery settings, but the second generation TM2 does not use that HP Quick Launch Button software.
    I called HP and they basically said it was working as designed.
    Has anyone found a solution to this? Granted, it's not a show-stopper but it is very annoying and it is basic tablet functionality that should work.
    Thanks.

    Same problem on my TM2-2150.  not even 2 months old and already things are quitting.  
    The workaround I  did that makes me less unhappy is as follows.
    1. Check the intel video drivers for the screen orrientation hot-keys.  Mine are Ctrl-Alt-Arrow (direct to top of screen)
    2. Enable Penflicks in all directions
    3. Pick the screen orientation you want to use in tablet mode.  ( Mine turns the screen clockwise)
    4. Change one of the directional pen-flicks to a custom key command coresponding to the keyboard shortcut to change screen orientation.
    5. Change the directional 90 degrees away (anti-clockwise in my case) to the key command to revert the screen back.
    now the direction you picked on the screen toggles the orientation of the screen between landscape and tablet mode.  It's not ideal, but it is workable.

  • How to show note window for a table cell with javascript?

    My goal is to do tihs with javascript. No server side handling.
    <af:table id="t1">
    <af:column id="c1">
    <af:outputText id="ot1">....
    <af:clientListner ....method="showPopup"/>
    </..>
    </..>
    </..>
    <af:popup id="p1">
    <af:noteWindow id=ot2>
    here to show the value of ot1
    </..>
    </..>
    function showPopup(e){
    var text=e.getSource().getValue();
    var popup=e.getSource().findComponent("::p1");
    now how to update the content of the notewindow??
    popup.show();
    }

    Hi,
    You could try with something like this.
                   <af:outputText value="outputText1" id="ot1" clientComponent="true">
                        <af:clientListener method="showPopup" type="mouseOver"/>
                    </af:outputText>
                    <af:popup childCreation="immediate" autoCancel="disabled" id="p1" clientComponent="true"
                              contentDelivery="immediate">               
                        <af:noteWindow id="nw1" clientComponent="true">
                            <af:outputText value="outputText2" id="ot2" clientComponent="true" />
                        </af:noteWindow>
                    </af:popup>
                    <af:resource type="javascript">
                        function showPopup(evt){
                            var ot1 = AdfPage.PAGE.findComponent("ot1");
                            var text=ot1.getValue();
                            var popup=AdfPage.PAGE.findComponent("p1");
                            var ot2=AdfPage.PAGE.findComponent("ot2");
                            ot2.setValue(text);
                            popup.show();
                    </af:resource>-Arun

  • Script for setting Imported Excel Table Cell Inset

    InDesign CS3 Windows XP
    I've checked the FAQ and ran all the searches, but I can't find this. My old computer crashed and took with it a script that I had that would set all the cell insets for the cells of the imported Excel tables in one swelled foop. Can someone point me to the source again? My price sheets are nothing but imported Excel tables and it takes forever to set all the insets for each block separately.
    Thanks,
    JAG

    Phah.
    app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem().propert ies = [topInset:"1cm"]; //??
    This one-liner may need some additional work, but when I am done with it, it'll set the insets for all tables in every open document.
    Perhaps 'everyItem' also works on disk files ...
    [Edit] Just pulling your leg. I'll take a look on the one-liner when I'm back at work.
    I've got a class in a couple of weeks on Javascripting ...
    I'm jealous. They give classes about this? BTW, JavaScript is not that hard (e.g., not harder than any other reasonably popular programming language), but its interface to InDesign is something else. In this case, the magic word is 'everyItem'. (You'll learn.)

Maybe you are looking for

  • My Screensaver no longer works

    Hello. My Screensaver no longer works I choose - change desktop background, nothing happens! I choose "System Preferences - Display," I can not see all the beautiful flowers and other beautiful backgrounds. Hoping for help.

  • Lumia 1020 is not seen by Windows 7 64-bit

    Hi, When I connect my new Nokai Lumia 1020 to USB, my PC (which is Windows 7 64-bit Ultimate) is not able to install the correct driver. When I connec the mobile, Windows installs driver for a device named as "RM-875|Nokia 909". It then says " There

  • How to download adobe digital editions to my iPad?

    How do I download books in adobe digital editions from my computer to my iPad? 

  • Lost embedded images in emails

    IOS 8.1, I used to create draft emails in gmail with embedded images. Once complete, I'd change sending email account to work Exchange server account and send email. However embedded images often disappear - they are no in receiving email - they are

  • Sun java vs. microsoft java

    I need to know what the difference is between the two of these. And some good places to find info regarding this topic? I need to know differences, similarities, and what each is better suited for. I don't need this for a specific op sys but i need t