1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2010 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
33 |
|
|
34 |
import org.jsampler.view.fantasia.Res; |
import org.jsampler.view.fantasia.Res; |
35 |
|
|
36 |
import org.jvnet.substance.SubstanceLookAndFeel; |
import org.pushingpixels.substance.api.SubstanceLookAndFeel; |
37 |
|
import org.pushingpixels.substance.api.combo.ComboPopupPrototypeCallback; |
38 |
|
|
39 |
/** |
/** |
40 |
* |
* |
43 |
public class FantasiaComboBox extends JComboBox { |
public class FantasiaComboBox extends JComboBox { |
44 |
public |
public |
45 |
FantasiaComboBox() { |
FantasiaComboBox() { |
|
setUI(new FantasiaComboBoxUI()); |
|
46 |
setOpaque(true); |
setOpaque(true); |
47 |
setBackground(new java.awt.Color(0x818181)); |
setBackground(new java.awt.Color(0x818181)); |
48 |
setBorder(BorderFactory.createEmptyBorder()); |
setBorder(BorderFactory.createEmptyBorder()); |
49 |
setRenderer(new FantasiaListCellRenderer()); |
setRenderer(new FantasiaListCellRenderer()); |
50 |
putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); |
//putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); |
51 |
//putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); |
//putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); |
52 |
//putClientProperty(SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY, Boolean.TRUE); |
//putClientProperty(SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY, Boolean.TRUE); |
53 |
} |
} |
54 |
|
|
55 |
|
@Override |
56 |
|
public void |
57 |
|
updateUI() { setUI(new FantasiaComboBoxUI(this)); } |
58 |
|
|
59 |
|
public static class WidestComboPopupPrototype implements ComboPopupPrototypeCallback { |
60 |
|
@Override |
61 |
|
public Object |
62 |
|
getPopupPrototypeDisplayValue(JComboBox jc) { |
63 |
|
Object prototype = ""; |
64 |
|
for(int i = 0; i < jc.getItemCount(); i++) { |
65 |
|
if(jc.getItemAt(i).toString().length() > prototype.toString().length()) { |
66 |
|
prototype = jc.getItemAt(i); |
67 |
|
} |
68 |
|
} |
69 |
|
return prototype; |
70 |
|
} |
71 |
|
} |
72 |
} |
} |
73 |
|
|
74 |
class FantasiaComboBoxEditor extends BasicComboBoxEditor { |
class FantasiaComboBoxEditor extends BasicComboBoxEditor { |