mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 07:47:12 -06:00
PopupMenuBorder implementation
This commit is contained in:
@@ -32,14 +32,18 @@ import java.beans.PropertyChangeEvent;
|
|||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.ListCellRenderer;
|
import javax.swing.ListCellRenderer;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.border.Border;
|
||||||
import javax.swing.plaf.ColorUIResource;
|
import javax.swing.plaf.ColorUIResource;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicComboBoxUI;
|
import javax.swing.plaf.basic.BasicComboBoxUI;
|
||||||
|
import javax.swing.plaf.basic.BasicComboPopup;
|
||||||
|
import javax.swing.plaf.basic.ComboPopup;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
@@ -174,6 +178,11 @@ public class FlatComboBoxUI
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ComboPopup createPopup() {
|
||||||
|
return new FlatComboPopup( comboBox );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureEditor() {
|
protected void configureEditor() {
|
||||||
super.configureEditor();
|
super.configureEditor();
|
||||||
@@ -279,4 +288,24 @@ public class FlatComboBoxUI
|
|||||||
g.setColor( comboBox.isEnabled() ? comboBox.getBackground() : disabledBackground );
|
g.setColor( comboBox.isEnabled() ? comboBox.getBackground() : disabledBackground );
|
||||||
g.fillRect( bounds.x, bounds.y, bounds.width, bounds.height );
|
g.fillRect( bounds.x, bounds.y, bounds.width, bounds.height );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class FlatComboPopup -----------------------------------------------
|
||||||
|
|
||||||
|
private class FlatComboPopup
|
||||||
|
extends BasicComboPopup
|
||||||
|
{
|
||||||
|
@SuppressWarnings( "rawtypes" )
|
||||||
|
FlatComboPopup( JComboBox combo ) {
|
||||||
|
super( combo );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configurePopup() {
|
||||||
|
super.configurePopup();
|
||||||
|
|
||||||
|
Border border = UIManager.getBorder( "PopupMenu.border" );
|
||||||
|
if( border != null )
|
||||||
|
setBorder( border );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 FormDev Software GmbH
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border for {@link javax.swing.JPopupMenu}.
|
||||||
|
*
|
||||||
|
* @uiDefault PopupMenu.borderInsets Insets
|
||||||
|
* @uiDefault PopupMenu.borderColor Color
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatPopupMenuBorder
|
||||||
|
extends FlatLineBorder
|
||||||
|
{
|
||||||
|
public FlatPopupMenuBorder() {
|
||||||
|
super( UIManager.getInsets( "PopupMenu.borderInsets" ),
|
||||||
|
UIManager.getColor( "PopupMenu.borderColor" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -122,6 +122,11 @@ MenuItemCheckBox.icon.checkmarkColor=A7A7A7
|
|||||||
MenuItemCheckBox.icon.disabledCheckmarkColor=606060
|
MenuItemCheckBox.icon.disabledCheckmarkColor=606060
|
||||||
|
|
||||||
|
|
||||||
|
#---- PopupMenu ----
|
||||||
|
|
||||||
|
PopupMenu.borderColor=515151
|
||||||
|
|
||||||
|
|
||||||
#---- ProgressBar ----
|
#---- ProgressBar ----
|
||||||
|
|
||||||
ProgressBar.background=555555
|
ProgressBar.background=555555
|
||||||
|
|||||||
@@ -124,6 +124,12 @@ PasswordField.background=@textComponentBackground
|
|||||||
PasswordField.margin=@textComponentMargin
|
PasswordField.margin=@textComponentMargin
|
||||||
|
|
||||||
|
|
||||||
|
#---- PopupMenu ----
|
||||||
|
|
||||||
|
PopupMenu.border=com.formdev.flatlaf.ui.FlatPopupMenuBorder
|
||||||
|
PopupMenu.borderInsets=1,1,1,1
|
||||||
|
|
||||||
|
|
||||||
#---- PopupMenuSeparator ----
|
#---- PopupMenuSeparator ----
|
||||||
|
|
||||||
PopupMenuSeparator.height=9
|
PopupMenuSeparator.height=9
|
||||||
|
|||||||
@@ -122,6 +122,11 @@ MenuItemCheckBox.icon.checkmarkColor=4D89C9
|
|||||||
MenuItemCheckBox.icon.disabledCheckmarkColor=ABABAB
|
MenuItemCheckBox.icon.disabledCheckmarkColor=ABABAB
|
||||||
|
|
||||||
|
|
||||||
|
#---- PopupMenu ----
|
||||||
|
|
||||||
|
PopupMenu.borderColor=cdcdcd
|
||||||
|
|
||||||
|
|
||||||
#---- ProgressBar ----
|
#---- ProgressBar ----
|
||||||
|
|
||||||
ProgressBar.background=c4c4c4
|
ProgressBar.background=c4c4c4
|
||||||
|
|||||||
@@ -121,6 +121,11 @@ MenuItemCheckBox.icon.checkmarkColor=4D89C9
|
|||||||
MenuItemCheckBox.icon.disabledCheckmarkColor=ABABAB
|
MenuItemCheckBox.icon.disabledCheckmarkColor=ABABAB
|
||||||
|
|
||||||
|
|
||||||
|
#---- PopupMenu ----
|
||||||
|
|
||||||
|
PopupMenu.borderColor=0000ff
|
||||||
|
|
||||||
|
|
||||||
#---- PopupMenuSeparator ----
|
#---- PopupMenuSeparator ----
|
||||||
|
|
||||||
PopupMenuSeparator.height=30
|
PopupMenuSeparator.height=30
|
||||||
|
|||||||
Reference in New Issue
Block a user