Enumeration binding for combo box - missing feature

Hi,
In our application, combo boxes are usually employed for similar purpose as radio button groups: provide the end-user with an exclusive, static list of choices.
Unfortunately, JUComboBoxBinding.createEnumerationBinding method does not seem to follow the same paradigm as JUButtonGroupBinding.createEnumerationBinding.
In fact, for JUButtonGroupBinding, one parameter is "AbstractButton[] buttons", which is used for display purposes (end-user descriptions of the choices), and another is "Object[] valueList", which is the list of values for the corresponding attribute (usually, the valid values in the database for the column).
Meanwhile, JUComboBoxBinding is only receiving one array parameter, "Object[] values", which is used both for display purposes and for database values... This approach is very restrictive, as long as we expect to display in the combo box a descriptive text for the coded value in the database (and localizable, as well!).
Is this a known bug, or am I the first one to have noticed it? Is there any schedule for making this feature available?
Thanks,
Adrian

I'm not sure where my last reply went, so another try.
Unfortunately, I have the same feeling as usual, that my posted messages are not carefully read...
The main issue was the comparison between JUComboBoxBinding and JUButtonGroupBinding, and my question was about the possible future availability of a feature. Nothing about this in the answer...
Could I have an aswer to my original message, please?JUButtonGroupBinding is a custom control provided by JClient and has an api to let a user 'provide' custom Button objects instead of the default 'RadioButton's that would get created if none is passed in. The fact that you could use that to perform LOV kind of indirection of displaying a value other than what's set is 'a side-effect' of the original intention.
FYI, we already implemented an extension to JUComboBoxBinding which is just doing what I was asking for. It is not complex at all:( I was only thinking that it might be useful also in standard...The 'standard' way of getting this behavior you're asking for is to create a programmatic VO as suggested above, with both display/update attribute values and bind it to the ComboBox as an LOV Binding. And yes you can certainly create custom controls extending Swing and use the existing bindings or 'extend' them as per an application need.
Regards,
Adrian

Similar Messages

  • How to Bind a Combo Box so that it retrieves and display content corresponding to the Id in a link table and populates itself with the data in the main table?

    I am developing a desktop application in Wpf using MVVM and Entity Frameworks. I have the following tables:
    1. Party (PartyId, Name)
    2. Case (CaseId, CaseNo)
    3. Petitioner (CaseId, PartyId) ............. Link Table
    I am completely new to .Net and to begin with I download Microsoft's sample application and
    following the pattern I have been successful in creating several tabs. The problem started only when I wanted to implement many-to-many relationship. The sample application has not covered the scenario where there can be a any-to-many relationship. However
    with the help of MSDN forum I came to know about a link table and managed to solve entity framework issues pertaining to many-to-many relationship. Here is the screenshot of my application to show you what I have achieved so far.
    And now the problem I want the forum to address is how to bind a combo box so that it retrieves Party.Name for the corresponding PartyId in the Link Table and also I want to populate it with Party.Name so that
    users can choose one from the dropdown list to add or edit the petitioner.

    Hello Barry,
    Thanks a lot for responding to my query. As I am completely new to .Net and following the pattern of Microsoft's Employee Tracker sample it seems difficult to clearly understand the concept and implement it in a scenario which is different than what is in
    the sample available at the link you supplied.
    To get the idea of the thing here is my code behind of a view vBoxPetitioner:
    <UserControl x:Class="CCIS.View.Case.vBoxPetitioner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:v="clr-namespace:CCIS.View.Case"
    xmlns:vm="clr-namespace:CCIS.ViewModel.Case"
    mc:Ignorable="d"
    d:DesignWidth="300"
    d:DesignHeight="200">
    <UserControl.Resources>
    <DataTemplate DataType="{x:Type vm:vmPetitioner}">
    <v:vPetitioner Margin="0,2,0,0" />
    </DataTemplate>
    </UserControl.Resources>
    <Grid>
    <HeaderedContentControl>
    <HeaderedContentControl.Header>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
    <TextBlock Margin="2">
    <Hyperlink Command="{Binding Path=AddPetitionerCommand}">Add Petitioner</Hyperlink>
    | <Hyperlink Command="{Binding Path=DeletePetitionerCommand}">Delete</Hyperlink>
    </TextBlock>
    </StackPanel>
    </HeaderedContentControl.Header>
    <ListBox BorderThickness="0" SelectedItem="{Binding Path=CurrentPetitioner, Mode=TwoWay}" ItemsSource="{Binding Path=tblParties}" />
    </HeaderedContentControl>
    </Grid>
    </UserControl>
    This part is working fine as it loads another view that is vPetioner perfectly in the manner I want it to be.
    Here is the code of vmPetitioner, a ViewModel:
    Imports Microsoft.VisualBasic
    Imports System.Collections.ObjectModel
    Imports System
    Imports CCIS.Model.Party
    Namespace CCIS.ViewModel.Case
    ''' <summary>
    ''' ViewModel of an individual Email
    ''' </summary>
    Public Class vmPetitioner
    Inherits vmParty
    ''' <summary>
    ''' The Email object backing this ViewModel
    ''' </summary>
    Private petitioner As tblParty
    ''' <summary>
    ''' Initializes a new instance of the EmailViewModel class.
    ''' </summary>
    ''' <param name="detail">The underlying Email this ViewModel is to be based on</param>
    Public Sub New(ByVal detail As tblParty)
    If detail Is Nothing Then
    Throw New ArgumentNullException("detail")
    End If
    Me.petitioner = detail
    End Sub
    ''' <summary>
    ''' Gets the underlying Email this ViewModel is based on
    ''' </summary>
    Public Overrides ReadOnly Property Model() As tblParty
    Get
    Return Me.petitioner
    End Get
    End Property
    ''' <summary>
    ''' Gets or sets the actual email address
    ''' </summary>
    Public Property fldPartyId() As String
    Get
    Return Me.petitioner.fldPartyId
    End Get
    Set(ByVal value As String)
    Me.petitioner.fldPartyId = value
    Me.OnPropertyChanged("fldPartyId")
    End Set
    End Property
    End Class
    End Namespace
    And below is the ViewMode vmParty which vmPetitioner Inherits:
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Collections.Generic
    Imports CCIS.Model.Case
    Imports CCIS.Model.Party
    Imports CCIS.ViewModel.Helpers
    Namespace CCIS.ViewModel.Case
    ''' <summary>
    ''' Common functionality for ViewModels of an individual ContactDetail
    ''' </summary>
    Public MustInherit Class vmParty
    Inherits ViewModelBase
    ''' <summary>
    ''' Gets the underlying ContactDetail this ViewModel is based on
    ''' </summary>
    Public MustOverride ReadOnly Property Model() As tblParty
    '''' <summary>
    '''' Gets the underlying ContactDetail this ViewModel is based on
    '''' </summary>
    'Public MustOverride ReadOnly Property Model() As tblAdvocate
    ''' <summary>
    ''' Gets or sets the name of this department
    ''' </summary>
    Public Property fldName() As String
    Get
    Return Me.Model.fldName
    End Get
    Set(ByVal value As String)
    Me.Model.fldName = value
    Me.OnPropertyChanged("fldName")
    End Set
    End Property
    ''' <summary>
    ''' Constructs a view model to represent the supplied ContactDetail
    ''' </summary>
    ''' <param name="detail">The detail to build a ViewModel for</param>
    ''' <returns>The constructed ViewModel, null if one can't be built</returns>
    Public Shared Function BuildViewModel(ByVal detail As tblParty) As vmParty
    If detail Is Nothing Then
    Throw New ArgumentNullException("detail")
    End If
    Dim e As tblParty = TryCast(detail, tblParty)
    If e IsNot Nothing Then
    Return New vmPetitioner(e)
    End If
    Return Nothing
    End Function
    End Class
    End Namespace
    And final the code behind of the view vPetitioner:
    <UserControl x:Class="CCIS.View.Case.vPetitioner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:vm="clr-namespace:CCIS.ViewModel.Case"
    mc:Ignorable="d"
    Width="300">
    <UserControl.Resources>
    <ResourceDictionary Source=".\CompactFormStyles.xaml" />
    </UserControl.Resources>
    <Grid>
    <Border Style="{StaticResource DetailBorder}">
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Column="0" Text="Petitioner:" />
    <ComboBox Grid.Column="1" Width="240" SelectedValuePath="." SelectedItem="{Binding Path=tblParty}" ItemsSource="{Binding Path=PetitionerLookup}" DisplayMemberPath="fldName" />
    </Grid>
    </Border>
    </Grid>
    </UserControl>
    The problem, presumably, seems to be is that the binding path "PetitionerLookup" of the ItemSource of the Combo box in the view vPetitioner exists in a different ViewModel vmCase which serves as an ObservableCollection for MainViewModel. Therefore,
    what I need to Know is how to route the binding path if it exists in a different ViewModel?
    Sir, I look forward to your early reply bringing a workable solution to the problem I face. 
    Warm Regards,
    Arun

  • Action event automatically triggered for combo box

    Hi all,
    I am facing a typical event handling problem for combo box in Swing(Using Net Beans 5.0, jdk 1.4.2)
    While adding items to combo box it is firing action event twice instead of once irrespective of no. of items added to it.
    For eg if there are 1 or more than 1 item added to combo box it is triggerring action event twice(one just after when first item is added and one again when rest all items are added)
    and if there is no item then also it is triggering once.
    Can you please help me out.
    Thanks

    post the SSCCE code, then only it is easy to find the problem

  • Combo Box missing in the output

    Dear All,
    I cannot find the reason why combo box is not coming in the output. All the other components are coming. Please help me since i am a beginner in java. Please.
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    class update
         public static void main(String[] args)
                   String course[] = {"BCA","MCA","PPC","CIC"};
                   JFrame frame= new JFrame("Update");
                   JPanel panel1= new JPanel();
                   JLabel label1= new JLabel("Client Machine:");
                   JLabel label2= new JLabel("Server Path:");
                   JLabel label3= new JLabel("Client Path:");
                   JLabel label4= new JLabel("UPDATE");                                        
                   label1.setBounds(20,50,150,150);               
                   label1.setForeground(Color.black);
                   label1.setFont(new java.awt.Font("Arial",1,15));                    
                   label2.setBounds(20,80,150,150);               
                   label2.setForeground(Color.black);
                   label2.setFont(new java.awt.Font("Arial",1,15));                              
                   label3.setBounds(20,110,150,150);               
                   label3.setForeground(Color.black);
                   label3.setFont(new java.awt.Font("Arial",1,15));                              
                   label4.setBounds(200,20,150,50);          
                   label4.setForeground(Color.red);
                   label4.setFont(new java.awt.Font("Arial",1,30));                              
                   JComboBox combo= new JComboBox(course);
                   combo.setBackground(Color.gray);
                   combo.setForeground(Color.red);
                   combo.setEditable(true);          
                   panel1.setLayout(null);                                   
                   panel1.add(label1);
                   panel1.add(label2);               
                   panel1.add(label3);
                   panel1.add(label4);
                   panel1.add(combo);                    
                   frame.add(panel1);                    
                   frame.setSize(500,500);     
                   frame.setResizable(false);                                                                 
                   frame.setVisible(true);
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    rahulreigns123 wrote:
    Thanks for your valuable reply. I have tried using the layouts. But that was not a satisfactory output for me. I couldn't get the components in the right positions i need. Then you don't fully understand how to use them yet. That doesn't change the answer that you should learn how to use them and should use them for this program.

  • Alternative for Combo-box

    Hi,
    Combo-BOx is not supported by Forms on web,so I would like to make combo-box my-
    self .. I dont know how but I guess I can
    do it with JAVA. Also I like to prepare it
    exactly same like Oracle COMBO-BOX with
    all functionality ..
    Anybody have any IDEA pl.
    give me respond or
    send me a mail : [email protected]

    Combo-Boxes are supported in the current version of Forms on the Web. (6.0 and 6i)

  • Key commands for part box missing in Logic Pro X

    The manual mentions several key commands for selecting objects in the part box, that would make this a very efficient step time input program, but they don't exist in the key command list.
    Can anyone help? All I want to do is select note or pause values with one hand while inputting pitc from a midi controller keyboard.

    Thanks for this reply. You are correct I am actually running 10.9 and fully up to date on software updates for August 2014. My bad, thought I had taken the most recent option from the drop down menu.
    I have been able to fix the issue but going into Library/ApplicationSupport/Logic and removing the 'drummer' folder. I also went into the plugins folder and removed 'drum presets'. I put all removed files onto a new folder on my desktop.
    When I tried to open a drummer track Logic detected that the files were missing and prompted me to download the missing 'drummer files' once the download was complete, drummer operated correctly with all drummers available again.
    I went back into the file system again and moved some of the drum presets that I had initially moved out (I  had originally acquired these when I first installed Logic and did a lengthy additional content download) that had not re-downloaded back into 'drum presets'. All drumkits were now available too.
    If the issue occurs again I'll take a look at Spotlight file reindexing - would be worth a try and probably quicker. It would make sense that the underlying issue here is one around the drummer sampler code having issues around indexing the sample data.

  • Display Attribute for Combo Box List of Value

    Hi all,
    I am wondering that if even for JDeveloper 12c we need to keep doing this work around https://blogs.oracle.com/adf/entry/combo_lov_how_to_display in order to display a meaningful attribute?
    Regards

    You could, for example. store both of them (old value, along with new one) in the pageFlowScope. You can do that in the valueChangeListener (before calling popup), and use them in the dialog listener...

  • Why will this not work for combo box

    I need to know why this will not work a combobox but it works for text fields. Isay ther is an error in the doc.createTextNode.
    Please any help would be great.
    Thanks
    // Repeats for each Element in the User Configuration.
    item = doc.createElement("COMPANY_NAME"); // Create element
    item.appendChild( doc.createTextNode(SetupCompanyNameJText.getText()) );
    UserConfig.appendChild( item ); // atach element to User Config element
    item = doc.createElement("INTIALS"); // Create element
    item.appendChild( doc.createTextNode(SetupIntialsjComboBox.getSelectedItem()) );
    UserConfig.appendChild( item ); // atach element to User Config element
    item = doc.createElement("FIRST_NAME"); // Create element
    item.appendChild( doc.createTextNode(SetupFirstNamejText.getText()) );
    UserConfig.appendChild( item );

    when I do that I end up with the following
    Error: #:300: class Configuration not found in class
    any ideas
    thanks

  • ArrayCollection for combo box - null vlaue

    I have defined an ArrayCollection like this:
    public var typename:ArrayCollection = new ArrayCollection(["Simple" , "Complex"]);
    In mxml file,
    the usage is,
    <mx:ArrayCollection id = "sample">
    <mx:Object dataField = "type" dataType = "Array" dataProvider = "{com.values.typename}" editable = true updatable = "true"/>
    </mx:ArrayCollection>
    In screen, i get the drop down with a null value. I want only two values dropped down , Simple and Complex.
    Where does this null field come from??

    1. your arrayCollection should be bindable:
    [Bindable]
    public var typename:ArrayCollection = new ArrayCollection(["Simple" , "Complex"]);
    2. What is com.values? Is that a reference to a class? If you store typename in a class, you can do two things:
         a. Store it as a static var:
              public static var typename....
              and then reference it as MyClass.typename
         b. Store it in a singleton class and then reference it as MyClass.getInstance().typename
    3. How do you populate your comboBox? Where is it in your code?
    Dany

  • Plotting a combination chart with a combo box for selection

    Hi:
    I am a newbie using xcelcius and I need help on the following:-
    I need to create a combination chart that plots 3 years data by month, and I need a combo box selection at the top that allows me to select user display for each difference region. I manage to create one that plots only 2008 data with a combo-box selection, but I have no idea how to do it for a combi chart in xcelcius. Any advise?

    Hi Ning,
    I assume your data are like this:
    Region             Year     Jan     Feb     Mar
    APJ             2006     $234.45     $310.34     $321.54
    APJ             2007     $314.35     $319.12     $256.89
    APJ             2008     $425.54     $354.34     $285.73
    North Asia     2006     $534.64     $642.35     $484.64
    North Asia     2007     $631.74     $654.13     $754.34
    North Asia     2008     $754.31     $423.65     $634.32
    South East Asia     2006     $536.42     $576.35     $525.42
    South East Asia     2007     $426.78     $876.43     $643.75
    South East Asia     2008     $634.87     $425.77     $732.43
    If this, you can set the insertion type of combo box is "Filtered Rows", see steps:
    1) For Combo Box, bind General > Labels to the Region column.
    2) Set General > Data Insertion > Insertion Type is "Filtered Rows" (you can refer to following flash to see how "Filtered Rows" works).
    3) Set its Source Data are Year, Jan, Feb, ... columns and Destination to blank cells.
    4) Bind Chart to the destination data.
    Now when you select APJ from Combo Box, it will insert all the rows of APJ data to the desitination cells which will be displayed in Chart.
    Hope this can help!

  • Horizontal scroll bar for combo/lsit box in JSP

    hi,
    i want "Horizontal Scroll bar" for combo box to display long names.
    regards,
    krishna

    Not a JSP issue. Look up styles, CSS, and dynamic HTML. They should help.

  • Determine the best width for ListCellRenderer - Multi-column combo box

    Currently, I am having a multi column combo box. In order for the column to align properly during show popup, I use box layout to do so. However, the short coming for box layout is that, the size for each column is fixed. This makes me have a difficulty, when I have a long string to be displayed. The problem is shown through the following screen shoot.
    http://i.imgur.com/4Nfc6.png
    This is because in 2nd column,
    1) All the 3 rows must be in same size so that they are aligned.
    2) But 1st row and 2nd row cell renderer, do not know 3rd row is holding such a long string.
    The code (2 files) to demo this problem is as follow. Is there any way the size of the cell will be adjusted automatically? Yet, all the row will be aligned properly.
    ResultSetCellRenderer.java
    package javaapplication24;
    import java.awt.Color;
    import java.awt.Component;
    import javaapplication24.NewJFrame.ResultType;
    import javax.swing.JList;
    import javax.swing.ListCellRenderer;
    import javax.swing.UIManager;
    * @author yccheok
    public class ResultSetCellRenderer extends javax.swing.JPanel implements ListCellRenderer {
        /** Creates new form ResultSetCellRenderer */
        public ResultSetCellRenderer() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
            jLabel1.setText("jLabel1");
            jLabel1.setMaximumSize(new java.awt.Dimension(88, 14));
            jLabel1.setMinimumSize(new java.awt.Dimension(88, 14));
            jLabel1.setPreferredSize(new java.awt.Dimension(88, 14));
            add(jLabel1);
            jLabel2.setText("jLabel2");
            jLabel2.setMaximumSize(new java.awt.Dimension(100, 14));
            jLabel2.setMinimumSize(new java.awt.Dimension(200, 14));
            jLabel2.setPreferredSize(new java.awt.Dimension(100, 14));
            add(jLabel2);
        }// </editor-fold>
        // Variables declaration - do not modify
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        // End of variables declaration
        // Do not use static, so that our on-the-fly look n feel change will work.
        private final Color cfc  = UIManager.getColor("ComboBox.foreground");
        private final Color cbc  = UIManager.getColor("ComboBox.background");
        private final Color csfc = UIManager.getColor("ComboBox.selectionForeground");
        private final Color csbc = UIManager.getColor("ComboBox.selectionBackground");
        private final Color cdfc = UIManager.getColor("ComboBox.disabledForeground");
        // For Nimbus look n feel.
        private final Color nimbus_csfc;
             Color c = UIManager.getColor("ComboBox:\"ComboBox.renderer\"[Selected].textForeground");
             // Pretty interesting. Applying "c" directly on the component will not
             // work. I have the create a new instance of Color based on "c" to make
             // it works.
             nimbus_csfc = c != null ? new Color(c.getRed(), c.getGreen(), c.getBlue()) : null;
        private final Color nimbus_csbc;
            Color c = UIManager.getColor("ComboBox:\"ComboBox.renderer\"[Selected].background");
             // Pretty interesting. Applying "c" directly on the component will not
             // work. I have the create a new instance of Color based on "c" to make
             // it works.
            nimbus_csbc = c != null ? new Color(c.getRed(), c.getGreen(), c.getBlue()) : null;
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            final Color _csbc = csbc != null ? csbc : nimbus_csbc;
            final Color _csfc = csfc != null ? csfc : nimbus_csfc;
            this.setBackground(isSelected ? _csbc : cbc);
            this.setForeground(isSelected ? _csfc : cfc);
            jLabel1.setBackground(isSelected ? _csbc : cbc);
            jLabel1.setForeground(isSelected ? _csfc : cfc);
            jLabel2.setBackground(isSelected ? _csbc : cbc);
            jLabel2.setForeground(isSelected ? _csfc : cfc);
            final ResultType result = (ResultType)value;
            jLabel1.setText(result.symbol);
            jLabel2.setText(result.name);
            return this;
    NewJFrame.java
    package javaapplication24;
    import java.awt.Container;
    import java.awt.Dimension;
    import javax.swing.JComboBox;
    import javax.swing.JList;
    import javax.swing.JScrollBar;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    import javax.swing.event.PopupMenuEvent;
    import javax.swing.event.PopupMenuListener;
    import javax.swing.plaf.basic.BasicComboPopup;
    * @author yccheok
    public class NewJFrame extends javax.swing.JFrame {
        public static class ResultType {
             * The symbol.
            public final String symbol;
             * The name.
            public final String name;
            public ResultType(String symbol, String name) {
                this.symbol = symbol;
                this.name = name;
            @Override
            public String toString() {
                return symbol;
        /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
            this.jComboBox1.addPopupMenuListener(this.getPopupMenuListener());
            this.jComboBox1.setRenderer(new ResultSetCellRenderer());
            this.jComboBox1.addItem(new ResultType("Number 1", "Normal"));
            this.jComboBox1.addItem(new ResultType("Number 2", "Normal"));
            this.jComboBox1.addItem(new ResultType("Number 3", "A VERY VERY VERY VERY long text"));
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            jComboBox1 = new javax.swing.JComboBox();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
            jComboBox1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox1ActionPerformed(evt);
            getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 110, -1));
            pack();
        }// </editor-fold>
        private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    final NewJFrame frame = new NewJFrame();
                    frame.setVisible(true);
        private PopupMenuListener getPopupMenuListener() {
            return new PopupMenuListener() {
                @Override
                public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    // We will have a much wider drop down list.
                    adjustPopupWidth(jComboBox1);
                @Override
                public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                @Override
                public void popupMenuCanceled(PopupMenuEvent e) {
         * Adjust popup for combo box, so that horizontal scrollbar will not display.
         * Resize JComboBox dropdown doesn't work without customized ListCellRenderer
         * http://www.camick.com/java/source/BoundsPopupMenuListener.java
         * @param comboBox The combo box
        public static void adjustPopupWidth(JComboBox comboBox) {
            if (comboBox.getItemCount() == 0) return;
            Object comp = comboBox.getAccessibleContext().getAccessibleChild(0);
            if (!(comp instanceof BasicComboPopup)) {
                return;
            BasicComboPopup popup = (BasicComboPopup)comp;
            JList list = popup.getList();
            JScrollPane scrollPane = getScrollPane(popup);
            // Just to be paranoid enough.
            if (list == null || scrollPane == null) {
                return;
            //  Determine the maximimum width to use:
            //  a) determine the popup preferred width
            //  b) ensure width is not less than the scroll pane width
            int popupWidth = list.getPreferredSize().width
                            + 5  // make sure horizontal scrollbar doesn't appear
                            + getScrollBarWidth(popup, scrollPane);
            Dimension scrollPaneSize = scrollPane.getPreferredSize();
            popupWidth = Math.max(popupWidth, scrollPaneSize.width);
            //  Adjust the width
            scrollPaneSize.width = popupWidth;
            scrollPane.setPreferredSize(scrollPaneSize);
            scrollPane.setMaximumSize(scrollPaneSize);
         *  I can't find any property on the scrollBar to determine if it will be
         *  displayed or not so use brute force to determine this.
        private static int getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) {
            int scrollBarWidth = 0;
            JComboBox comboBox = (JComboBox)popup.getInvoker();
            if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) {
                JScrollBar vertical = scrollPane.getVerticalScrollBar();
                scrollBarWidth = vertical.getPreferredSize().width;
            return scrollBarWidth;
         *  Get the scroll pane used by the popup so its bounds can be adjusted
        private static JScrollPane getScrollPane(BasicComboPopup popup) {
            JList list = popup.getList();
            Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
            return (JScrollPane)c;
        // Variables declaration - do not modify
        private javax.swing.JComboBox jComboBox1;
        // End of variables declaration
    }Edited by: yccheok on Jan 13, 2011 9:35 AM

    Are these two lines intentionally or is it just a mismatch?
    jLabel2.setMaximumSize(new java.awt.Dimension(100, 14));
    jLabel2.setMinimumSize(new java.awt.Dimension(200, 14));
    2) But 1st row and 2nd row cell renderer, do not know 3rd row is holding such a long string.There is only one cell renderer for all rows, so no need for the rows to know each other.
    To calculate the exact maximum width of column two, you have to check each entry.
    If you can do this BEFORE creating the combo, you could do this in a loop similar to this pseudo code
    FontMetrics fm= jComboBox1.getFontMetrics(jComboBox1.getFont());
    foreach (column2String) {
      int length= fm.stringWidth(column2String);
      if (length>max) max= length;
    }Now you have a max value to dimension jLabel2 in your renderer.
    If you don't fill your combo in one go, but rather at runtime, you have to check at each
    jComboBox1.addItem(...)
    whether the string for label2 is extending the current max, redefine max, and repaint the combo.
    This second approach I haven't done so far, but that's how I would try.

  • CUIT is not giving name property value for VB combo boxes

    Hi Everyone,
    We are testing simple Vb6 controls using CUIT. Using CUIT we can get name property value of Vb6 button control. But for simple Vb6 combo box, CUIT is not showing name property value.
    I want to add CUIT assertion for combo box name property value. how can I add ?
    For more details please see the image
    Regards,
    Rajendar..

    Hi Rajendar,
    Do you record a coded UI test with the coded UI test builder? If so, which item did you record?
    >>How can I get combobox.SelectedItem without identifying combo box?
    It doesn't mean that we don't identify the control. Generally we use the unique property as the search property to find/capture the control.
    Like this blog here:
    http://blogs.msdn.com/b/visualstudioalm/archive/2012/02/01/guidelines-on-improving-performance-of-coded-ui-test-playback.aspx
    SelectedItems versus
    SelectedIndices property
    For large number of items, it is preferable to use SelectedItems. SelectedIndices essentially does an Instance search internally, which is slower compared to unique automation property based search. Use SelectedIndices only when
    the items don’t have unique Automation properties. And of course exercise caution over changes to the list content.
    I think you could get a useful sample here:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a32bc4a6-f562-436d-96a4-a3409b1b3e73/codedui-and-combobox-i-want-to-go-to-the-next-nonselected-item-in-combobox?forum=vstest
    Best Regards,
    Jack
    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.

  • BC4J binding combo boxes

    Hello all,
    When I bind a combo box to a particular field, and get its values from another table, using
    comboBox.setModel(JUComboBoxBinding.createLovBinding(binding, comboBox, voName, null, voName + "Iter", new String[] { attribName }, lovVOName, new String[] { lovValAttribName }, new String[] { lovDispAttribName }, null, null));
    The combo box becomes editable. I don't want it to be editable, since the value must be one of the ones in the list! Is there any way to make the box uneditable? I tried setEditable(false), and it doesn't appear to work.
    Thanks!

    It's version 9.0.2.822.
    Actually, I told a lie. The box isn't unselectable, it just doesn't display the selection when the list isn't shown.
    So all the combo boxes on my screens look empty, but actually contain selections! And they update the corresponding database row appropriately.
    Perhaps it is a bug in this version; I'll try upgrading.

  • Combo box select default value.

    Hi,
    I am using Combo box to display the status of the document.
    my code is
    oForm = SBO_Application.Forms.Item("I8_BGU_")
                            Dim oCombo1 As SAPbouiCOM.ComboBox
                            oForm.DataSources.UserDataSources.Add("ComboSrc5", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1)
                            'oItem = oForm.Items.Item("21")  ''for accessing the combo box item
                            oCombo1 = oForm.Items.Item("21").Specific
                            '' to bind the combo box item to defined user data source
                            oCombo1.DataBind.SetBound(True, "", "ComboSrc5")
                            ''giving some static values to combobox
                            oCombo1.ValidValues.Add("Open", "Open")
                            oCombo1.ValidValues.Add("Closed", "Closed")
                            oCombo1.ValidValues.Add("Extended", "Extended")
                            ' oCombo.Select("Open")
                            oCombo1.Select("Open", SAPbouiCOM.BoSearchKey.psk_ByValue)
                            oForm.Items.Item("21").Specific.DataBInd.SetBound(True, "@I8_BGU", "U_STATUS")
                            oCombo1.Select("Open")
    In this code when it reaches last lineof line it is throwing  error.
    Object refertence not set to any instance..
    some time it is throwing
    error,,
    " Unble to cast COM object sbouiCom.itemeventClas to Interface Type IItemevent. This application Cal is failed.
    The same logic working form for another form..
    Is there any modification needed.
    Please.. get to me..
    mahi.

    Hi Mahendra,
    In case of selecting a default value in a combo, it has 2 parameters to be passed.  Its as below.
    objCombo.Select(0, SAPbouiCOM.BoSearchKey.psk_Index)
    Replace this with proper value (1st parameter).  It will work.
    I find that you have already used that line.  So you can remove your last line.
    Best Regards,
    satish. B.
    Edited by: satish b on Jan 12, 2010 8:35 AM

Maybe you are looking for