Long strings in combo box

I have an editable combo box that I'm sticking in a compact spring layout. The problem is if you use a list that contains very long strings (like a long hex string), the combo box sizes itself to fit it and all the other controls are made to be that length as well. Is there a way to stop the control from becoming so long, like a horizontal scroll bar in the list?

Read this [url http://www.objects.com.au/java/examples/src/examples/SteppedComboBoxExample.java]example
Here's its [url http://www.objects.com.au/java/examples/swing/SteppedComboBox.do]picture
ICE

Similar Messages

  • Unchecking "Allow Undefined Strings" for System Combo Box Doesn't Work

    Why will my system combo box still allow undefined strings even after unchecking "Allow Undefined Strings"?
    The combo box works nicely because it allows the user to start typing in the string they want and the combo box will finish it off for them, but if you hit delete or change a letter turning it into an undefined string, the combo box will accept it.
    Edit: I'm using LV 8.5
    Message Edited by Sima on 01-14-2009 07:03 PM
    Message Edited by Sima on 01-14-2009 07:04 PM
    Attachments:
    systemcombobox.vi ‏8 KB

    I don't see the issue with Delete, but Backspace causes what I think you're seeing.  If I type "a" into your example combo box, it autocompletes the "re" in the word "are".  If I hit delete, nothing happens.  If I type other characters, nothing happens.  But, if I hit backspace, then the "re" disappears, leaving just "a".  If I click outside the combo box, the a is left, and a string indicator picks this up.  Thus, the combo box has allowed an undefined string.
    Ouch.  A little help from NI, please?
    Maybe this is what "festo" was seeing here:
    http://forums.ni.com/ni/board/message?board.id=170&requireLogin=False&thread.id=114297
    (no offense intended I figured you were just slowing your code down... but thought it was an opportunity to stop others from starting bad habits with Next Multiple.)
    Certified LabVIEW Architect
    Wait for Flag / Set Flag
    Separate Views from Implementation for Strict Type Defs

  • Combo box popup width adjusting no longer work in 1.0.6_26-b03

    Previously, I was able to adjusting combo box popup's width, by referring to the technique described in [http://tips4java.wordpress.com/2010/11/28/combo-box-popup/|http://tips4java.wordpress.com/2010/11/28/combo-box-popup/]. During that time, I was using 1.0.6_24-b07.
    However, after I update my Java runtime to 1.0.6_26-b03, things broke.
    Here is the screen shoot.
    [Workable screen shoot|http://i.imgur.com/0elo7.png]
    [Not workable screen shoot|http://i.imgur.com/BeKMy.png]
    Here is the code snippet to demonstrate this problem.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * NewJFrame.java
    * Created on Aug 9, 2011, 4:13:41 AM
    package experiment;
    import java.awt.Component;
    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 {
         * 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;
            Component component = popup.getInvoker();
            if (component instanceof JComboBox) {
                JComboBox comboBox = (JComboBox)component;
                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;
        /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
            this.jComboBox1.addPopupMenuListener(getPopupMenuListener());
        /** 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);
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4", "This is a very long text. This is a very long text" }));
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(82, 82, 82)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(242, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(34, 34, 34)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(246, Short.MAX_VALUE))
            pack();
        }// </editor-fold>
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().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) {
        // Variables declaration - do not modify
        private javax.swing.JComboBox jComboBox1;
        // End of variables declaration
    }

    I had came across another workaround as stated here.
    [http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough|http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough]
    The popup's is having enough width to show all items. However, it is not perfect still, as the width is little too much. I still can see some extra space at the tailing of the list.
    The workaround is as follow.
    import javax.swing.*;
    import java.awt.*;
    import java.util.Vector;
    // got this workaround from the following bug:
    //      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4618607
    public class WideComboBox extends JComboBox{
        public WideComboBox() {
        public WideComboBox(final Object items[]){
            super(items);
        public WideComboBox(Vector items) {
            super(items);
        public WideComboBox(ComboBoxModel aModel) {
            super(aModel);
        private boolean layingOut = false;
        public void doLayout(){
            try{
                layingOut = true;
                super.doLayout();
            }finally{
                layingOut = false;
        public Dimension getSize(){
            Dimension dim = super.getSize();
            if(!layingOut)
                dim.width = Math.max(dim.width, getPreferredSize().width);
            return dim;
    }

  • COMBO BOX STRING

    Hi all,
    The string displayed in the combo box is in the left side, is there a method to move it to centre.
    without giving spaces before the string in the edit items.
    The image is attached below
    Solved!
    Go to Solution.
    Attachments:
    combo box.JPG ‏5 KB

    Hello Shrekt,
    set the focus to your combo box (mouse click on it) and then change its text properties.
    Attachments:
    Temp.png ‏16 KB

  • Combo box strings

    I am trying to get some combo boxes to have their entries populated by a text file. I've read many forum entries about the 'strings[]' property, it but it refuses to work for me. I want the combo box to be modifiable by changing entries in a text file.
    Can someone beat this code into submission? I get this error about a GPIB controller needing to be in charge.
    I've included the vi, the text file I want to populate the 'Version Number' combo box and that should be it.
    Tay
    Solved!
    Go to Solution.
    Attachments:
    Event Inspection.zip ‏662 KB
    test.txt ‏1 KB

    On a sidenote, you have some serious coding mistakes. For example look at the following code.
    I would think that the "select" node should act according to the current value of the boolean. WIth your current code, it is very likely that you read the stale value from the property node before the Pass/Fail indicator has received the new value. This is a classic race condition.
    Don't be afraid to branch a wire! The property node is entirely useless and actually is computationally expensive. All you need is a wire. Right? The wire creates a data dependency that ensures correct execution order.
    (See also http://forums.ni.com/ni/board/message?board.id=BreakPoint&view=by_date_ascending&message.id=5178#M51...)
    Message Edited by altenbach on 04-20-2008 01:05 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    RaceConditionAnnotated.png ‏11 KB

  • Cosmetic Glitch when Replacing a Silver Style Combo Box by a String

    As the title says, if you replace a Silver Style Combo Box by a String (same data type), things turn ugly:
    Nothing of the sort happens with the other styles as can be seen above too.

    Hi X
    Yea I get the same behavior in 2012 and 2013. A workaround for this would be to replace the original control or indicator with a non-silver version of the control and then replace that control with the desired silver style control. This seems to work for me.
    Paolo F.
    National Instruments
    Applications Engineer

  • Combo Box, Converting string to int

    The user is able to select the month, year etc for a TimerTask using a combo box.
    The problem I have is converting say, "January" to an integer 0 for use to set in a calendar for the date.
    The combo box is populated with every month but i cannot link it with the int variable "month" where 0= january, 1- feb etc for use in the TimerTask.
    In other words, when the user selects "January" in the combo box i want the integer value for the variable "month" to equal 0, for "Febuary", month to equal 1, "March", month equal 2 etc etc.
    Any help would be excellent!!

    if January is the first item in the box, February is the second, all the way to December:
    month = monthComboBox().getSelectedIndex();

  • How to get values of combo box?

    Hi All,
    I had a problem that need to be solve asap. I would be very appreciated if anyone could help me.
    I had a combo box that contain a string "Flower and Gifts" and when i passed the value to another jsp file it show only "Flower". I had been think for a long time about this problem. How can i pass the value to another jsp file with the whole value "Flower and Gifts".
    Please reply asap. Thanks all.

    Hi,
    Even i had the same problem earlier. Just try to print the string that you are passing to the next page, if it reads something like this "Flowers%20and%20Gifts" then you have to replace the special characters (i.e.,'%,2,0')with the blank spaces so that you have the complete string.
    Example:
    String str = "Flowers%20and%Gifts";
    if(str.indexOf('%')!=-1)
    str = str.replace('%','');
    Thanks,
    Rkanth

  • LOV's in form combo box - how to change font size?

    Greetings:
    I've a table generated form (custom vs. tabular), with a combo-box field that fills with a LOV's that has as it's visible data, a rather long concatenated string. Therefore, this field makes the entire form rather wide when the LOV's contains a long string (as returned from the SQL that gathers the data).
    I've tried using the FONT tag in the 2nd tab (Form wizard) for custom layouts; that didn't work.
    Anyone have ideas for decreasing the font size of the LOV's? Else, I'll have to leave-out some of the info concatenated on that string.
    As always, thanks for you continued guidance and support...
    Ed in Tampa

    Hi,
    Changing the font size and other properties like font color, width, height, etc.. of the form elements can be achieved by using Cascading Style Sheet (CSS).
    It cannot be changed using <FONT> tag.
    In Portal, one can add the CSS attribute to the HTML tags in the custom layout of the form. But adding the CSS attribute to FORM elements (Input, select..)is not possible through Form wizards.
    However, this can be achieved by creating a form through the Dynamic Page. In this case you have to define your whole form.
    To know more about CSS you can visit: http://www.mako4css.com
    Thanks,
    Shivank

  • 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.

  • Multiline combo box

    Hi All,
    We have a project where we are using combo boxes in our UI. However, for some of the texts, the drop down menu becomes too long. I was wondering if it could be made multiline. I tried binding combo box to a textbox which has multiline display instead of binding it to a string control; but the combo box was not added to the textbox control. What should I be doing ? Should I modify the combobox control ? or is there an equivalent control which me help me achieve the functionality ?
    Thanks,
    Kanu

    Kanu:
    I'm not picturing what you have in mind.
    Would a tree menu work?  Look at the example project treemenu.cws that ships with CVI.
    How often does the operator need to enter something instead of just selecting the dropdown options?
    There are multiple ways you could allow the operator to still enter (rather than select) something for or from a menu. (Menu item for a custom entry, right-click on an entry, popups, etc.)
    Can you post a picture of what you have in mind and explain why a standard combobox won't work?

  • Drop down menu or combo box in jtable

    Hi there I nee urgent help I have a jtable and I am collecting information to populate the table dynamically, the problem is I some of the strings that populate certain cells is longer the the width of the cell in a particular column, I thought I could use a combo box and split the strings up so I could have some type of drop down menu showing the information, but when I populate the combo box and instantiate the defaultcell renderer with the combobox it sets all cells in that column with the same information I would like to have it displaying the actual information for every row within that column
    or if you can give me any ideas as to how I can avoid this happening or maybe an alternative method of showing these long strings in the table some kind of drop down.
    Kind Regards Michael

    the problem is I some of the strings that populate certain cells is longer the the width of the cell in a particular column,Set a tooltip to display the entire text of the cell. Here is a simple example;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TableToolTip extends JFrame
         public TableToolTip()
              Object[][] data = { {"1234567890qwertyuiop", "A"}, {"2", "B"}, {"3", "C"} };
              String[] columnNames = {"Number","Letter"};
              JTable table = new JTable(data, columnNames)
                   public String getToolTipText( MouseEvent e )
                        int row = rowAtPoint( e.getPoint() );
                        int column = columnAtPoint( e.getPoint() );
                        Object value = getValueAt(row, column);
                        return value == null ? null : value.toString();
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              TableToolTip frame = new TableToolTip();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(150, 100);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }If you want to get fancier than you could set the tooltip text only when the width of the text is greater than the width of the column. Here is an example of this is done with a text field. You would need to modify the code to refer the to table for the text string and the TableColumn for the width.:
    JTextField textField = new JTextField(15)
         public String getToolTipText(MouseEvent e)
              FontMetrics fm = getFontMetrics( getFont() );
              String text = getText();
              int textWidth = fm.stringWidth( text );
              return (textWidth > getSize().width ? text : null);
    textField.setToolTipText(" ");
    I thought I could use a combo box and split the strings up so I could have some type of drop down menu showing the informationIf you want to proceed with this approach then check out this posting:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=637581

  • Auto Complete Combo Boxes?

    Does anyone know of auto-completing combo boxes written in Java? I have a dirty hack that sort of works, but if you type too fast the caret jumps to the end of the text it thinks you are typing instead of selecting the characters that you haven't typed yet.
    Any help would be greatly appreciated.

    Jrabi,
    Below is the code for KComboBoxes. Please be aware that this code comes with NO guarantee. It works for me, but that doesn't necessarily mean that it will work for you. If you have any questions about the code I will be happy to answer them. Make sure that once you create an instance of KComboBox that you set it as editable or the auto complete function won't work.
    package pubprint; //make this package whatever your package is
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    * Title: <BR>
    * Description: <BR>
    * Copyright: Copyright (c) 2002<BR>
    * Company: <BR>
    * @author Kevin J. Keen
    * @version 0.5
    public class KComboBox extends JComboBox implements KeyListener {
    private ComboBoxModel myModel;
    private KeySelectionManager myKeyManager;
    private ComboBoxEditor myEditor;
    private JTextField txtEditor;
    private long timeOfLastEvent = 0;
    //Constructors
    public KComboBox() {
    super();
    myModel = super.getModel();
    myKeyManager = super.getKeySelectionManager();
    myEditor = super.getEditor();
    txtEditor = (JTextField)myEditor.getEditorComponent();
    txtEditor.addKeyListener(this);
    public KComboBox(ComboBoxModel daModel) {
    super(daModel);
    myModel = super.getModel();
    myKeyManager = super.getKeySelectionManager();
    myEditor = super.getEditor();
    txtEditor = (JTextField)myEditor.getEditorComponent();
    txtEditor.addKeyListener(this);
    public KComboBox(Object[] items) {
    super(items);
    myModel = super.getModel();
    myKeyManager = super.getKeySelectionManager();
    myEditor = super.getEditor();
    txtEditor = (JTextField)myEditor.getEditorComponent();
    txtEditor.addKeyListener(this);
    public KComboBox(Vector items) {
    super(items);
    myModel = super.getModel();
    myKeyManager = super.getKeySelectionManager();
    myEditor = super.getEditor();
    txtEditor = (JTextField)myEditor.getEditorComponent();
    txtEditor.addKeyListener(this);
    //Key listener methods
    public synchronized void keyReleased(KeyEvent e) {
    if(e.getKeyCode() == KeyEvent.VK_SHIFT || e.getKeyCode() == KeyEvent.VK_TAB) {
    return;
    //This IF/ELSE is necessary because without it
    //you can out-type the auto complete and get
    //really weird behavior.
    if((e.getWhen() - timeOfLastEvent) < 100) {
    return;
    else {
    timeOfLastEvent = e.getWhen();
    String temp = txtEditor.getText();
    int hashCode = temp.hashCode();
    for(int i = 0; i < myModel.getSize(); i++) {
    String contents = (String)myModel.getElementAt(i);
    if(contents.startsWith(temp)) {
    int selectionStart = txtEditor.getCaretPosition();
    int selectionEnd = (contents.length());
    //Check to make sure that the value in the text field hasn't changed
    if(txtEditor.getText().hashCode() == hashCode) {
    setSelectedItem(contents);
    selectedItemChanged();
    txtEditor.setSelectionStart(selectionStart);
    txtEditor.setSelectionEnd(selectionEnd);
    return;
    else {
    return;
    public void keyPressed(KeyEvent e) {}
    public void keyTyped(KeyEvent e) {}
    }

  • How to populate data in the data table on combo box change event

    hi
    i am deepak .
    i am very new to JSF.
    my problem is i want to populate data in the datatable on the combo box change event.
    for example ---
    combo box has name of the city. when i will select a city
    the details of the city should populate in the datatable. and if i will select another city then the datatable should change accordingly..
    its urgent
    reply as soon as possible
    thanks in advance

    i am using Rational Application Developer to develop my application.
    i am using a combo box and i am assigning cityName from the SDO.
    and i am declaring a variable in the pageCode eg.
    private String cityName;
    public void setCityName(String cityName){
    this.cityName = cityName;
    public String getCityName(){
    return cityName;
    <h:selectOneMenu id="menu1" styleClass="selectOneMenu" value="#{pc_Test1.loginID}" valueChangeListener="#{pc_Test1.handleMenu1ValueChange}">
                        <f:selectItems
                             value="#{selectitems.pc_Test1.usercombo.LOGINID.LOGINID.toArray}" />
                   </h:selectOneMenu>
                   <hx:behavior event="onchange" target="menu1" behaviorAction="get"
                        targetAction="box1"></hx:behavior>
    and also i am declaring a requestParam type variable named city;
    and at the onChangeEvent i am writing the code
    public void handleMenu1ValueChange(ValueChangeEvent valueChangedEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    Map requestScope = ext.getApplication().createValueBinding("#{requestScope}").getValue(context);
    requestScope.put("login",(String)valueChangedEvent.getNewValue());
    and also i am creating another SDO which is used to populate data in datatable and in this SDO in the where clause i am using that requestParam .
    it is assigning value in the pageCode variable and in the requestParam but it is not populating the dataTable. i don't no why??
    it is possible that i may not clear at this point.
    please send me the way how my problem can be solved.
    thanks in advance

  • 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

Maybe you are looking for

  • Mail App dead after Leopard upgrade + 10.5.6 update

    Has anyone else ended up with a dead Mail app after upgrading to Leopard and applying the 10.5.6 update? Mail app would appear to launch, but would not run or quit. Reinstalling the 10.5.6 combo update didn't help. I had to reinstall Leopard from scr

  • Mail Settings

    Still new to macmail..and having a problem with sending mail. For some reason the SEND tab will not activate. I can not click it after I am ready to send mail.... ALso sometimes emails are slow to come in while i can log on to my charter account and

  • UCCX 7.0 - Access db_cra in standalone installs

    Hi,      We have UCCX 7.0(1)SR5_Build 504. This version is installed  as a stand alone box for testing environemnt. Now, I would like to view the tables/views etc the underlying db_cra database in this standalone install. How do I achieve this since

  • FRM-40400 No changes to apply

    Dear friends, I'm using a button to do a commit_form, i have 3 blocks (2 database blocks, 1 non database block). when ever i push the button for the first time it commits the form without any messages, but after that it always shows (FRM-40400 No cha

  • All Icons and Fonts have doubled in Size on my Iphone 3 GS

    I have a problem with my Iphone 3GS 32 GIG model. I do not know what I pressed but I have turned all the Icons and fonts to double in size and now I can't see the Settings Icon properly because of the inflated size of all the icons and fonts. Could s