ComboBox Highlighting

Hi Guys,
Is it possible to highlight a JComboBox even when an item is not selected? I need to show focus within the JComboBox when a user tabs to it.
-Sri :)

I added a FocusAdapter to my JComboBox like this:
focusAdapter = new FocusAdapter() {
public void focusGained(FocusEvent fe)
comboBox.getEditor().getEditorComponent().setForeground(SystemColor.textHighlightText);
comboBox.getEditor().getEditorComponent().setBackground(SystemColor.textHighlight);
public void focusLost(FocusEvent fe)
comboBox.getEditor().getEditorComponent().setForeground(SystemColor.textText);
comboBox.getEditor().getEditorComponent().setBackground(SystemColor.text);
comboBox.addFocusListener(focusAdapter);
It looks almost life-like :)

Similar Messages

  • ComboBox Highlighted Text Problem

    Greetings Flash Gurus...
    Working with the ComboBox Component (MX 2004 Pro) and noticed
    something weird.
    I have an editable combobox with three selectable items. When
    a longer item is selected, the text in the input box gets
    highlighted only partially. In fact, it gets a selection highlight
    of exactly the same number of characters as the previous one. It
    looks silly if the default selection was "pear" and the user
    changes it to "pineapple", and the first four characters are
    highlighted. This does not happen when the user enters text, only
    on selecting from the list.
    Any thoughts on how to override this behaviour? Ideally, I
    would rather have no selection/highlight, just a blinking cursor at
    the end of the text. Alas, a change event handler and
    Selection.setSelection isn't giving me any love.

    Heeeey, cool that you found that!
    I reported this ages ago (Re: SQLDeveloper 1.1.0.21.41 - Results display issues but wasn't aware the setting was taken from the OS. Now the developers don't have any excuse not to fix this.
    Mind that different themes can change the text colour; the Sky themes aren't suitable for the default dark blue background, but for you it might be the perfect solution.
    Also take up Furry's tip and customize the colour scheme through the Preferences.
    Thanks,
    K.

  • Highlight color for Combobox

    I have a JComboBox, when i navigate between the various items inside the Combobox, it gets highlighted by some color. I want to know how to get that color object, i want to use the same color for something else. What would be the RGB combination for tat color?

    Popup, or drop down, list of JComboBox is a JList object.
    JList has getSelectionBackground() and ---Foreground() methods to get selection highlight
    color. In order to access the JList object in a JComboBox, study the source code
    JComboBox.java. Especially, its AccessibleJComboBox() constructor is the key.
    Alternately, you could use:
    UIManager.getColor("ComboBox.selectionBackground")
    // and
    UIManager.getColor("ComboBox.selectionForeground")

  • ComboBox / TextField Highlight Issue

    I've got a form that uses the ComboBox component which, when
    previewing in html loading the movie normally, the halos or
    highlights that show when tabbing through my form (text fields and
    comboboxes currently).
    As soon as I load that RegForm through another swf using
    loadMovieNum, the halo's cease to exist for some reason.
    I've tried to set _lockroot = true on either swf, then on
    both swfs just for kicks, but that didn't do it.
    Anyone have any ideas on this?
    Thanks!

    Replicated your situation: works here.
    Are you sure you have the options "Clear Destination when no selected item" and "Data Change and Interaction" on the main sheet checked/selected?

  • ComboBox scroll and selected/highlight on glasspane

    I'm using JInternalFrame as a modal frame( we couldn't use JDialog).
    For that I used an example that i found on net, which in this way the JInternalFrame is added to GlassPane of JFrame .
    On JInternalFrame there is a JComboBox.
    When I drag its scrollpad and move it up and down (to see items in Combo box), content moves ok, but scrollpad stays fixed on one place (instead of going up and down too).
    Also, when mouse points an item, it's not highlighted.
    After browsing the web and this forum i found 2 threads about this but no answer.
    Does anyone have a solution for that?
    Sample code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.beans.*;
    public class ModalInternalFrame extends JInternalFrame {
      private static final JDesktopPane glass = new JDesktopPane();
      public ModalInternalFrame(String title, JRootPane
          rootPane, Component desktop) {
        super(title);
        // create opaque glass pane   
        glass.setOpaque(false);
        glass.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        // Attach mouse listeners
        MouseInputAdapter adapter = new MouseInputAdapter(){};
        glass.addMouseListener(adapter);
        glass.addMouseMotionListener(adapter);
        desktop.validate();
        try {
          setSelected(true);
        } catch (PropertyVetoException ignored) {
        // Add modal internal frame to glass pane
        glass.add(this);
        // Change glass pane to our panel
        rootPane.setGlassPane(glass);
        @Override
      public void setVisible(boolean value) {
        super.setVisible(value);
        // Show glass pane, then modal dialog
        if(glass != null)
            glass.setVisible(value);   
        if (value) {
          startModal();
        } else {
          stopModal();
      private synchronized void startModal() {
        try {
          if (SwingUtilities.isEventDispatchThread()) {
            EventQueue theQueue =
              getToolkit().getSystemEventQueue();
            while (isVisible()) {
              AWTEvent event = theQueue.getNextEvent();
              Object source = event.getSource();
              if (event instanceof ActiveEvent) {             
                ((ActiveEvent)event).dispatch();
              } else if (source instanceof Component) {
                  ((Component)source).dispatchEvent(event);                           
              } else if (source instanceof MenuComponent) {             
                ((MenuComponent)source).dispatchEvent(
                  event);
              } else {
                System.out.println(
                  "Unable to dispatch: " + event);
          } else {
            while (isVisible()) {
              wait();
        } catch (InterruptedException ignored) {
      private synchronized void stopModal() {
        notifyAll();
      public static void main(String args[]) {
          final JFrame frame = new JFrame(
          "Modal Internal Frame");
        frame.setDefaultCloseOperation(
          JFrame.EXIT_ON_CLOSE);
        final JDesktopPane desktop = new JDesktopPane();
        ActionListener showModal =
            new ActionListener() {
          Integer ZERO = new Integer(0);
          Integer ONE = new Integer(1);
          public void actionPerformed(ActionEvent e) {
            // Construct a message internal frame popup
            final JInternalFrame modal =
              new ModalInternalFrame("Really Modal",
              frame.getRootPane(), desktop);
            JTextField text = new JTextField("hello");
            JButton btn = new JButton("close");
            JComboBox cbo = new JComboBox(new String[]{"-01-", "-02-", "-03-", "-04-", "-05-", "-06-", "-07-", "-08-", "-09-", "-10-", "-11-", "-12-"});
            btn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            modal.setVisible(false);
            cbo.setLightWeightPopupEnabled(false);
            Container iContent = modal.getContentPane();
            iContent.add(text, BorderLayout.NORTH);
            iContent.add(cbo, BorderLayout.CENTER);       
            iContent.add(btn, BorderLayout.SOUTH);
            //modal.setBounds(25, 25, 200, 100);
            modal.pack();
            modal.setVisible(true);    
        JInternalFrame jif = new JInternalFrame();
        jif.setSize(200, 200);
        desktop.add(jif);
        jif.setVisible(true);
        JButton button = new JButton("Open");
        button.addActionListener(showModal);
        Container iContent = jif.getContentPane();
        iContent.add(button, BorderLayout.CENTER);
        jif.setBounds(25, 25, 200, 100);
        jif.setVisible(true);
        Container content = frame.getContentPane();
        content.add(desktop, BorderLayout.CENTER);
        frame.setSize(500, 300);
        frame.setVisible(true);
    }

    This is a bug, and there are several open bugs on the same subject.
    The only pop up that works in this situation is a heavy weight pop up.
    There are 3 types of pop up windows: light weight, medium weight and heavy weight.
    When you call setLightWeightPopupEnabled(false) the combo box uses the medium weight when the pop up window is inside the application frame, and heavy weight when the window exceeds the frame bounds.
    There is no easy way to force the pop up to heavy weight, since most of the functions and fields in the relevant classes are private.
    But you can use reflection to access them.
    Here is one solution (tested and working with JDK 5) - adding the client property forceHeavyWeightPopupKey from PopupFactory to your combo box.
    cbo.setLightWeightPopupEnabled(false);
    try {                         
         Class cls = Class.forName("javax.swing.PopupFactory");
         Field field = cls.getDeclaredField("forceHeavyWeightPopupKey");
         field.setAccessible(true);
         cbo.putClientProperty(field.get(null), Boolean.TRUE);
    } catch (Exception e1) {e1.printStackTrace();}
    ...

  • How to align the item text in the combobox vertically centred after increasing the height of the combobox in mfc?

    I want to make the item text of the combobox to  be aligned vertically(Centred) . Actually I increased the height 
    of the combobox and after the increasing the combobox height, the text is not centred vertically.The code
    snippet for increasing the height is as follows,
    m_SpecifyCombo.SetItemHeight(-1,20);//CCombobox m_SpecifyCombo
    After increasing the height the text in the combobox is not in the centre as shown in the below image,
    But I want the text to be centred as shown in the below image.
    Code snippet for owner drawn combobox:
    #if !defined(AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_)
    #define AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_
    #if _MSC_VER >= 1000
    #pragma once
    #endif // _MSC_VER >= 1000
    typedef enum {FONTS} STYLE; //Why have I enumerated, Cos, Maybe I might want something other than Fonts here
    class COwnerDrawCombo : public CComboBox
    // Construction
    public:
    COwnerDrawCombo();
    COwnerDrawCombo (STYLE);
    // Attributes
    public:
    void SetHilightColors (COLORREF hilight,COLORREF hilightText)
    m_clrHilight = hilight;
    m_clrHilightText = hilightText;
    void SetNormalColors (COLORREF clrBkgnd,COLORREF clrText)
    m_clrNormalText = clrText;
    m_clrBkgnd = clrBkgnd;
    static BOOL CALLBACK EnumFontProc (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData);
    void FillFonts ();
    int GetSelFont (LOGFONT&);
    // Operations
    public:
    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CCustComboBox)
    public:
    virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
    virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
    protected:
    virtual void PreSubclassWindow();
    //}}AFX_VIRTUAL
    // Implementation
    public:
    virtual ~COwnerDrawCombo();
    // Generated message map functions
    protected:
    STYLE m_enStyle;
    COLORREF m_clrHilight;
    COLORREF m_clrNormalText;
    COLORREF m_clrHilightText;
    COLORREF m_clrBkgnd;
    BOOL m_bInitOver;
    void DrawDefault (LPDRAWITEMSTRUCT);
    void DrawFont(LPDRAWITEMSTRUCT);
    void InitFonts ();
    //{{AFX_MSG(CCustComboBox)
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnDestroy();
    //}}AFX_MSG
    afx_msg long OnInitFonts (WPARAM, LPARAM);
    DECLARE_MESSAGE_MAP()
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
    #endif //!defined(AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_)
    // OwnerDrawCombo.cpp : implementation file
    #include "stdafx.h"
    #include "combobox.h"
    #include "OwnerDrawCombo.h"
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    #define WM_INITFONTS (WM_USER + 123)
    //I chose 123 cos nobody might use the same exact number.. I can improve this by use RegisterWindowMessage..
    // COwnerDrawCombo
    //Initial values of the text and highlight stuff
    COwnerDrawCombo::COwnerDrawCombo()
    m_enStyle = FONTS;
    m_clrHilight = GetSysColor (COLOR_HIGHLIGHT);
    m_clrNormalText = GetSysColor (COLOR_WINDOWTEXT);
    m_clrHilightText = GetSysColor (COLOR_HIGHLIGHTTEXT);
    m_clrBkgnd = GetSysColor (COLOR_WINDOW);
    m_bInitOver = FALSE;
    COwnerDrawCombo::COwnerDrawCombo (STYLE enStyle)
    m_enStyle = enStyle;
    m_clrHilight = GetSysColor (COLOR_HIGHLIGHT);
    m_clrNormalText = GetSysColor (COLOR_WINDOWTEXT);
    m_clrHilightText = GetSysColor (COLOR_HIGHLIGHTTEXT);
    m_clrBkgnd = GetSysColor (COLOR_WINDOW);
    m_bInitOver =FALSE;
    COwnerDrawCombo::~COwnerDrawCombo()
    BEGIN_MESSAGE_MAP(COwnerDrawCombo, CComboBox)
    //{{AFX_MSG_MAP(COwnerDrawCombo)
    ON_WM_CREATE()
    ON_WM_DESTROY()
    //}}AFX_MSG_MAP
    ON_MESSAGE (WM_INITFONTS,OnInitFonts)
    END_MESSAGE_MAP()
    // COwnerDrawCombo message handlers
    void COwnerDrawCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
    //I might want to add something else someday
    switch (m_enStyle)
    case FONTS:
    DrawFont(lpDrawItemStruct);
    break;
    //I dont need the MeasureItem to do anything. Whatever the system says, it stays
    void COwnerDrawCombo::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
    void COwnerDrawCombo::DrawFont(LPDRAWITEMSTRUCT lpDIS)
    CDC* pDC = CDC::FromHandle(lpDIS->hDC);
    CRect rect;
    TRACE0 ("In Draw Font\n");
    // draw the colored rectangle portion
    rect.CopyRect(&lpDIS->rcItem);
    pDC->SetBkMode( TRANSPARENT );
    if (lpDIS->itemState & ODS_SELECTED)
    pDC->FillSolidRect (rect,m_clrHilight);
    pDC->SetTextColor (m_clrHilightText);
    else
    pDC->FillSolidRect (rect,m_clrBkgnd);
    pDC->SetTextColor (m_clrNormalText);
    if ((int)(lpDIS->itemID) < 0) // Well its negetive so no need to draw text
    else
    CString strText;
    GetLBText (lpDIS->itemID,strText);
    CFont newFont;
    CFont *pOldFont;
    ((LOGFONT*)lpDIS->itemData)->lfHeight = 90; //9 point size
    ((LOGFONT*)lpDIS->itemData)->lfWidth = 0;
    newFont.CreatePointFontIndirect ((LOGFONT*)lpDIS->itemData);
    pOldFont = pDC->SelectObject (&newFont);
    pDC->DrawText(strText, rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    pDC->SelectObject (pOldFont);
    newFont.DeleteObject ();
    void COwnerDrawCombo::InitFonts ()
    CDC *pDC = GetDC ();
    ResetContent (); //Delete whatever is there
    EnumFonts (pDC->GetSafeHdc(),NULL,(FONTENUMPROC) EnumFontProc,(LPARAM)this);//Enumerate
    m_bInitOver = TRUE;
    BOOL CALLBACK COwnerDrawCombo::EnumFontProc (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData)
    if (dwType == TRUETYPE_FONTTYPE) //Add only TTF fellows, If you want you can change it to check for others
    int index = ((COwnerDrawCombo *) lpData)->AddString(lplf->lfFaceName);
    LPLOGFONT lpLF;
    lpLF = new LOGFONT;
    CopyMemory ((PVOID) lpLF,(CONST VOID *) lplf,sizeof (LOGFONT));
    ((COwnerDrawCombo *) lpData)->SetItemData (index,(DWORD) lpLF);
    return TRUE;
    int COwnerDrawCombo::OnCreate(LPCREATESTRUCT lpCreateStruct)
    if (CComboBox::OnCreate(lpCreateStruct) == -1)
    return -1;
    // TODO: Add your specialized creation code here
    if (m_enStyle == FONTS)
    //SetItemHeight(-1,30);
    PostMessage (WM_INITFONTS,0,0);
    return 0;
    long COwnerDrawCombo::OnInitFonts (WPARAM, LPARAM)
    InitFonts ();
    return 0L;
    void COwnerDrawCombo::OnDestroy()
    if (m_enStyle == FONTS)
    int nCount;
    nCount = GetCount ();
    for (int i = 0; i < nCount; i++)
    delete ((LOGFONT*)GetItemData (i)); //delete the LOGFONTS actually created..
    // TODO: Add your message handler code here
    CComboBox::OnDestroy();
    void COwnerDrawCombo::FillFonts ()
    m_enStyle = FONTS;
    PostMessage (WM_INITFONTS,0,0); //Process in one place
    int COwnerDrawCombo::GetSelFont (LOGFONT& lf)
    int index = GetCurSel ();
    if (index == LB_ERR)
    return LB_ERR;
    LPLOGFONT lpLF = (LPLOGFONT) GetItemData (index);
    CopyMemory ((PVOID)&lf, (CONST VOID *) lpLF, sizeof (LOGFONT));
    return index; //return the index here.. Maybe the user needs it:-)
    void COwnerDrawCombo::PreSubclassWindow()
    // TODO: Add your specialized code here and/or call the base class
    //Tried to do what Roger Onslow did for the button.. Did not work..?? Any R&D guys around :-)
    Can anyone please let me know how can I achieve this.
    Any help can be appreciated.
    Thanks in advance
    SivaV

    Hi sivavuyyuru,
    I cannot find a easy way to make this.
    I think you may need to draw your own Combo Box control. And you could change the edit control more like static text. Check the article:
    http://www.codeguru.com/cpp/controls/combobox/fontselectioncombos/article.php/c1795/Owner-Drawn-Font-Selection-Combobox.htm
    In the resource editor, Owner draw -> variable , Has string->true, type->drop list.
    The result:
    Best regards,
    Shu Hu
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Refresh combobox with custom display(Plug in)

    Hello ,
    I am using combobox with custom display(Plug in) in my application.
    i want to display value in combobox on selection of values in radio item
    sample query used in combobox like
    if :Radio_item = 1 then
    return 'SELECT NAME dropdown_display
        ,NAME search_string
        ,NAME input_display
        ,id return_value
    FROM Table_A';
    else
    return 'SELECT NAME dropdown_display
        ,NAME search_string
        ,NAME input_display
        ,id return_value
    FROM Table_B';
    end if;
    but problem is it is always showing the data from first query,it is not displaying the value from second query on changing of radio option.
    i also tried to refresh the combobox item  on change of radio item values but still it is showing the value from first query.
    please help me how to resolve this issue.
    Apex Version - 4.1.1
    Database - 11g
    Regards and thanks
    Jitendra

    Shiv wrote:
    Hi,
    I used plugin "Combobox with Custom Display".
    I have issue like
    When i entered some text in textbox and scroll down using down key of key board. That highlighted part can not scroll down with scroll.
    The demo link for above issue
    http://apex.oracle.com/pls/apex/f?p=35538:4
    kindly help me out.
    ThanksIts a bug in the plugin code and not related to APEX.
    I will look into it and fix my code to address this issue, please bookmark this page http://www.apex-plugin.com/oracle-apex-plugins/item-plugin/combobox-with-custom-display_212.html and check for updates.
    Thanks,
    Vikram

  • How do I limit typing in a ComboBox Dropdown list

    I’ve created a form and added a ComboBox which generated the code:
    this->DateList = (gcnew System::Windows::Forms::ComboBox());
    this->SuspendLayout();
    // DateList
    this->DateList->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12,
    System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
    static_cast<System::Byte>(0)));
    this->DateList->FormattingEnabled = true;
    this->DateList->Location = System::Drawing::Point(91, 7);
    this->DateList->Name = L"DateList";
    this->DateList->Size = System::Drawing::Size(121, 28);
    this->DateList->TabIndex = 0;
    this->DateList->SelectedIndexChanged += gcnew System::EventHandler(this,&Form1::DateList_SelectedIndexChanged);
    And then I added some custom code to add the items to the DateList
    for ( int x = numSnapShots - 1 ; x >= 0 ; x-- )
      String ^ item = gcnew String ( SnapShots[x]->dateStr );
        this->DateList->Items->Add(item);
    this->DateList->SelectedIndex = 0;
    All is working fine, I can select any Snapshot date I want from the list. 
    The problem is that I can also type anything I want in the ComboBox. 
    The dropdown of 12/31/2014 is in the list, but I can also type “Last Year” and of course the code doesn’t know how to handle that.
    What item in the combobox do I have the change to what to disable the user’s ability to type in the combobox?

    David,
    Maybe I didn’t look hard enough, but I could not find a way to create a C# WinForms project and include my existing C++ code as is and then interface the form front end to the existing C++ logic.
    I did find relatively easy ways for a C++ CLI Windows Forms Application to communicate with standard C++. 
    I had to limit the data types that I passed pack and forth, but the link up was relatively easy.
    I have externals in Form1.h which can then simply call the primary C++ interface:
    extern std::string str;
    extern std::string strPage;
    extern std::string strDate;
    extern
    void Initialize();
    extern
    int RebuildPage(int);
    Initialize() is called right after Initialize Component() to load all the data into memory and build the first HTML page.
    if (RebuildPage(7))    
    RefreshThePage();
    Exists for most of the button clicks and dropdown selections. 
    The number tells the C++ code what form control was clicked and a nonzero return tells the form to refresh the page. 
    Refresh the page is a simple Form1.h method that does just that, changes the labels on the form header and refreshes the HTML string to the new HTML data created by the C++ logic.
    void RefreshThePage(void)
    this->webBrowser1->DocumentText =
    gcnew String( str.c_str() );
    this->ViewLabel->Text =
    gcnew String( strPage.c_str() );
    this->DateLabel->Text =
    gcnew String( strDate.c_str() );
    This allowed me to perform all of the complex operation in the existing code with minimal changes, like changing the fprintf’s that created the original HTML files into str.append logic to pass the pages directly to the form.
    It’s true that all of my other code was batch style console applications, but the form front end was not totally difficult to learn and the simple fixes like David Lowndes just suggested makes the coding even easier. 
    Thanks again Dave.
    I created a very complex program to make visualizing mutual fund trends very simple. 
    The problem with the batch console application was that if I wanted to stop highlighting symbol ABC and wanted to start highlighting XYZ, I had to modify a data file by hand and then rerun the batch process to recreate the entire website on my local
    drive so I could not instantly see the change.  Using a form front end and building and displaying the pages interactively make that process instant.

  • How do I get the value of a comboBox item that is in a grid?

    Hi all,
    I have a data grid that has comboBoxes in two of its columns.
    What I need to do is get the values of those bombo boxes when a user highlights the row of the grid NOT when the user uses the comboBox. I understand how to pull the values out once the change handler is invoked on the comboBox, but I'm not seeing a way to get at the comboBoxes that belong to the currently highlighted gridRow.
    I'm sure it's really straight forward, but I'm just not able to find any reference on how it's done. Any help greatly appreciated.

    This code shows how you can do it if you know the dataProvider fields for the ComboBox data.
    If this post answered your question or helped, please mark it as such.
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
       initialize="initData()">
       <mx:Script>
       <![CDATA[
        import mx.events.ListEvent;
          import mx.collections.*;
          private var DGArray:Array = [
             {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99, combo1: [1,2,3], combo2: [100,200,300]},
             {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99, combo1: [2,4,6], combo2: [200,400,600]}];
          [Bindable] public var initDG:ArrayCollection;
          public function initData():void {
             initDG=new ArrayCollection(DGArray);
          private function dgChangeHandler(event:ListEvent):void{
           var ac:ArrayCollection = event.currentTarget.dataProvider;
           txt.text = "";
           txt.text += ac.getItemAt(event.rowIndex).combo1 + "\n";
           txt.text += ac.getItemAt(event.rowIndex).combo2;
       ]]>
       </mx:Script>
       <mx:DataGrid id="myGrid" width="350" height="200"
          dataProvider="{initDG}" change="dgChangeHandler(event);">
          <mx:columns>
             <mx:DataGridColumn dataField="Artist" />
             <mx:DataGridColumn dataField="Album" />
             <mx:DataGridColumn dataField="Price" />
             <mx:DataGridColumn dataField="combo1">
              <mx:itemRenderer>
               <mx:Component>
                <mx:VBox>
                 <mx:ComboBox dataProvider="{data.combo1}"/>
                </mx:VBox>
               </mx:Component>
              </mx:itemRenderer>
             </mx:DataGridColumn>
             <mx:DataGridColumn dataField="combo1">
              <mx:itemRenderer>
               <mx:Component>
                <mx:VBox>
                 <mx:ComboBox dataProvider="{data.combo2}"/>
                </mx:VBox>
               </mx:Component>
              </mx:itemRenderer>
             </mx:DataGridColumn>
          </mx:columns>
       </mx:DataGrid>
       <mx:TextArea id="txt" width="100%" height="100%"/>
    </mx:Application>

  • JComboBox selection and highlight problem of the selected item

    Hi,
    I have a question how can I make my newly added item to the combo-box selectable and highlighted. I am adding new items to my custom comboBox dynamically and I want whatever item I add to be selected by default. I am using my own custom ComboBoxModel that extends AbstractListModel and implements ComboBoxModel and TreeModelListener, and my custom Renderer that extends JLabel and implements ListCellRenderer. Because I am trying to get a tree structure in my comboBox model and that's why I have my own custom model and renderer. Now when I add a new node or item to my comboBox it is being added and shown in the combo-box textField, but as soon I pull down the combo-box my parent directory is selected though my current selection is the last node added. That's how I am adding new nodes and making it selectable
    treeModel.insertNodeInto(tempNode, (DefaultMutableTreeNode)nodeCollection.lastElement(), 0);
    int nodeTotal =((CMRGlobals.myTreeGlobals).getModel()).getSize();
    Object lastNode = CMRGlobals.myTreeGlobals).getModel()).getElementAt(nodeTotal - 1);
    ((CMRGlobals.myTreeGlobals).getModel()).setSelectedItem(lastNode);
    when I do this my node is added under my parentNode and is shown in the comboBox but when I try to pull down the combo my parent node is high lighted and when I move out of the combo-box my parent node gets selected and show in the combo-box though I haven't selected it,and the contents of my last node are shown. I am just writing my own custom model that simulates the effect of JTree. I am using these......
    DefaultMutableTreeNode and
    DefaultTreeModel
    and in my JComboBox I am setting my model as
    this.setModel(new myModel(treemodel));
    this.setRenderer(new myRenderer());
    I am building my own FileDialog that just works like FileDialog I have all the functionality except this problem.Thanks for any help. I know I have posted this same thread yesterday but I didn't get any response hoping now may somebody can help me.Thanks again

    never mind I got it
    Thanks

  • [svn:fx-trunk] 11532: ComboBox user interactions

    Revision: 11532
    Author:   [email protected]
    Date:     2009-11-06 13:32:37 -0800 (Fri, 06 Nov 2009)
    Log Message:
    ComboBox user interactions
    Added support for an improved user interaction. When the user starts typing in the textInput, ComboBox will now update the textInput with the rest of the matching item. It will then select the non-typed text. When using the navigation keys, the textInput will change to the new highlighted item.
    QE notes: Tests need updating to account for new user interaction
    Doc notes: We should update the docs to describe the user interaction
    Bugs: N/A
    Reviewer: Glenn
    Tests run: DropDownList, ComboBox
    Is noteworthy for integration: No
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/ComboBox.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DropDownList.as

  • Editable ComboBox

    OK, java jocks - I need help... I am a vb programmer (don't hold that against me) but need to do some java
    stuff... I have included the following 'object' code but need to get it to do what a lot of you good folks have
    already dealt with back in 2001... And that is, as the user starts typing in a codelist choice, the focus
    moves to that item in the combobox... I tried to read through the various code classes offered up in this forum but can not get any to work for me... Any suggestions and remember I am a java beginner...
    thanks, msp@duke
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class EditableComboBox extends JDialog
                   implements ActionListener {
    JFrame frame;
    JLabel result;
    String currentPattern;
    public EditableComboBox() {
         System.out.println("inside EditableComboBox constructor...");
         JFrame frame = new JFrame("EditableComboBox");
         //JPanel panel = new JPanel();
         JPanel panel = new JPanel(new GridLayout(5,1));
         //panel.setLayout(new GridLayout(5,1));
         final JLabel label = new JLabel();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    String[] codelist = {
    "1 - Code#1",
    "2 - Code#2",
    "3 - Code#3",
    "4 - Code#4",
    "5 - Code#5",
    "6 - Code#6",
    "7 - Code#7",
    "8 - Code#8",
                        "9 - Code#9",
    "10 - Code#10"
    //currentPattern = codelist[0];
              currentPattern = "";
    //Set up the UI for selecting a pattern.
    JLabel cboLabel1 = new JLabel("Enter the pattern string");
    JLabel cboLabel2 = new JLabel("select one from the list:");
              panel.add(cboLabel1);
              panel.add(cboLabel2);
              //Creates a JComboBox that contains the elements
              //     in the specified Vector
    JComboBox cboList = new JComboBox(codelist);
    cboList.setEditable(true);
    cboList.addActionListener(this);
              panel.add(cboList);
    //Create the UI for displaying result.
    JLabel resultLabel = new JLabel("You Selected:",JLabel.LEADING);
              // add label
              panel.add(resultLabel);
    result = new JLabel("");
    result.setForeground(Color.black);
    result.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createLineBorder(Color.black),
    BorderFactory.createEmptyBorder(5,5,5,5)
              panel.add(result);
              frame.getContentPane().add(BorderLayout.CENTER,panel);
              System.out.println("bottom of EditableComboBox constructor...");
              frame.pack();
              //frame.setSize(h,v);
              frame.setSize(200,175);
              frame.setVisible(true);
    } //constructor
    public void actionPerformed(ActionEvent e) {
              System.out.println("inside actionPerformed...");
    JComboBox cb = (JComboBox)e.getSource();
    String newSelection = (String)cb.getSelectedItem();
    currentPattern = newSelection;
    validate();
    /** Formats and displays today's date. */
    public void validate() {
              result.setText(currentPattern);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
              System.out.println("inside main...");
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
                        EditableComboBox ec = new EditableComboBox();

    You need to write a KeyListener, which upon receiving
    a keyEvent will do the following:
    1) Get the current string from the ComboBox (or you
    can internally keep track of it in a Char[]).
    2) Loop through all the elements of the ComboBox to
    check for a possible match
    using startsWith() method (java.lang.String).
    3) If match found, then use SetSelectedItem() on that
    ComboBox to show the corresponding value.
    But make sure you highlight only the portions of the
    text to the right of cursor. (the one that will "most
    likely" follow). Use setSelectionStart() and
    SetSelectionEnd() to accomplish this.
    += KRRThx for the 3 step leads, KRR... I will try implementing them today...
    cheers, msp@duke

  • Combobox removing focus!? help!

    Why when I use the combobox component does it remove focus
    from other movieclips?? For instance...I have a button with
    onRollOver and onRollOut functions. These work fine, but once I
    click on a combobox, they break...and won't work.
    I've looked in other places but I haven't found a fix for
    this yet. Doing setfocus(this) only puts a ugly yellow highlight
    box around my button, and then kills the swf with an infinite loop.
    Any ideas?

    hi, hold your data in a Hashtable with the value as key
    and the visible text as value,use a renderer for the combobox like here
    class MyCellRenderer extends JLabel implements ListCellRenderer {
    public MyCellRenderer() {
    setOpaque(true);
    public Component getListCellRendererComponent(
    JList list,
    Object value,
    int index,
    boolean isSelected,
    boolean cellHasFocus)
    setText(value.toString());
    setBackground(isSelected ? Color.red : Color.white);
    setForeground(isSelected ? Color.white : Color.black);
    return this;
    in the method getListCellRendererComponent you get your hashtable as object parameter,get the visible text from the hashtable and call setText (..)
    you can also make a combined String with value and text
    and take only the visible text in the renderer(this solution is not so bombastic as before)

  • Combobox help

    Why when I use the combobox component does it remove focus
    from other movieclips?? For instance...I have a button with
    onRollOver and onRollOut functions. These work fine, but once I
    click on a combobox, they break...and won't work.
    I've looked in other places but I haven't found a fix for
    this yet. Doing setfocus(this) only puts a ugly yellow highlight
    box around my button, and then kills the swf with an infinite loop.
    Any ideas?

    Your question is very vague and badly phrased. Why don't you post some code to show what you've done and how you're inserting values into the DB right now?
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • Combobox removing focus?

    Why when I use the combobox component does it remove focus
    from other movieclips?? For instance...I have a button with
    onRollOver and onRollOut functions. These work fine, but once I
    click on a combobox, they break...and won't work.
    I've looked in other places but I haven't found a fix for
    this yet. Doing setfocus(this) only puts a ugly yellow highlight
    box around my button, and then kills the swf with an infinite loop.
    Any ideas?

    While it depends partly on what is outside the textfield, one way would be to add an event listener to the stage and then check what was clicked.  If it happened to be the stage, set the focus onto the stage.
    stage.addEventListener(MouseEvent.MOUSE_UP, focusStage);
    function focusStage(evt:MouseEvent):void {
        if(evt.target == stage){
           stage.focus = stage;

Maybe you are looking for

  • PDF Form extended rights problem

    Hi, i am working on a php application which opens a pdf form (created with acrobat 9 standard), fills it with user data, saves it as a form and sends this form to the user by email, so he cann fill the rest of the form. This works fine for pdf forms,

  • My IPhoto Library is unreadable Tried everything recommended even deleted IPhoto and I still get the error message

    Hi I keep getting the error message  (photo library is either in use by another application or has become unreadable ) I've tried everything that has been suggested, I've even deleted Iphoto and reinstalled it ,but this doesn't work, I even reinstall

  • How to made plugin using flex3 application

    Hi   All, I am working on transitiom plug-in for  premiere pro cs3 ,using  premiere pro cs3 SDK. now i am developing plugins by using adobe flex3 ,application name is transition viewer in which when click on thumbnail play the transition on  the text

  • Sqlcesa35.dll - 500 internal system error

    Hi, I am looking after a windows cloud server hosting a single web application. It has been set up and installed by a third party, I am having to do the day to day maintenance. It uses the Microsoft SQL Server Compact Server Agent for one of the task

  • Error(11,1): PL/SQL: SQL Statement ignored

    FUNCTION getName ( theSSN IN NUMBER ) RETURN VARCHAR2 IS theTotal NUMBER; theName VARCHAR2(40); s varchar2(10); BEGIN select count(*) into theTotal from employee where SSN = theSSN; if (theTotal = 0) then RETURN(''); else select sex as s, (FName || '