ListComboBox does not reflect Font Change (JComboBox does)

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.

ListComboBox does not reflect Font Change (JComboBox does)

Postby gtt » Wed May 10, 2023 6:27 am

Hi all,

here is another very special behaviour of the ListComboBox that differs from JComboBox and many others.
Given a FontUiResource, ListComboBox.setFont() will ignore it while others do.


[code]import java.awt.Font;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.text.StyleContext;

import com.jidesoft.combobox.ListComboBox;
import com.jidesoft.swing.JideComboBox;

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

JFrame frame = new JFrame("ComboBoxes setFont Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Font myFont = StyleContext.getDefaultStyleContext().getFont("Snap ITC", 0, 12);
String[] items = new String[] { "Option 1", "Option 2", "Option 3" };

// Uses font
JComboBox<String> jComboBox = new JComboBox<String>(items);
jComboBox.setEditable(false);
jComboBox.setFont(myFont);

// Uses font
JideComboBox jideComboBox = new JideComboBox(items);
jideComboBox.setEditable(false);
jideComboBox.setFont(myFont);

// Does not use font
ListComboBox listComboBox = new ListComboBox(items);
listComboBox.setEditable(false);
listComboBox.setFont(myFont);

JPanel panel = new JPanel();
panel.add(jComboBox);
panel.add(jideComboBox);
panel.add(listComboBox);
frame.getContentPane().add(panel);

frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
[code]
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: ListComboBox does not reflect Font Change (JComboBox doe

Postby gtt » Mon May 15, 2023 5:37 am

Is this the right place/context for this topic "ListComboBox"?

- There is a small line in your code, that ignores to set a new setFont(FontUiResource).
- I think if you dismiss this, it will work like JComboBox.
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: ListComboBox does not reflect Font Change (JComboBox doe

Postby JIDE Support » Thu Jul 27, 2023 9:47 am

FontUIResource, or any UIResource value, was meant for internal use by the LookAndFeel. This is my understanding of the UIResource interface. If you want to change the font, do not use UIResource.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: ListComboBox does not reflect Font Change (JComboBox doe

Postby gtt » Wed Aug 23, 2023 7:14 am

Thanks for this understanding, and i will honor your understanding, but....

1. obviously the behaviour of com.jidesoft.swing.JideComboBox/ListComboBox differs from that of javax.swing.JComboBox in that part. And it is only one line of internal code that makes the difference, but for us impossible to change.

2. In order to display all fonts correctly f.e. in multichar languages like chinese, one must use "CompositeFont".
But this derives from FontUiResource. This chinese version produces the problem.
gtt
 
Posts: 311
Joined: Thu Feb 04, 2010 11:42 pm

Re: ListComboBox does not reflect Font Change (JComboBox doe

Postby gtt » Tue Oct 10, 2023 8:04 am

Sorry, but i cant agree...

Please respect this very simple example.
What should be the reason for this different behaviour of ListComboBox in contrast to JComboBox and JideComboBox.
I would expect them to be echangable.


Code: Select all
import java.awt.Font;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.text.StyleContext;

import com.jidesoft.combobox.ListComboBox;
import com.jidesoft.swing.JideComboBox;

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

      JFrame frame = new JFrame("ComboBoxes setFont Example");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      Font myFont = StyleContext.getDefaultStyleContext().getFont("Snap ITC", 0, 12);
      String[] items = new String[] { "Option 1", "Option 2", "Option 3" };

      // Uses font
      JComboBox<String> jComboBox = new JComboBox<String>(items);
      jComboBox.setEditable(false);
      jComboBox.setFont(myFont);

      // Uses font
      JideComboBox jideComboBox = new JideComboBox(items);
      jideComboBox.setEditable(false);
      jideComboBox.setFont(myFont);

      // Does not use font
      ListComboBox listComboBox = new ListComboBox(items);
      listComboBox.setEditable(false);
      listComboBox.setFont(myFont);

      JPanel panel = new JPanel();
      panel.add(jComboBox);
      panel.add(jideComboBox);
      panel.add(listComboBox);
      frame.getContentPane().add(panel);

      frame.pack();
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
   }
}
Attachments
2023-10-10 Fonts in ListComboBox.png
2023-10-10 Fonts in ListComboBox.png (19.42 KiB) Viewed 6061 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: Google [Bot] and 8 guests