mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 22:47:13 -06:00
Table and Tree: show focus border (at scroll pane) even if in editing mode
This commit is contained in:
@@ -22,13 +22,17 @@ import java.awt.Component;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.KeyboardFocusManager;
|
||||||
import java.awt.Paint;
|
import java.awt.Paint;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JTable;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JTree;
|
||||||
import javax.swing.JViewport;
|
import javax.swing.JViewport;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.basic.BasicBorders;
|
import javax.swing.plaf.basic.BasicBorders;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
@@ -97,7 +101,19 @@ public class FlatBorder
|
|||||||
if( c instanceof JScrollPane ) {
|
if( c instanceof JScrollPane ) {
|
||||||
JViewport viewport = ((JScrollPane)c).getViewport();
|
JViewport viewport = ((JScrollPane)c).getViewport();
|
||||||
Component view = (viewport != null) ? viewport.getView() : null;
|
Component view = (viewport != null) ? viewport.getView() : null;
|
||||||
return (view != null) ? view.hasFocus() : false;
|
if( view != null ) {
|
||||||
|
if( view.hasFocus() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( (view instanceof JTable && ((JTable)view).isEditing()) ||
|
||||||
|
(view instanceof JTree && ((JTree)view).isEditing()) )
|
||||||
|
{
|
||||||
|
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||||
|
if( focusOwner != null )
|
||||||
|
return SwingUtilities.isDescendingFrom( focusOwner, view );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
} else if( c instanceof JComboBox && ((JComboBox<?>)c).isEditable() ) {
|
} else if( c instanceof JComboBox && ((JComboBox<?>)c).isEditable() ) {
|
||||||
Component editorComponent = ((JComboBox<?>)c).getEditor().getEditorComponent();
|
Component editorComponent = ((JComboBox<?>)c).getEditor().getEditorComponent();
|
||||||
return (editorComponent != null) ? editorComponent.hasFocus() : false;
|
return (editorComponent != null) ? editorComponent.hasFocus() : false;
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ public class FlatComponents2Test
|
|||||||
|
|
||||||
//---- tree1 ----
|
//---- tree1 ----
|
||||||
tree1.setShowsRootHandles(true);
|
tree1.setShowsRootHandles(true);
|
||||||
|
tree1.setEditable(true);
|
||||||
scrollPane3.setViewportView(tree1);
|
scrollPane3.setViewportView(tree1);
|
||||||
}
|
}
|
||||||
add(scrollPane3, "cell 1 3,growx");
|
add(scrollPane3, "cell 1 3,growx");
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ new FormModel {
|
|||||||
add( new FormComponent( "javax.swing.JTree" ) {
|
add( new FormComponent( "javax.swing.JTree" ) {
|
||||||
name: "tree1"
|
name: "tree1"
|
||||||
"showsRootHandles": true
|
"showsRootHandles": true
|
||||||
|
"editable": true
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 3,growx"
|
"value": "cell 1 3,growx"
|
||||||
|
|||||||
Reference in New Issue
Block a user