| 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.managers.view.able.IViewManager; |
| 6 | |
import org.jtheque.core.managers.view.able.ViewDefaults; |
| 7 | |
import org.jtheque.core.utils.ui.Borders; |
| 8 | |
|
| 9 | |
import javax.swing.BorderFactory; |
| 10 | |
import javax.swing.JPanel; |
| 11 | |
import javax.swing.border.CompoundBorder; |
| 12 | |
import javax.swing.text.JTextComponent; |
| 13 | |
import java.awt.BorderLayout; |
| 14 | |
import java.awt.Color; |
| 15 | |
import java.awt.Font; |
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
public abstract class AbstractFilthyField extends JPanel { |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
public AbstractFilthyField() { |
| 43 | 0 | super(); |
| 44 | |
|
| 45 | 0 | IResourceManager resources = Managers.getManager(IResourceManager.class); |
| 46 | |
|
| 47 | 0 | Color inputColor = resources.getColor("filthyInputColor"); |
| 48 | 0 | Color inputBorderColor = resources.getColor("filthyInputBorderColor"); |
| 49 | |
|
| 50 | 0 | setLayout(new BorderLayout()); |
| 51 | 0 | setBackground(inputColor); |
| 52 | 0 | setBorder(new CompoundBorder( |
| 53 | |
BorderFactory.createLineBorder(inputBorderColor, 2), |
| 54 | |
BorderFactory.createEmptyBorder(2, 2, 2, 2))); |
| 55 | |
|
| 56 | 0 | initComponent(); |
| 57 | 0 | } |
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
abstract void initComponent(); |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
static void makeFilthy(JTextComponent field) { |
| 70 | 0 | ViewDefaults defaults = Managers.getManager(IViewManager.class).getViewDefaults(); |
| 71 | |
|
| 72 | 0 | Font inputFont = defaults.getFilthyInputFont(); |
| 73 | |
|
| 74 | 0 | Color inputTextColor = defaults.getFilthyForegroundColor(); |
| 75 | 0 | Color inputSelectionColor = defaults.getFilthyForegroundColor(); |
| 76 | 0 | Color inputSelectedTextColor = defaults.getFilthyBackgroundColor(); |
| 77 | |
|
| 78 | 0 | field.setOpaque(false); |
| 79 | 0 | field.setBorder(Borders.EMPTY_BORDER); |
| 80 | 0 | field.setForeground(inputTextColor); |
| 81 | 0 | field.setSelectedTextColor(inputSelectedTextColor); |
| 82 | 0 | field.setSelectionColor(inputSelectionColor); |
| 83 | 0 | field.setCaretColor(inputSelectionColor); |
| 84 | 0 | field.setFont(inputFont); |
| 85 | 0 | } |
| 86 | |
} |