| 1 | |
package org.jtheque.core.managers.view.impl.components.filthy; |
| 2 | |
|
| 3 | |
import org.jtheque.core.managers.Managers; |
| 4 | |
import org.jtheque.core.managers.resource.IResourceManager; |
| 5 | |
import org.jtheque.core.utils.ui.Borders; |
| 6 | |
|
| 7 | |
import javax.swing.AbstractButton; |
| 8 | |
import javax.swing.BorderFactory; |
| 9 | |
import javax.swing.ComboBoxModel; |
| 10 | |
import javax.swing.DefaultListCellRenderer; |
| 11 | |
import javax.swing.JComboBox; |
| 12 | |
import javax.swing.JList; |
| 13 | |
import javax.swing.UIManager; |
| 14 | |
import javax.swing.border.CompoundBorder; |
| 15 | |
import java.awt.Color; |
| 16 | |
import java.awt.Component; |
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
public final class FilthyComboBox extends JComboBox { |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
public FilthyComboBox(ComboBoxModel model) { |
| 46 | 0 | super(model); |
| 47 | |
|
| 48 | 0 | IResourceManager resources = Managers.getManager(IResourceManager.class); |
| 49 | |
|
| 50 | 0 | setOpaque(false); |
| 51 | 0 | setBackground(resources.getColor("filthyInputColor")); |
| 52 | |
|
| 53 | 0 | setBorder(new CompoundBorder( |
| 54 | |
BorderFactory.createLineBorder(resources.getColor("filthyInputBorderColor"), 2), |
| 55 | |
BorderFactory.createEmptyBorder(2, 2, 2, 2))); |
| 56 | |
|
| 57 | 0 | UIManager.put("ComboBox.selectionBackground", new Color(0, 0, 0, 0)); |
| 58 | |
|
| 59 | 0 | for (int i = 0; i < getComponentCount(); i++) { |
| 60 | 0 | if (getComponent(i) instanceof AbstractButton) { |
| 61 | 0 | ((AbstractButton) getComponent(i)).setBorderPainted(false); |
| 62 | |
} |
| 63 | |
} |
| 64 | |
|
| 65 | 0 | setRenderer(new FilthyRenderer()); |
| 66 | 0 | } |
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | 0 | private static final class FilthyRenderer extends DefaultListCellRenderer { |
| 74 | |
@Override |
| 75 | |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
| 76 | 0 | super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
| 77 | |
|
| 78 | 0 | setBorder(Borders.createEmptyBorder(0, 0, 0, 0)); |
| 79 | 0 | setForeground(Color.white); |
| 80 | 0 | setOpaque(false); |
| 81 | |
|
| 82 | 0 | return this; |
| 83 | |
} |
| 84 | |
} |
| 85 | |
} |