|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
NPE in combo boxes with fontHi,
I have some problems with combo boxes in SubstanceRavenLookAndFeel. I get NPE in SubstanceComboBoxUI (e.g. in the method "configureEditor" or in "getMinimumSize") when I set a font while creating the combo box. Though everything works fine when I don't set any font. Since Substance 4.3RC the background of the editable combo box is white and not in the color of our L&F (e.g. blue). With version 4.2 the background is correct (in blue). See the TestApp (ComboBoxTest.java) . Editable combo box with font: Exception in thread "main" java.lang.NullPointerException at javax.swing.plaf.basic.BasicComboBoxUI.configureEditor(BasicComboBoxUI.java:738) at org.jvnet.substance.SubstanceComboBoxUI.configureEditor(SubstanceComboBoxUI.java:705) at javax.swing.plaf.basic.BasicComboBoxUI.addEditor(BasicComboBoxUI.java:695) at javax.swing.plaf.basic.BasicComboBoxUI$Handler.propertyChange(BasicComboBoxUI.java:1604) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:318).... Non-editable combo box with font: Exception in thread "main" java.lang.NullPointerException at org.jvnet.substance.SubstanceComboBoxUI.getMinimumSize(SubstanceComboBoxUI.java:268) at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(BasicComboBoxUI.java:865) at javax.swing.JComponent.getPreferredSize(JComponent.java:1632) at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:702) at java.awt.Container.preferredSize(Container.java:1616) at java.awt.Container.getPreferredSize(Container.java:1601) at javax.swing.JComponent.getPreferredSize(JComponent.java:1634) Sometimes I get this Exception, but I don't know why: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.jvnet.substance.SubstanceComboBoxUI$ComboBoxPropertyChangeHandler$2.run(SubstanceComboBoxUI.java:356) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) package de.or.console.test; import java.awt.BorderLayout; import java.awt.Font; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Vector; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.WindowConstants; import org.jvnet.substance.skin.SubstanceRavenLookAndFeel; public class ComboBoxTest extends JFrame { public static void main(String[] args) { try { UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel()); new ComboBoxTest("Test"); } catch (UnsupportedLookAndFeelException e) { System.out.println(e); } } public ComboBoxTest(String title) { super(title); initGUI(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setLocationRelativeTo(null); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); pack(); setVisible(true); } private void initGUI() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); Vector<String> boxVector = new Vector<String>(); boxVector.add("Test 1"); boxVector.add("Test 2"); JComboBox comboBox = new JComboBox(boxVector); // I get NPE in SubstanceComboBoxUI when I set a font while creating the // combobox. // everything works fine when I don't set any font, here comboBox.setFont(new Font("Verdana", Font.PLAIN, 12)); comboBox.setEditable(true); panel.add(comboBox, BorderLayout.CENTER); getContentPane().add(panel); } } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
|
|
|
Re: NPE in combo boxes with fontHi Kirill, thanks for your reply. Now it works fine. According to the second question, I attached a test app that shows the difference between version 4.2 and 4.3. The white background color of the selected text is also seen in other components (like text field or alike). Do you have any idea? It is not really a problem, but I'm wondered about that. Thanks Tina Kirill Grouchnikov schrieb:
package de.or.console.test; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Vector; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.WindowConstants; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.button.ClassicButtonShaper; import org.jvnet.substance.painter.SimplisticGradientPainter; import org.jvnet.substance.skin.SubstanceRavenLookAndFeel; import org.jvnet.substance.theme.SubstanceComplexTheme; import org.jvnet.substance.theme.SubstanceTheme; import org.jvnet.substance.theme.SubstanceTheme.ThemeKind; import org.jvnet.substance.utils.SubstanceConstants; import org.jvnet.substance.watermark.SubstanceNoneWatermark; public class ComboBoxTest extends JFrame { public static void main(String[] args) { try { initLaF(); } catch (UnsupportedLookAndFeelException e) { System.out.println(e); } SwingUtilities.invokeLater(new Runnable() { public void run() { new ComboBoxTest("Test"); } }); } public static void initLaF() throws UnsupportedLookAndFeelException { UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel()); // DefaultTheme Color[] colors = { Color.white, new Color(150, 150, 150), new Color(170, 170, 170), new Color(130, 130, 130), new Color(100, 100, 100), new Color(76, 76, 76), new Color(101, 101, 101) }; SubstanceTheme tintedRaven = new ColorTheme("DefaultTheme", colors); // active Theme Color[] activeColors = { Color.white, new Color(170, 170, 232), new Color(165, 165, 212), new Color(117, 120, 232), new Color(100, 100, 100), new Color(76, 76, 76), new Color(101, 101, 101) }; SubstanceTheme active = new ColorTheme("ActiveTheme", activeColors); // disabled ColorScheme: Color[] disabledColors = { new Color(167, 167, 167), new Color(150, 150, 150), new Color(170, 170, 170), new Color(130, 130, 130), new Color(100, 100, 100), new Color(76, 76, 76), new Color(101, 101, 101) }; SubstanceTheme disabled = new ColorTheme("DisabledTheme", disabledColors); SubstanceComplexTheme t = new SubstanceComplexTheme("all", ThemeKind.DARK, active, tintedRaven, disabled, tintedRaven.getActiveTitlePaneTheme()); SubstanceRavenLookAndFeel.setCurrentTheme(t); SubstanceRavenLookAndFeel.setCurrentButtonShaper(new ClassicButtonShaper()); SubstanceRavenLookAndFeel.setCurrentGradientPainter(new SimplisticGradientPainter()); SubstanceRavenLookAndFeel.setCurrentWatermark(new SubstanceNoneWatermark()); UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, SubstanceConstants.FocusKind.NONE); UIManager.put(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); UIManager.put(LafWidget.COMBO_BOX_NO_AUTOCOMPLETION, Boolean.TRUE); } public ComboBoxTest(String title) { super(title); initGUI(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); pack(); setLocationRelativeTo(null); setVisible(true); } private void initGUI() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); Vector<String> boxVector = new Vector<String>(); boxVector.add("Test 1"); boxVector.add("Test 2"); JComboBox comboBox = new JComboBox(boxVector); comboBox.setFont(new Font("Verdana", Font.PLAIN, 16)); comboBox.setEditable(true); panel.add(comboBox, BorderLayout.CENTER); getContentPane().add(panel); } } package de.or.console.test; import java.awt.Color; import javax.swing.JComponent; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.color.ColorScheme; import org.jvnet.substance.theme.SubstanceTheme; public class ColorTheme extends SubstanceTheme { public void resetColorToDefault(JComponent button) { button.putClientProperty(SubstanceLookAndFeel.THEME_PROPERTY, SubstanceLookAndFeel.getTheme()); button.repaint(); } protected Color[] colors; public ColorTheme(String name, final Color[] colors) { super(new ColorScheme() { public Color getDarkColor() { return colors[5]; } public Color getExtraLightColor() { return colors[2]; } public Color getForegroundColor() { return colors[0]; } public Color getLightColor() { return colors[3]; } public Color getMidColor() { return colors[4]; } public Color getUltraDarkColor() { return colors[6]; } public Color getUltraLightColor() { return colors[1]; } }, name, ThemeKind.DARK); this.colors = colors; } public void setTheme(JComponent boxButton, SubstanceTheme theme) { boxButton.putClientProperty(SubstanceLookAndFeel.THEME_PROPERTY, theme); boxButton.repaint(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
|
|
|
Re: NPE in combo boxes with fontHi Kirill,
thanks for all. Everything works fine. Substance is really great. I'm looking forward to version 5.0. Special thanks, Tina --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
|
| Free Forum Powered by Nabble | Forum Help |