JComboBox with checkboxes - how to ?

How can I implement a JComboBox with JChecBoxes as elements ?

my first guess:
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JCheckBox;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
public class CheckListCellRenderer extends JCheckBox implements
        ListCellRenderer {
    public CheckListCellRenderer() {
        setLayout(new BorderLayout());
    public Component getListCellRendererComponent(JList list, Object value,
            int index, boolean isSelected, boolean cellHasFocus) {
        return (Component) value;
}The problem is the checkboxes are not editable....

Similar Messages

  • Editable ALV with checkbox, how to use on_change event

    Hi experts,
    I used an editable  ALV. In firs collumn I Used an cell editor checkbox (cl_salv_wd_uie_checkbox). I neet to react on each click on each checkbox in order to do some actions in context, that is not part (mapped) to ALV.
    There are IF_SALV_WD_CONFIG~CHANGED event in checkbox class. Is it possible to use (and how) this event for my task ? Any example ?...
    Thanks, Gabriel

    Hi Gabriel,
    Try uisng ON_DATA_CHECK event.
    Create a method and assign the above mentioned event. In the method have the folleoing code.
    FIELD-SYMBOLS: <l_value> TYPE ANY                           .
    Find the check box that has modified
      LOOP AT r_param->t_modified_cells INTO ls_modified_cell
        WHERE attribute EQ 'ATTRIBUTE NAME'.
        ASSIGN ls_modified_cell-r_value->* TO <l_value>           .
        CLEAR lv_index                                            .
        lv_index = ls_modified_cell-index                         .
      ENDLOOP  
    <l_value> should have the value. In your case X or space.
    You can also find index for that which is lv_index.
    So now you know the index so u know in which cell the check box is modified.
    Try that.
    Thank You,
    Gajendra.

  • How to handle multiple selection in the Spark List control with checkbox as itemrenderer?

    Hi All,
    I am using checkbox as an ItemRenderer in spark list.
    I have a query.
    how to handle multiple selection in the Spark List control with checkbox as itemrenderer?
    how to retrieve the selected item label?
    Thank you in advance.

    Hi there, I'll tweak your code a little bit to something like this:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical">
        <mx:Script>
            <![CDATA[
                 import mx.events.ListEvent;
                 import mx.controls.CheckBox;
               [Bindable]
               private var mySelectedIndexes:ArrayCollection=new ArrayCollection();
                private function onChange(e:ListEvent):void
                   if(CheckBox(e.itemRenderer).selected){
                             mySelectedIndexes.addItem(e.rowIndex);
                   }else{
                                  mySelectedIndexes.removeItemAt(mySelectedIndexes.getItemIndex(e.rowIndex));     
                   chkList.selectedIndices=mySelectedIndexes.toArray();
            ]]>
        </mx:Script>
    <mx:ArrayCollection id="collection">
            <mx:Object label="Test A"/>
            <mx:Object label="Test B"/>
            <mx:Object label="Test C"/>
            <mx:Object label="Test D"/>
            <mx:Object label="Test E"/>
            <mx:Object label="Test F"/>
            <mx:Object label="Test G"/>
        </mx:ArrayCollection>
    <mx:List id="chkList" dataProvider="{collection}" itemRenderer="mx.controls.CheckBox"  itemClick="onChange(event);" allowMultipleSelection="true"/>
    </mx:Application>

  • How to create a JComboBox with Dates???

    Hi... I need to create a JComboBox with Date elements...
    For example: from "Jan-01-2007" to "Mar-02-2007"
    Jan-01-2007
    Jan-02-2007
    Jan-03-2007
    Mar-01-2007
    Mar-02-2007
    Anyone know how to do it???
    Regards...

    //here is an example how to get the date
    //I think this might help you!!!
    import java.text.DateFormat;
    import java.util.Date;
    public class DateFormatExample1 {
        public static void main(String[] args) {
            // Make a new Date object. It will be initialized to the current time.
            Date now = new Date();
            // See what toString() returns
            System.out.println(" 1. " + now.toString());
            // Next, try the default DateFormat
            System.out.println(" 2. " + DateFormat.getInstance().format(now));
            // And the default time and date-time DateFormats
            System.out.println(" 3. " + DateFormat.getTimeInstance().format(now));
            System.out.println(" 4. " +
                DateFormat.getDateTimeInstance().format(now));
            // Next, try the short, medium and long variants of the
            // default time format
            System.out.println(" 5. " +
                DateFormat.getTimeInstance(DateFormat.SHORT).format(now));
            System.out.println(" 6. " +
                DateFormat.getTimeInstance(DateFormat.MEDIUM).format(now));
            System.out.println(" 7. " +
                DateFormat.getTimeInstance(DateFormat.LONG).format(now));
            // For the default date-time format, the length of both the
            // date and time elements can be specified. Here are some examples:
            System.out.println(" 8. " + DateFormat.getDateTimeInstance(
                DateFormat.SHORT, DateFormat.SHORT).format(now));
            System.out.println(" 9. " + DateFormat.getDateTimeInstance(
                DateFormat.MEDIUM, DateFormat.SHORT).format(now));
            System.out.println("10. " + DateFormat.getDateTimeInstance(
                DateFormat.LONG, DateFormat.LONG).format(now));
    }

  • How to work with checkbox in a table

    hi im working with a table than shows SQL result and i put a column with checkboxes in the table
    how can i handle the rows with the checkbox in true ? i want to do it with a button
    thanks

    Here are more resources. By the way, I don't understand what you mean by "how can i handle the rows with the checkbox in true ? i want to do it with a button "
    http://blogs.sun.com/roller/page/divas?entry=using_checkboxes_in_a_table
    http://blogs.sun.com/roller/page/divas?entry=table_component_sample_project

  • How can i populate the Jcombobox with the data from my jpa list? Desperate

    I need to populate my jcombobox with data from my jpa. This is my first time trying this and i just need some sample or a quick solution to this. Thanks in advance
    <code>
    public static MyNames myNames() {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("JavaTrialsPU");
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    Query q = em.createNamedQuery("MyNames.findAll");
    MyNames n = (MyNames) q.getResultList();
    return n;
    public static void myCombo() {       
    comboBox = new JComboBox(????--how can i make the jcombobox display my myNames() list--?????);
    frame.add(comboBox, BorderLayout.PAGE_START);
    </code>

    Implement toString() on your entity to return whatever you want to use as a label for the combobox.
    Your need for quick solutions is very destructive to your learning process. In stead take the time and read around a little. Swing happens to have an excellent tutorial with many example programs readily available for you to pick through:
    http://docs.oracle.com/javase/tutorial/uiswing/
    And PS: you need to use \ tags in this forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to find control,  jListBox with checkBoxs

    Hello Everyone
    Using Jclient/Swing application i want to use listbox with
    checkBoxs.
    Suppose listbox display list of items along with
    these checkboxs.And these checkbox varies according the
    items aviable in listbox.
    whether this type control available in jDeveloper or not.

    Thanks for reply !
    i found swing code for jListBox containing checkboxs.
    So how to use this class in Jdeveloper for using as
    a control.
    Please tell me suggetion?
    public class CheckBoxList extends JFrame
         protected JList m_list;
         //protected JLabel m_total;
         public CheckBoxList()
              super("Swing List [Check boxes]");
              setSize(360, 340);
              getContentPane().setLayout(new FlowLayout());
              InstallData[] options = {
              new InstallData("Program executable", 118),
              new InstallData("Help files", 52),
              new InstallData("Tools and converters", 83),
              new InstallData("Source code", 133),
              new InstallData("Project",147),
    new InstallData("Search",188),
    new InstallData("Edit",189),
    new InstallData("Girdher",3445)
              m_list = new JList(options);
              CheckListCellRenderer renderer = new CheckListCellRenderer();
              m_list.setCellRenderer(renderer);
              m_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              CheckListener lst = new CheckListener(this);
              m_list.addMouseListener(lst);
              m_list.addKeyListener(lst);
              JScrollPane ps = new JScrollPane();
              ps.getViewport().add(m_list);
    //          m_total = new JLabel("Space required: 0K");
              JPanel p = new JPanel();
              p.setLayout(new BorderLayout());
              p.add(ps, BorderLayout.CENTER);
         //p.add(m_total, BorderLayout.SOUTH);
              p.setBorder(new TitledBorder(new EtchedBorder(),
                   "Please select options:") );
              getContentPane().add(p);
              WindowListener wndCloser = new WindowAdapter()
                   public void windowClosing(WindowEvent e)
                        System.exit(0);
              addWindowListener(wndCloser);
              setVisible(true);
         //     recalcTotal();
    /*public void recalcTotal()
              ListModel model = m_list.getModel();
              int total = 0;
              for (int k=0; k < model.getSize(); k++)
                   InstallData data = (InstallData)model.getElementAt(k);
                   if (data.isSelected())
                        total += data.getSize();
              m_total.setText("Space required: "+total+"K");
         public static void main(String argv[])
              new CheckBoxList();
    class CheckListCellRenderer extends JCheckBox implements ListCellRenderer
         protected static Border m_noFocusBorder =
              new EmptyBorder(1, 1, 1, 1);
         public CheckListCellRenderer()
         super();
         setOpaque(true);
         setBorder(m_noFocusBorder);
         public Component getListCellRendererComponent(JList list,
              Object value, int index, boolean isSelected, boolean cellHasFocus)
              setText(value.toString());
              setBackground(isSelected ? list.getSelectionBackground() :
              list.getBackground());
              setForeground(isSelected ? list.getSelectionForeground() :
              list.getForeground());
              InstallData data = (InstallData)value;
              setSelected(data.isSelected());
              setFont(list.getFont());
              setBorder((cellHasFocus) ?
                   UIManager.getBorder("List.focusCellHighlightBorder")
                   : m_noFocusBorder);
              return this;
    class CheckListener implements MouseListener, KeyListener
         protected CheckBoxList m_parent;
         protected JList m_list;
         public CheckListener(CheckBoxList parent)
              m_parent = parent;
              m_list = parent.m_list;
         public void mouseClicked(MouseEvent e)
              if (e.getX() < 20)
                   doCheck();
         public void mousePressed(MouseEvent e) {}
         public void mouseReleased(MouseEvent e) {}
         public void mouseEntered(MouseEvent e) {}
         public void mouseExited(MouseEvent e) {}
         public void keyPressed(KeyEvent e)
              if (e.getKeyChar() == ' ')
                   doCheck();
         public void keyTyped(KeyEvent e) {}
         public void keyReleased(KeyEvent e) {}
         protected void doCheck()
              int index = m_list.getSelectedIndex();
              if (index < 0)
                   return;
              InstallData data = (InstallData)m_list.getModel().
                   getElementAt(index);
                   data.invertSelected();
                   m_list.repaint();
              //     m_parent.recalcTotal();
    class InstallData
    protected String m_name;
    protected int m_size;
    protected boolean m_selected;
    public InstallData(String name, int size)
         m_name = name;
         m_size = size;
         m_selected = false;
    public String getName() { return m_name; }
    public int getSize() { return m_size; }
    public void setSelected(boolean selected) { m_selected = selected;}
    public void invertSelected() { m_selected = !m_selected; }
    public boolean isSelected() { return m_selected; }
    public String toString() { return m_name+" ("+m_size+" K)"; }

  • How to make a prog. Tree with Checkbox in JSF?

    I am facing prob. to how to dev. prog. which contain Tree with Checkbox .
    I want to use checkbox because whatever comes under any directory in Tree is selected if I select perticular folder from Tree?
    Can you guide me guys ?
    Ur help is needed to me.
    Thanks,
    Harshal Joshi

    I have worked whith JSF-s CheckBox components , It has a problem, when I used it with tables and Trees, so I think this components needs to develop.
    enyone has other ideas about it, and knows how to do it?

  • How to create a JTable with CheckBox(checkbox should be added to a buttong)

    hi,
    i want a JTable with checkbox or radio button with them as editable.Only one check box can be selected i.e i want to add it to button group.no of rows in the table to not fixed
    And on the click of radiobutton a text field has to be updated.
    how to do this???
    thanks
    neel

    I think this article would be helpful:
    http://www.chka.de/swing/table/columns.html
    But don't expect any thanks from the OP!Exuse me my dummy question. But I am novice at this
    forum. Who is OP and what do you mean?OP - Original Poster.
    Thanks - a response indicating that your efforts in providing a solution to a problem are appreciated!

  • How can I fill a JComboBox with a ResultSet?

    I want to fill a JComboBox with the data in ResultSet. What�s the better way to do this? Can I convert a RecordSet to a Vector and use the vector in JComboBox constructor?
    Thanks for any help.
    Renato

    Prova cosi:
    myComboBox = new JComboBox();
    ArrayList items = new ArrayList();
    ResultSet result = conn.executeQuery("SELECT BLABLA FROM BLABLA");
    while (result.next())
    items.add(result.getString(1));
    result.close();
    myComboBox.setModel(new DefaultComboBoxModel(items.toArray()));
    E' molto pi� efficiente che aggiungere gli item alla combo uno alla volta.
    G.M.

  • Open dialog box window with checkboxes for each child record - Please Help

    Hello Everybody
    I have a 10g form with master record and 20 child records. In the child record form, currently there is a “Notes” Editor, which pops up when user click the “Edit” button. In the “Notes” editor, user enters remarks if anything is missing. For example, typical remarks will be: Statement is missing, LOC paper is missing etc.
    Now, I would like to replace “Notes” editor with a dialog box. In the dialog box , I would like to add checkboxes with values “Statement is missing” and “LOC paper is missing” etc. along with “Notes” field. The user can select checkboxes. The value of the checkboxes should go in the “Notes” field with the ability to edit it. This way, user doesn’t need to type the most common notes every time.
    I have created a “NewNotes” dialog box with checkboxes and multiline text Item. It is pops up when I click on the button. I have also created to WHEN_CHECKBOC_CHANGED trigger for each checkboxes so that the its value will go in a multiline text item.
    But, I am not sure how I can link “NewNotes” dialog box to the each record in child record block. I would really appreciate it if anybody could give me some idea.
    Thanks,

    if i understand correctly you have a note item (based on table) on every child record? when you open the dialog box: how do you put data from notes to dialog box? in the same way as you can write it back ...

  • Problem with checkbox selection in Tableview

    Hi All
    I am using table view with 8 columns - in the last 4 columns i have checkboxes for user input - i have a strange problem - when the table has multiple entries - for the last column i can only select the checkbox on line 1 - and i cannot select the checkbox on the remaining entries below - but for the other colums with checkboxes this is not the case
    The selection mode for the table is no line selection - since the table is already displayed with input enabled fields - this is to reduce the no of clicks for user
    Can anyone point out what is going wrong - how can i fix this - what i am doing wrong ?
    Thanks
    Sen

    Hi
    When i click on the checkbox for the 2nd or 3rd rows of the last column - nothing happens - the checkox is still active but nothing happens -
    this is the tableview code
    <htmlb:tableView id              = "Detail"
                     design          = "ALTERNATING"
                     headerText      = "Header Text"
                     onNavigate      = "onMyNavigate"
                     emptyTableText  = "test"
                     onRowSelection  = "onMyRowSelection"
                     fillUpEmptyRows = "false"
                     footerVisible   = "true"
                     visibleRowCount = "5"
                     table           = "<%= DETAILTAB %>"
                     iterator        = "<%= iterator %>" >
    and this is the code for the last column
    <htmlb:tableViewColumn columnName         = "OBSOFLGICON"
                               width               = "3"
                               type                = "user"
                               horizontalAlignment = "CENTER"
                               title               = "Obs" >
          <htmlb:checkbox />
        </htmlb:tableViewColumn>
    Thanks
    Sen

  • Problem with checkbox column in matrix

    Hello.
    I have a little problem with checkbox column in matrix.
    Column is binded to the UserData.
    It has ValOn="Y", ValOff="N".
    I use C++. It is wird problem. In matrix I have 10 columns - scrollbar role and if You want see checkbox column, You must role to the right. If this column is on the screen, and I use:
    checkcell->PutChecked(VARIANT_TRUE);
    then the checkbox is cheched, and if the checkbox isn`t on the screen and I use this comment - it nothing happening.
    I tried to use ValOn="Y", PutChecked...
    The problem i solved if the column is on the screen - if the column is first in matrix or second, but if it`s last I have a big problem.
    My column with checkbox is not editable, but I tried to make it editable, check it, and then make it uneditable - the same efect.
    How can I solve it ?
    Sorry for my english.
    Kamil Wydra

    Hello Kamil,
    I am not sure about your problem, but here is an example of how to use checkbox in UI API.
    First, create the matrix with checkbox column in Screen painter, and the output is an xml file, like this. Type as 121 indicates that it is a check box.
    - <column AffectsFormMode="0" backcolor="-1" description="" disp_desc="0" editable="0" right_just="0" title="Rented" type="121" uid="Rented" val_off="N" val_on="Y" visible="1" width="41">
      <databind alias="U_RENTED" databound="1" table="@VIDS" />
      <ExtendedObject />
    Second, bind the column to table from DB. This is a bug of 2004 Screen Painter, so if you are using 2005 Screen Painter, there is no problem.
    Third, when you open the form, you can check and uncheck the cell.
    BTW, please set the editable of the column to true.
    Hope this helps,
    Nick

  • Problem with checkbox on table component

    Hello i am having a problem with checkbox in table component
    i am developing something like a shopping cart app and i have a checkbox in my table component , i want users to select items from the checkbox to add to thier cart, They can select the items from cartegory combobox , my problem is when they select the items from the checkbox if they select another category the alread selected once do not display in my collection opbject please how can i maintain the state of the already selected items in my collection object

    Hi,
    Please go through the tutorial "Understanding scope and managed beans". This is available at:
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/scopes.html
    The details of the selected items need to be stored in an object that is in session scope.
    Hope this helps
    Cheers
    Girish

  • Problem with checkbox and process

    Hallo,
    I have a checkbox on my page and now I want to create a process that runs when the checkbox is checked.
    What I want to do is: to ckeck wheather the checkbox is check and if this is then to set values.
    I don't know if it is right how I check the status of the checkbox. What I also don't really know how I can decide
    that all field I go through in the loop get the same value from the XYZ-collection. The value should be the last from
    the XYZ-collection.
    Thanks, Jade
    declare
    check integer:=0;
    change integer:=0;
    begin
    check:=:Px_Check;
    if (check <> 0) then change:=1; end if;
    if change = 1 then
    for i in 1..htmldb_application.g_f04.count
    loop
    htmldb_collection.update_member_attribute(p_collection_name=>'XYZ',
    p_seq=>i,
    p_attr_number=>5,
    p_attr_value=>???);
    end loop;
    end if;
    end;

    Hi,
    Taking the two issues separately....
    1 - When dealing with checkboxes, you have to bear in mind that the submit process will only return the values of those checkboxes that have been ticked into the f04 collection (assuming f04 is the column containing your checkboxes). In order to determine which ones they are, you need to get the value (which should be a row number if you've created the checkboxes by using the Row Selector option) and then use that to get to the values on the actual rows. Something like:
    DECLARE
    vITEM NUMBER;
    BEGIN
    FOR i IN 1..HTMLDB_APPLICATION.G_F04.COUNT
    LOOP
      vITEM := HTMLDB_APPLICATION.G_F04(i);
    END LOOP;
    END;Then, within the loop, you can use vITEM as the row number. So, if the user ticked items 1, 4 and 6. G_F04(1) would contain 1, G_F04(2) would contain 4 and G_F04(3) would contain 6. Therefore, for you update statement, you can use vITEM for the sequence number of the item to update.
    2 - When dealing with collections, if you want to get to the last item in the collection, you can get the member count and use that to get to the member:
    DECLARE
    vCOUNT NUMBER;
    vDATA NUMBER;
    BEGIN
    vCOUNT := HTMLDB_COLLECTION.COLLECTION_MEMBER_COUNT ('XYZ');
    SELECT c005 INTO vDATA FROM HTMLDB_COLLECTIONS WHERE COLLECTION_NAME = 'XYZ';
    END;That should get the c005 value for the last item and store it in vDATA. You can then update the ticked items with this value.
    Andy

Maybe you are looking for

  • How to connect a new 27" LED Cinema Display to an older Mac Mini?

    I bought a 27" LED Cinema Display (no Thunderbolt) but don't know how to connect it to my wife's older Mac Mini. I presume the Atlona adaptor is the solution, but I haven't bougt one yet. robbert keegel

  • Exit Code 7 for installing Creative Suite 5.5 Web Premium

    I have follow the instructions on Adobe websites but the installation still failed.... really need help for the installaation!!! my laptop info: Microsoft Windows XP Professional Verson 2002 Service Pack 3 error show as follow: Exit Code: 7     -----

  • How to stop the rename the cn again if it had meet the condition

    How to stop to rename the CN in Active directory if running the script. This is my script: $objSearch = New-Object DirectoryServices.DirectorySearcher $dateNow = Get-Date $DomainDNS = "server2008.server1.com" #server 2008 $ADpath = [ADSI]"LDAP://$Dom

  • IMessage no longer accepts images to be dragged into the message box

    My iMessage iMac app no longer accepts images to be dragged into the message box since upgrading to Mavericks. I used to be able to just drag in .jpg images and they would appear in the text field to be sent to another persons iPhone/iPad/iMac. This

  • Compressor 2 - Quicktime error 0 revealed

    After upgrading to the latest version of QT, FCP5, DVDSP4, and Compressor 2 with all the latest fixes I could not compress a 1 hr 46 min video on my quad G5 without getting the dreaded quicktime 0 error message. I spent days trying to get around this