JideComboBox preferredSize not correct

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

JideComboBox preferredSize not correct

Postby gtt » Sat Nov 06, 2021 2:14 pm

JideComboBox preferredSize not correct (3.7.12) (Changing to JComboBox behaves correctly)

{code}

import com.jidesoft.swing.JideComboBox;

/**
* Very primitive test exapmple for preferredSize of a JideComboBox
* JFAST-6734
* @author olb 11/2021
*/
public class JideComboBoxtest {
public static void main(String[] args) {

// This text is not displayed completely
String [] items = {"Mein"};
JideComboBox cb = new JideComboBox(items)
{ // ... unless getPreferredSize() is slightly modified
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
return new Dimension(d.width+1, d.height);
}
}
;

JFrame frame = new JFrame();
JPanel panel = new JPanel(new FlowLayout());
panel.add(cb);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}
{code}
Attachments
prefSize ohne Korrektur.png
prefSize ohne Korrektur.png (7.92 KiB) Viewed 22423 times
prefSize mit Korrektur.png
prefSize mit Korrektur.png (7.3 KiB) Viewed 22423 times
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby gtt » Thu Dec 23, 2021 7:54 am

what about my prevoius post?
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby JIDE Support » Thu Dec 23, 2021 11:16 am

There is a miscalculation in the preferred size. We will fix it. Before it, you can use your workaround for now.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideComboBox preferredSize not correct

Postby gtt » Fri Dec 24, 2021 2:51 am

Ok, thanks for this shorttime answer,
but please keep in mind we are selling a Low Code platform which extremely depends on
customizable swing beans (components) and a lot of internal customizable features and
layouts depend on the size behaviour of each other.

Therefore this is important for us.

kindly regards markus
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby JIDE Support » Tue Feb 22, 2022 7:13 pm

Just so you know, this bug is fixed in the latest 3.7.13 release.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideComboBox preferredSize not correct

Postby gtt » Thu Mar 03, 2022 11:23 am

Thank you for prompt reaction,

so i switched to 3.7.13 but unfortunatly nothing changed.

Again: This ist the very very simple example that produces a non complete text "Mein"
if i use JideComboBox.

Switching to JComboBox it shows a complete Text, fine.

Example 1:

public class JideComboBoxtest {
public static void main(String[] args) {

// This text is not displayed completely
String [] items = {"Mein"};
JideComboBox cb = new JideComboBox(items);
// JComboBox cb = new JComboBox(items);

JFrame frame = new JFrame();
JPanel panel = new JPanel(new FlowLayout());
panel.add(cb);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}
}



Example 2: This is also very important : Only a little bit more complex.
JComboxBox renders fine, JideComboBox doesnt.


public class JideComboBoxtest {
public static void main(String[] args) {

// This text is not displayed completely
String [] items = {"Mein"};
JideComboBox cb = new JideComboBox(items);
// JComboBox cb = new JComboBox(items);

cb.setRenderer(new BorderListCellRenderer(20));

JFrame frame = new JFrame();
JPanel panel = new JPanel(new FlowLayout());
panel.add(cb);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}

static class BorderListCellRenderer implements ListCellRenderer {
private Border insetBorder;
private DefaultListCellRenderer defaultRenderer;

public BorderListCellRenderer(int rightMargin) {
this.insetBorder = new EmptyBorder(0, 2, 0, rightMargin);
this.defaultRenderer = new DefaultListCellRenderer();
}

@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {

JLabel renderer = (JLabel) defaultRenderer
.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
renderer.setBorder(insetBorder);
JPanel p = new JPanel(new BorderLayout());
p.add(BorderLayout.CENTER, new JLabel(value.toString()));
p.add(BorderLayout.EAST, new JLabel(NamedIcon.ARROW_DOWN.getImageIcon()));
return p;
}
}
}
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby JIDE Support » Fri Mar 04, 2022 12:02 am

Thanks. I need to do some further fix.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideComboBox preferredSize not correct

Postby gtt » Thu Dec 15, 2022 9:05 am

ok please do so..
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby gtt » Thu Dec 29, 2022 6:12 am

JIDE Support wrote:Thanks. I need to do some further fix.


Dear JIDE Team, what about this case?
Is there yet another solution?

kindly regards markus
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby JIDE Support » Thu Dec 29, 2022 10:59 pm

Can you please check if http://www.jidesoft.com/downloads/archi ... 3.7.14.zip fixed the issue?
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideComboBox preferredSize not correct

