linux - Java JComboBox Custom Renderer and GTK -


I have a list of customer objects, for which I have to choose from jesimbobox. What I read is that I want to apply a custom renderer to the fields I want to display in the list

I want to make a formatted entry like my JComboBox:

  + ---------------------------------------------- + | Customer Name - Contact - City, State V. + =============================================== | Customer # 2 Name - Contact - City, State | | Customer # 3 Name - Contact - City, State | | Customer # 4 Name - Contact - City, State | | Customer # 5 Name - Contact - City, State | + ---------------------------------------------- +  

I used this code:

public class CustomerListCellRenderer extends DefaultListCellRenderer {

  @Override public component getListCellRendererComponent (JList list, object value , Int index, boolean isSelected, boolean cellHasFocus) {super.getListCellRendererComponent (list, value, index, isSelected, cellHasFocus); If (value example customers) {customer C = (customer) value; Stringbuffer sb = new stringbuffer (); If (c.getCompany ()! = Null & amp; amp; c.getCompany (). Length ()> gt; {sb.append (c.getCompany ());} Sb.append ( "-"); If (c.getCompany ()! = Null & amp; amp; amp; c.getCompany (). length () & gt; {) sb.append (c.getContact ());} Sb.append ( "-") ; If (c.getCompany ()! = Null & amp; amp; amp; c.getCompany () Length ()> gt; {sb.append (c.getCity ()); Sb.append (",");} If (c.getCompany ()! = Null & amp; amp; c.getCompany (). length ()> 0) {sb.append (c.getState ());} SetText (sb.toString ());} this return;}}  

the system Solaris / UNIX / under Linux does not work correctly, it went not set against the backdrop of the input field system GTKLookAndFeel Konbboks and around o No limit has been created (see screenshot below). Is there another way to achieve that will work correctly in 3 major platforms (Win / Mac / GTK)? I do this and only manipulate data Can not a converter do the GUI?

The format of my current solution is to override the toString (on my client object) to display each record in I want, but the bottom Other thoughts in the rage.

The same issue, I did this in order to show the symbol To customize it:

  Custom static class extends the CustomComboBoxRenderer DefaultListCellRenderer {Private Final ListCellRenderer backend; Public CustomComboBoxRenderer (ListCellRenderer backend) {this.backend = backend; } @Override public component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, Boolean cellHasFocus) {component = backend.getListCellRendererComponent (list, value, index, isSelected, cellHasFocus); If (JLLL == incorrect) component = super.gettest cell render component (list, value, index, selected, cellophobia); JLabel label = (JLabel) component; Label.setIcon (Icons.COMPONENT); return label; }}  

Then assigned to renderer like this:

  comboBox.setRenderer (new CustomComboBoxRenderer (comboBox.getRenderer ()));  

It has done fine work for me so far.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -