Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #5013
| From | "John B. Matthews" <nospam@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Problems with BasicComboBoxEditor |
| Date | 2012-02-14 22:15 -0500 |
| Organization | The Wasteland |
| Message-ID | <nospam-B28283.22151714022012@news.aioe.org> (permalink) |
| References | <87k43pw2dq.fsf@bitburger.home.felix> |
In article <87k43pw2dq.fsf@bitburger.home.felix>,
Felix Natter <fnatter@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)));
}
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:
<http://download.oracle.com/javase/tutorial/uiswing/concurrency/initial.html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
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