Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #5043
| From | fnatter <fnatter@gmx.net> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Problems with BasicComboBoxEditor |
| Date | 2012-02-18 10:45 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <238cc9c0-c79b-4909-9f04-3a8a6fdf11bc@k6g2000vbz.googlegroups.com> (permalink) |
| References | <87k43pw2dq.fsf@bitburger.home.felix> <nospam-B28283.22151714022012@news.aioe.org> |
On 15 Feb., 04:15, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article <87k43pw2dq....@bitburger.home.felix>,
> Felix Natter <fnat...@gmx.net> wrote:
>
>
>
>
>
>
>
>
>
> > I am using an editable ComboBox with BasicComboBoxEditor
> > (minimal example attached) with GTK or Nimbus L&Fs:
>
> > JComboBox comboBox = new JComboBox();
> > comboBox.setEditable(true);
> > comboBox.setEditor(new BasicComboBoxEditor());
>
> > I am having two problems with this:
>
> > #1. the first character in the editable combobox (which uses a
> > JTextField internally) cannot show the first letter completely (too
> > few left padding, see attached minimal example)
>
> > #2. The Background color of the editable combo box is white
> > (as opposed to normal comboboxes, which are grey, depending on L&F)
>
> > #1 can be worked around by using a MetalComboBoxEditor (without using
> > metal L&F) instead of the BasicComboBoxEditor. I think this solution
> > is satisfactory, but does there happen to be a better solution?
>
> > #2: Concerning the background color issue, I managed to change the
> > background color of the JTextField:
>
> 1. One approach is to use a compound Border with a suitable left margin:
>
> public ComboBoxEditorWithBGColor() {
> Color c = UIManager.getColor("ComboBox.background");
> editor.setBackground(c);
> editor.setBorder(BorderFactory.createCompoundBorder(
> editor.getBorder(), new EmptyBorder(0, 5, 0, 0)));
> }
That is a perfect solution, don't you want to send this patch to sun/
oracle?
(the BasicComboBoxEditor seems like a real bug to me...)
> 2. Recycling the UI delegate's color(s) seems reasonable, but I'd urge
> minimal tinkering and maximal testing.
>
> Note that you don't need the defaults or a new Color each time, and
> Swing GUI objects should be constructed and manipulated only on the
> event dispatch thread:
Yes, this was just a quick+dirty program ;-)
Thanks a lot and Best Regards,
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Problems with BasicComboBoxEditor Felix Natter <fnatter@gmx.net> - 2012-02-14 22:06 +0100
Re: Problems with BasicComboBoxEditor "John B. Matthews" <nospam@nospam.invalid> - 2012-02-14 22:15 -0500
Re: Problems with BasicComboBoxEditor fnatter <fnatter@gmx.net> - 2012-02-18 10:45 -0800
Re: Problems with BasicComboBoxEditor "John B. Matthews" <nospam@nospam.invalid> - 2012-02-18 21:44 -0500
Re: Problems with BasicComboBoxEditor Lew <lewbloch@gmail.com> - 2012-02-15 09:45 -0800
Re: Problems with BasicComboBoxEditor fnatter <fnatter@gmx.net> - 2012-02-18 10:46 -0800
csiph-web