1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.fantasia.basic; |
24 |
|
25 |
import java.awt.Graphics; |
26 |
import java.awt.Insets; |
27 |
|
28 |
import javax.swing.BorderFactory; |
29 |
import javax.swing.JComboBox; |
30 |
import javax.swing.JTextField; |
31 |
|
32 |
import javax.swing.plaf.basic.BasicComboBoxEditor; |
33 |
|
34 |
import org.jsampler.view.fantasia.Res; |
35 |
|
36 |
import org.jvnet.substance.SubstanceLookAndFeel; |
37 |
|
38 |
/** |
39 |
* |
40 |
* @author Grigor Iliev |
41 |
*/ |
42 |
public class FantasiaComboBox extends JComboBox { |
43 |
public |
44 |
FantasiaComboBox() { |
45 |
setUI(new FantasiaComboBoxUI()); |
46 |
setOpaque(true); |
47 |
setBackground(new java.awt.Color(0x818181)); |
48 |
setBorder(BorderFactory.createEmptyBorder()); |
49 |
setRenderer(new FantasiaListCellRenderer()); |
50 |
putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); |
51 |
//putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); |
52 |
//putClientProperty(SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY, Boolean.TRUE); |
53 |
} |
54 |
|
55 |
|
56 |
} |
57 |
|
58 |
class FantasiaComboBoxEditor extends BasicComboBoxEditor { |
59 |
|
60 |
/** Creates a new instance of <code>FantasiaComboBoxEditor</code> */ |
61 |
public |
62 |
FantasiaComboBoxEditor() { |
63 |
} |
64 |
|
65 |
@Override |
66 |
protected JTextField |
67 |
createEditorComponent() { return new TextEditor(); } |
68 |
|
69 |
static class TextEditor extends JTextField { |
70 |
private static Insets pixmapInsets = new Insets(1, 1, 1, 1); |
71 |
|
72 |
TextEditor() { |
73 |
setOpaque(false); |
74 |
setBorder(BorderFactory.createEmptyBorder()); |
75 |
} |
76 |
|
77 |
@Override |
78 |
public void |
79 |
setText(String s) { |
80 |
if(getText().equals(s)) return; |
81 |
setText(s); |
82 |
} |
83 |
|
84 |
@Override |
85 |
protected void |
86 |
paintComponent(Graphics g) { |
87 |
super.paintComponent(g); |
88 |
|
89 |
PixmapPane.paintComponent(this, g, Res.gfxTextField, pixmapInsets); |
90 |
} |
91 |
} |
92 |
} |