Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: JComboBox is not displaying properly in GroupLayout

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JComboBox is not displaying properly in GroupLayout

    Last edited by sundeep; June 25th, 2013 at 10:41 PM. Reason: More complex


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    979
    Thanks
    7
    Thanked 206 Times in 182 Posts

    Default Re: JComboBox is not displaying properly in GroupLayout

    It might be a good idea to post a small, compilable, example which illustrates the problem. (for instance you don't need the list cell renderer unless it contributes to the problem). And say what it means for the combobox to not be displayed "properly".

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JComboBox is not displaying properly in GroupLayout

    Thank you for your reply!!..
    My problem is JComboBox is not working as i required, like i need to select some data and it should be focus on that list.
    JComboBox domainNamesBox = new JComboBox();
    domainNamesBox.setModel(new DefaultComboBoxModel(new String[] {"a", "b", "c", "d"}));
    //Arrange the above GUI components to GroupLayout...
    GroupLayout gl_contentPane = new GroupLayout(contentPane);
    gl_contentPane.setHorizontalGroup(
    gl_contentPane.createParallelGroup(Alignment.TRAIL ING)
    .addGroup(gl_contentPane.createSequentialGroup()
    .addContainerGap()
    .addGroup(gl_contentPane.createParallelGroup(Align ment.TRAILING, false)
    .addComponent(lblDomainName, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addGap(18)
    .addGroup(gl_contentPane.createParallelGroup(Align ment.LEADING)
    .addComponent(domainNamesBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
    .addGap(41))))
    );
    gl_contentPane.setVerticalGroup(
    gl_contentPane.createParallelGroup(Alignment.TRAIL ING)
    .addGroup(gl_contentPane.createSequentialGroup()
    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addGroup(gl_contentPane.createParallelGroup(Align ment.TRAILING)
    .addComponent(domainNamesBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    .addComponent(lblDomainName))
    .addPreferredGap(ComponentPlacement.RELATED)
    .addContainerGap())
    );

    PFA enclosed on following thread :-)

  4. #4
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JComboBox is not displaying properly in GroupLayout

    we have to use method for comboBox.updateUI(). it will work as it is.

  5. #5
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    979
    Thanks
    7
    Thanked 206 Times in 182 Posts

    Default Re: JComboBox is not displaying properly in GroupLayout

    If you are still having problems with this consider my suggestion of posting a SSCCE and a description of what the problem is: ie how the output or other behaviour of the program differs from your intentions.

    It's not my (vain) intention to tell you how to post. But, for my part, I need code, not images. And some elaboration about what "not displaying properly" means.

Similar Threads

  1. Help With JComboBox
    By Olympaphibian89 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 6th, 2012, 08:06 PM
  2. JComboBox
    By ikocijan in forum What's Wrong With My Code?
    Replies: 9
    Last Post: July 16th, 2012, 07:35 AM
  3. [SOLVED] JCombobox help
    By sman36 in forum AWT / Java Swing
    Replies: 10
    Last Post: August 11th, 2010, 05:11 AM
  4. JComboBox
    By nasi in forum AWT / Java Swing
    Replies: 1
    Last Post: April 29th, 2010, 09:40 AM