Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* MIT License
*
* Copyright (c) 2019 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.ui.combobox;
import com.github.weisj.darklaf.components.ArrowButton;
import com.github.weisj.darklaf.ui.list.DarkListCellRenderer;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.ComboPopup;
import java.awt.*;
import java.awt.event.FocusAdapter;
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.RoundRectangle2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
/**
* @author Konstantin Bulenkov
* @author Jannis Weis
*/
public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyChangeListener {
private static final int BUTTON_PAD = 7;
private final MouseListener mouseListener = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
comboBox.getEditor().getEditorComponent().requestFocus();
}
};
protected int arcSize;
protected int borderSize;
protected Color background;
protected Color editBackground;
protected Color inactiveBackground;
protected Color inactiveForeground;
protected Color focusBorderColor;
protected Color borderColor;
protected Color inactiveBorderColor;
protected Color arrowBackgroundStart;
protected Color arrowBackgroundEnd;
private Insets boxPadding;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkComboBoxUI();
}
@Override
public void installUI(final JComponent c) {
super.installUI(c);
comboBox.setBorder(this);
boxPadding = UIManager.getInsets("ComboBox.padding");
borderSize = UIManager.getInt("ComboBox.borderThickness");
background = UIManager.getColor("ComboBox.activeBackground");
editBackground = UIManager.getColor("ComboBox.editBackground");
inactiveBackground = UIManager.getColor("ComboBox.inactiveBackground");
inactiveForeground = UIManager.getColor("ComboBox.disabledForeground");
focusBorderColor = UIManager.getColor("ComboBox.focusBorderColor");
borderColor = UIManager.getColor("ComboBox.activeBorderColor");
inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor");
arrowBackgroundStart = UIManager.getColor("ComboBox.arrowBackgroundStart");
arrowBackgroundEnd = UIManager.getColor("ComboBox.arrowBackgroundEnd");
}
@Override
protected void installDefaults() {
super.installDefaults();
LookAndFeel.installProperty(comboBox, "opaque", false);
arcSize = UIManager.getInt("ComboBox.arc");
}
@Override
protected void installListeners() {
super.installListeners();
comboBox.addMouseListener(mouseListener);
comboBox.addPropertyChangeListener(this);
}
@Override
protected void uninstallListeners() {
super.uninstallListeners();
comboBox.removeMouseListener(mouseListener);
comboBox.removePropertyChangeListener(this);
}
@Override
protected ComboPopup createPopup() {
return new DarkComboPopup(comboBox);
}
@Override
protected ListCellRenderer