|
|
@ -35,13 +35,7 @@ import javax.swing.plaf.InsetsUIResource; |
|
|
|
import javax.swing.plaf.basic.BasicComboBoxUI; |
|
|
|
import javax.swing.plaf.basic.BasicComboBoxUI; |
|
|
|
import javax.swing.plaf.basic.ComboPopup; |
|
|
|
import javax.swing.plaf.basic.ComboPopup; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.event.FocusAdapter; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
|
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import java.awt.event.MouseListener; |
|
|
|
|
|
|
|
import java.awt.geom.Area; |
|
|
|
import java.awt.geom.Area; |
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
import java.beans.PropertyChangeEvent; |
|
|
|
import java.beans.PropertyChangeEvent; |
|
|
@ -73,6 +67,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC |
|
|
|
protected Color arrowBackgroundStart; |
|
|
|
protected Color arrowBackgroundStart; |
|
|
|
protected Color arrowBackgroundEnd; |
|
|
|
protected Color arrowBackgroundEnd; |
|
|
|
private Insets boxPadding; |
|
|
|
private Insets boxPadding; |
|
|
|
|
|
|
|
private Insets cellPadding; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static ComponentUI createUI(final JComponent c) { |
|
|
|
public static ComponentUI createUI(final JComponent c) { |
|
|
@ -83,7 +78,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC |
|
|
|
public void installUI(final JComponent c) { |
|
|
|
public void installUI(final JComponent c) { |
|
|
|
super.installUI(c); |
|
|
|
super.installUI(c); |
|
|
|
comboBox.setBorder(this); |
|
|
|
comboBox.setBorder(this); |
|
|
|
boxPadding = UIManager.getInsets("ComboBox.padding"); |
|
|
|
boxPadding = UIManager.getInsets("ComboBox.insets"); |
|
|
|
borderSize = UIManager.getInt("ComboBox.borderThickness"); |
|
|
|
borderSize = UIManager.getInt("ComboBox.borderThickness"); |
|
|
|
background = UIManager.getColor("ComboBox.activeBackground"); |
|
|
|
background = UIManager.getColor("ComboBox.activeBackground"); |
|
|
|
editBackground = UIManager.getColor("ComboBox.editBackground"); |
|
|
|
editBackground = UIManager.getColor("ComboBox.editBackground"); |
|
|
@ -94,6 +89,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC |
|
|
|
inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor"); |
|
|
|
inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor"); |
|
|
|
arrowBackgroundStart = UIManager.getColor("ComboBox.arrowBackgroundStart"); |
|
|
|
arrowBackgroundStart = UIManager.getColor("ComboBox.arrowBackgroundStart"); |
|
|
|
arrowBackgroundEnd = UIManager.getColor("ComboBox.arrowBackgroundEnd"); |
|
|
|
arrowBackgroundEnd = UIManager.getColor("ComboBox.arrowBackgroundEnd"); |
|
|
|
|
|
|
|
cellPadding = UIManager.getInsets("ComboBox.cellEditorInsets"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -265,14 +261,14 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Insets getInsets() { |
|
|
|
protected Insets getInsets() { |
|
|
|
if (isTableCellEditor(comboBox)) { |
|
|
|
if (isTableCellEditor(comboBox)) { |
|
|
|
return new Insets(2, 5, 2, 5); |
|
|
|
return new InsetsUIResource(cellPadding.top, cellPadding.left, cellPadding.bottom, cellPadding.right); |
|
|
|
} |
|
|
|
} |
|
|
|
if (comboBox.getComponentOrientation().isLeftToRight()) { |
|
|
|
if (comboBox.getComponentOrientation().isLeftToRight()) { |
|
|
|
return new InsetsUIResource(borderSize + 4, borderSize + 6, |
|
|
|
return new InsetsUIResource(borderSize + boxPadding.top, borderSize + boxPadding.left, |
|
|
|
borderSize + 4, borderSize); |
|
|
|
borderSize + boxPadding.bottom, borderSize); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return new InsetsUIResource(borderSize + 4, borderSize, |
|
|
|
return new InsetsUIResource(borderSize + boxPadding.top, borderSize, |
|
|
|
borderSize + 4, borderSize + 6); |
|
|
|
borderSize + boxPadding.bottom, borderSize + boxPadding.right); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -297,7 +293,6 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC |
|
|
|
|
|
|
|
|
|
|
|
boolean shouldValidate = c instanceof JPanel; |
|
|
|
boolean shouldValidate = c instanceof JPanel; |
|
|
|
Rectangle r = new Rectangle(bounds); |
|
|
|
Rectangle r = new Rectangle(bounds); |
|
|
|
DarkUIUtil.applyInsets(r, boxPadding); |
|
|
|
|
|
|
|
if (isTableCellEditor(comboBox)) { |
|
|
|
if (isTableCellEditor(comboBox)) { |
|
|
|
r.x--; |
|
|
|
r.x--; |
|
|
|
} |
|
|
|
} |
|
|
@ -409,7 +404,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Insets getBorderInsets(final Component c) { |
|
|
|
public Insets getBorderInsets(final Component c) { |
|
|
|
if (isTableCellEditor(c) || isTreeCellEditor(c)) { |
|
|
|
if (isTableCellEditor(c) || isTreeCellEditor(c)) { |
|
|
|
return new InsetsUIResource(0, 0, 0, 0); |
|
|
|
return new InsetsUIResource(cellPadding.top, cellPadding.left, cellPadding.bottom, cellPadding.right); |
|
|
|
} |
|
|
|
} |
|
|
|
return new InsetsUIResource(borderSize, borderSize, borderSize, borderSize); |
|
|
|
return new InsetsUIResource(borderSize, borderSize, borderSize, borderSize); |
|
|
|
} |
|
|
|
} |
|
|
@ -429,7 +424,6 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC |
|
|
|
if ("componentOrientation".equals(key)) { |
|
|
|
if ("componentOrientation".equals(key)) { |
|
|
|
comboBox.doLayout(); |
|
|
|
comboBox.doLayout(); |
|
|
|
comboBox.repaint(); |
|
|
|
comboBox.repaint(); |
|
|
|
// editor.setComponentOrientation(comboBox.getComponentOrientation());
|
|
|
|
|
|
|
|
} else if ("editable".equals(key)) { |
|
|
|
} else if ("editable".equals(key)) { |
|
|
|
comboBox.repaint(); |
|
|
|
comboBox.repaint(); |
|
|
|
} else if ("JComboBox.isTableCellEditor".equals(key) || "JComboBox.isTreeCellEditor".equals(key)) { |
|
|
|
} else if ("JComboBox.isTableCellEditor".equals(key) || "JComboBox.isTreeCellEditor".equals(key)) { |
|
|
|