mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
Spinner: fixed painting of border corners on left side (issue #382; regression since FlatLaf 1.4)
ComboBox (editable): fixed wrong border of internal text field under special circumstances
This commit is contained in:
@@ -20,6 +20,10 @@ FlatLaf Change Log
|
|||||||
- OptionPane: Fixed rendering of longer HTML text if it is passed as
|
- OptionPane: Fixed rendering of longer HTML text if it is passed as
|
||||||
`StringBuilder`, `StringBuffer`, or any other object that returns HTML text in
|
`StringBuilder`, `StringBuffer`, or any other object that returns HTML text in
|
||||||
method `toString()`. (similar to issue #12)
|
method `toString()`. (similar to issue #12)
|
||||||
|
- ComboBox (editable): Fixed wrong border of internal text field under special
|
||||||
|
circumstances.
|
||||||
|
- Spinner: Fixed painting of border corners on left side. (issue #382;
|
||||||
|
regression since FlatLaf 1.4)
|
||||||
- TableHeader: Do not show resize cursor for last column if resizing last column
|
- TableHeader: Do not show resize cursor for last column if resizing last column
|
||||||
is not possible because auto resize mode of table is not off. (issue #332)
|
is not possible because auto resize mode of table is not off. (issue #332)
|
||||||
- TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of
|
- TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import java.beans.PropertyChangeListener;
|
|||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.CellRendererPane;
|
import javax.swing.CellRendererPane;
|
||||||
import javax.swing.ComboBoxEditor;
|
|
||||||
import javax.swing.DefaultListCellRenderer;
|
import javax.swing.DefaultListCellRenderer;
|
||||||
import javax.swing.InputMap;
|
import javax.swing.InputMap;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@@ -338,33 +337,25 @@ public class FlatComboBoxUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ComboBoxEditor createEditor() {
|
protected void configureEditor() {
|
||||||
ComboBoxEditor comboBoxEditor = super.createEditor();
|
super.configureEditor();
|
||||||
|
|
||||||
Component editor = comboBoxEditor.getEditorComponent();
|
|
||||||
if( editor instanceof JTextField ) {
|
if( editor instanceof JTextField ) {
|
||||||
JTextField textField = (JTextField) editor;
|
JTextField textField = (JTextField) editor;
|
||||||
textField.setColumns( editorColumns );
|
textField.setColumns( editorColumns );
|
||||||
|
|
||||||
// assign a non-null and non-javax.swing.plaf.UIResource border to the text field,
|
// remove default text field border from editor
|
||||||
// otherwise it is replaced with default text field border when switching LaF
|
Border border = textField.getBorder();
|
||||||
// because javax.swing.plaf.basic.BasicComboBoxEditor.BorderlessTextField.setBorder()
|
if( border == null || border instanceof UIResource ) {
|
||||||
// uses "border instanceof javax.swing.plaf.basic.BasicComboBoxEditor.UIResource"
|
// assign a non-null and non-javax.swing.plaf.UIResource border to the text field,
|
||||||
// instead of "border instanceof javax.swing.plaf.UIResource"
|
// otherwise it is replaced with default text field border when switching LaF
|
||||||
textField.setBorder( BorderFactory.createEmptyBorder() );
|
// because javax.swing.plaf.basic.BasicComboBoxEditor.BorderlessTextField.setBorder()
|
||||||
|
// uses "border instanceof javax.swing.plaf.basic.BasicComboBoxEditor.UIResource"
|
||||||
|
// instead of "border instanceof javax.swing.plaf.UIResource"
|
||||||
|
textField.setBorder( BorderFactory.createEmptyBorder() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return comboBoxEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configureEditor() {
|
|
||||||
super.configureEditor();
|
|
||||||
|
|
||||||
// remove default text field border from editor
|
|
||||||
if( editor instanceof JTextField && ((JTextField)editor).getBorder() instanceof FlatTextBorder )
|
|
||||||
((JTextField)editor).setBorder( BorderFactory.createEmptyBorder() );
|
|
||||||
|
|
||||||
// explicitly make non-opaque
|
// explicitly make non-opaque
|
||||||
if( editor instanceof JComponent )
|
if( editor instanceof JComponent )
|
||||||
((JComponent)editor).setOpaque( false );
|
((JComponent)editor).setOpaque( false );
|
||||||
|
|||||||
@@ -175,15 +175,7 @@ public class FlatSpinnerUI
|
|||||||
@Override
|
@Override
|
||||||
protected JComponent createEditor() {
|
protected JComponent createEditor() {
|
||||||
JComponent editor = super.createEditor();
|
JComponent editor = super.createEditor();
|
||||||
|
configureEditor( editor );
|
||||||
// explicitly make non-opaque
|
|
||||||
editor.setOpaque( false );
|
|
||||||
JTextField textField = getEditorTextField( editor );
|
|
||||||
if( textField != null )
|
|
||||||
textField.setOpaque( false );
|
|
||||||
|
|
||||||
updateEditorPadding();
|
|
||||||
updateEditorColors();
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,8 +183,19 @@ public class FlatSpinnerUI
|
|||||||
protected void replaceEditor( JComponent oldEditor, JComponent newEditor ) {
|
protected void replaceEditor( JComponent oldEditor, JComponent newEditor ) {
|
||||||
super.replaceEditor( oldEditor, newEditor );
|
super.replaceEditor( oldEditor, newEditor );
|
||||||
|
|
||||||
|
configureEditor( newEditor );
|
||||||
|
|
||||||
removeEditorFocusListener( oldEditor );
|
removeEditorFocusListener( oldEditor );
|
||||||
addEditorFocusListener( newEditor );
|
addEditorFocusListener( newEditor );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @since 1.6 */
|
||||||
|
protected void configureEditor( JComponent editor ) {
|
||||||
|
// explicitly make non-opaque
|
||||||
|
editor.setOpaque( false );
|
||||||
|
JTextField textField = getEditorTextField( editor );
|
||||||
|
if( textField != null )
|
||||||
|
textField.setOpaque( false );
|
||||||
|
|
||||||
updateEditorPadding();
|
updateEditorPadding();
|
||||||
updateEditorColors();
|
updateEditorColors();
|
||||||
|
|||||||
@@ -1621,6 +1621,10 @@ public class FlatComponentsTest
|
|||||||
// customRenderer.setBorder( new LineBorder( Color.red ) );
|
// customRenderer.setBorder( new LineBorder( Color.red ) );
|
||||||
// comboBox1.setRenderer( customRenderer );
|
// comboBox1.setRenderer( customRenderer );
|
||||||
// comboBox3.setRenderer( customRenderer );
|
// comboBox3.setRenderer( customRenderer );
|
||||||
|
|
||||||
|
// for testing issue #382
|
||||||
|
// spinner1.setModel( new SpinnerNumberModel( 0, null, 100, 1 ) );
|
||||||
|
// comboBox1.setEditor( new BasicComboBoxEditor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
|
|||||||
Reference in New Issue
Block a user