Postby gtt » Tue Jan 03, 2023 5:25 am

Wish a good year 2023 ...

Using your Update the example renders much better using text only.
But in addition with the image its ok in X but not ok in Y.

Ok, im awaiting your next version update.



See Screenshots of JComboBox and JideComboBox.

Code: Select all
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;

import com.jidesoft.swing.JideComboBox;


/**
 * Very primitive test example for preferredSize of a JideComboBox
 *
 * JFAST-6734
 *
 * @author olb 11/2021
 */
public class JideComboBoxtest {
   public static void main(String[] args) {
      
      // This text is not displayed completely
      String [] items = {"Mein Text "};
      JideComboBox cb = new JideComboBox(items);
//      JComboBox cb = new JComboBox(items);
      
      cb.setRenderer(new BorderListCellRenderer());

      JFrame frame = new JFrame();
      JPanel panel = new JPanel(new FlowLayout());
      panel.add(cb);
      frame.add(panel);
      frame.pack();
      frame.setVisible(true);
   }
   
   static class BorderListCellRenderer implements ListCellRenderer {
       private DefaultListCellRenderer defaultRenderer;
       public BorderListCellRenderer() {
           this.defaultRenderer = new DefaultListCellRenderer();
       }
       @Override
       public Component getListCellRendererComponent(JList list, Object value,
               int index, boolean isSelected, boolean cellHasFocus) {                    
          JLabel renderer = (JLabel) defaultRenderer
                   .getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
          JPanel p = new JPanel(new BorderLayout());
          p.add(BorderLayout.CENTER, new JLabel(value.toString()));
          // ########################################################################
          p.add(BorderLayout.EAST, new JLabel(new ImageIcon(loadImage("paste.gif"))));
          // ########################################################################
           return p;
       }
   }
   
   // Load image as Ressource
   public static byte[] loadImage(String iconPath) {
      byte[] iconData=null;
      try {
         InputStream in = JideComboBoxtest.class.getClassLoader()
            .getResourceAsStream(iconPath);
         if (in == null) {
            in = new FileInputStream(iconPath);                        
         }
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         int nextByte;
         while ((nextByte = in.read()) != -1) {
            bos.write(nextByte);
         }
         iconData = bos.toByteArray();
         in.close();
      } catch (IOException exc) {
         System.out.println(exc);
      }
      return iconData;
   }
}

Attachments
paste.gif
paste.gif (159 Bytes) Viewed 12496 times
2023-01-03 JComboBox Look.png
2023-01-03 JComboBox Look.png (7.98 KiB) Viewed 12496 times
2023-01-03 JideComboBox Look.png
2023-01-03 JideComboBox Look.png (7.35 KiB) Viewed 12496 times
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby gtt » Mon Jan 09, 2023 3:05 pm

could you please make a new suggestion or at least have a look and comment it.
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby JIDE Support » Mon Jan 09, 2023 6:27 pm

I am working on it and just want to achieve something before telling you.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideComboBox preferredSize not correct

Postby gtt » Thu Apr 06, 2023 12:27 am

Is there something new here?
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby gtt » Wed Jun 07, 2023 11:40 pm

*Urgent request for support*

We have been waiting for month now coming closer to our new Release Cadidate
and urgently need the fixed JIDE Release!
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: JideComboBox preferredSize not correct

Postby JIDE Support » Thu Jul 27, 2023 10:30 am

JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideComboBox preferredSize not correct

Postby gtt » Tue Oct 10, 2023 7:25 am

Thanks, a lot, i could test it today and it looks much better.

It could need a little attention to the space beetween text and icon.

In my example there ist a "Mein Text " (with an unusual trailing blank).
If you omit this blank, it looks bad, because there is no space beetween text and icon.

But Java Swing JComboBox renders it perfectly.

Test change: only skip this trailing blank and start with JCombobox and then JideComboBox.
Also check ListComboBox, it doesnt show the icon at all.

regards markus
Attachments
2023-10-10 JideComboBox_preferredSizeTest.png
2023-10-10 JideComboBox_preferredSizeTest.png (12.15 KiB) Viewed 6485 times
2023-10-10 ListComboBox_preferredSizeTest.png
2023-10-10 ListComboBox_preferredSizeTest.png (11.46 KiB) Viewed 6485 times
2023-10-10 JComboBox_preferredSizeTest.png
2023-10-10 JComboBox_preferredSizeTest.png (9.77 KiB) Viewed 6485 times
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 8 guests