Results 1 to 4 of 4
  1. #1
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Question [SOLVED] How to set insets for JComboBox.......?

    Hi Members,
    I have to set insets for JCombobox, like we set for textbox and other components. But for JCombobox there is no option of setInsets(); function.
    Please help me in this.
    But we tried by setting border for JCombobox, however we face some look and feel issues, regards to Windows and Linux.

    Looking forward for your reply.

    Regards,
    Prabhu.

  2. #2
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    6

    Default

    Hello Prabhu,
    You will have to override the default ListCellRenderer with your own (or extend the current one) and create an EmptyBorder with the insets you would like..

    JComboBox box = new JComboBox(data);
    ((BasicComboBoxRenderer)box.getRenderer()).setBord er(new EmptyBorder(0,3,0,3));
    To finish sooner, take your own time....
    Nivedithaaaa

  3. #3
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Hi Niveditha,

    Thank you for sharing your views. I will work on it and let you know the result.

    Regards,
    Prabhu.

  4. #4
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Hello Niveditha,
    Thank you very mych, its work fine. The mistake i have made is i dint use that Renderer, I just gave an emptyborder that's it, but now your code works fine.


    Thanks and Regards,
    Prabhu.

Similar Threads

  1. JComboBox and drop-down list.....HELP!!!!!
    By Anna in forum AWT / Swing
    Replies: 1
    Last Post: 06-18-2008, 05:16 AM
  2. Problem with JComboBox and Jlist
    By java_fun2007 in forum New To Java
    Replies: 2
    Last Post: 05-07-2008, 08:58 PM
  3. JComboBox setDisabledTextColor
    By Jack in forum AWT / Swing
    Replies: 2
    Last Post: 07-02-2007, 05:32 AM
  4. Help with jComboBox
    By Marcus in forum AWT / Swing
    Replies: 2
    Last Post: 07-01-2007, 11:08 PM
  5. jcombobox
    By Freddie in forum AWT / Swing
    Replies: 4
    Last Post: 05-11-2007, 12:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •