mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
FlatLaf Change Log
|
FlatLaf Change Log
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
## 3.3-SNAPSHOT
|
||||||
|
|
||||||
|
#### Fixed bugs
|
||||||
|
|
||||||
|
- Table: Switching theme looses table grid and intercell spacing. (issues #733
|
||||||
|
and #750)
|
||||||
|
|
||||||
|
|
||||||
## 3.2.5
|
## 3.2.5
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|||||||
@@ -26,10 +26,12 @@ import java.awt.Insets;
|
|||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
import javax.swing.JViewport;
|
import javax.swing.JViewport;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
@@ -151,19 +153,28 @@ public class FlatTableUI
|
|||||||
if( rowHeight > 0 )
|
if( rowHeight > 0 )
|
||||||
LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) );
|
LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) );
|
||||||
|
|
||||||
if( !showHorizontalLines ) {
|
FlatTablePropertyWatcher watcher = FlatTablePropertyWatcher.get( table );
|
||||||
|
if( watcher != null )
|
||||||
|
watcher.enabled = false;
|
||||||
|
|
||||||
|
if( !showHorizontalLines && (watcher == null || !watcher.showHorizontalLinesChanged) ) {
|
||||||
oldShowHorizontalLines = table.getShowHorizontalLines();
|
oldShowHorizontalLines = table.getShowHorizontalLines();
|
||||||
table.setShowHorizontalLines( false );
|
table.setShowHorizontalLines( false );
|
||||||
}
|
}
|
||||||
if( !showVerticalLines ) {
|
if( !showVerticalLines && (watcher == null || !watcher.showVerticalLinesChanged) ) {
|
||||||
oldShowVerticalLines = table.getShowVerticalLines();
|
oldShowVerticalLines = table.getShowVerticalLines();
|
||||||
table.setShowVerticalLines( false );
|
table.setShowVerticalLines( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( intercellSpacing != null ) {
|
if( intercellSpacing != null && (watcher == null || !watcher.intercellSpacingChanged) ) {
|
||||||
oldIntercellSpacing = table.getIntercellSpacing();
|
oldIntercellSpacing = table.getIntercellSpacing();
|
||||||
table.setIntercellSpacing( intercellSpacing );
|
table.setIntercellSpacing( intercellSpacing );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( watcher != null )
|
||||||
|
watcher.enabled = true;
|
||||||
|
else
|
||||||
|
table.addPropertyChangeListener( new FlatTablePropertyWatcher() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,15 +188,25 @@ public class FlatTableUI
|
|||||||
|
|
||||||
oldStyleValues = null;
|
oldStyleValues = null;
|
||||||
|
|
||||||
|
FlatTablePropertyWatcher watcher = FlatTablePropertyWatcher.get( table );
|
||||||
|
if( watcher != null )
|
||||||
|
watcher.enabled = false;
|
||||||
|
|
||||||
// restore old show horizontal/vertical lines (if not modified)
|
// restore old show horizontal/vertical lines (if not modified)
|
||||||
if( !showHorizontalLines && oldShowHorizontalLines && !table.getShowHorizontalLines() )
|
if( !showHorizontalLines && oldShowHorizontalLines && !table.getShowHorizontalLines() &&
|
||||||
table.setShowHorizontalLines( true );
|
(watcher == null || !watcher.showHorizontalLinesChanged) )
|
||||||
if( !showVerticalLines && oldShowVerticalLines && !table.getShowVerticalLines() )
|
table.setShowHorizontalLines( true );
|
||||||
table.setShowVerticalLines( true );
|
if( !showVerticalLines && oldShowVerticalLines && !table.getShowVerticalLines() &&
|
||||||
|
(watcher == null || !watcher.showVerticalLinesChanged) )
|
||||||
|
table.setShowVerticalLines( true );
|
||||||
|
|
||||||
// restore old intercell spacing (if not modified)
|
// restore old intercell spacing (if not modified)
|
||||||
if( intercellSpacing != null && table.getIntercellSpacing().equals( intercellSpacing ) )
|
if( intercellSpacing != null && table.getIntercellSpacing().equals( intercellSpacing ) &&
|
||||||
table.setIntercellSpacing( oldIntercellSpacing );
|
(watcher == null || !watcher.intercellSpacingChanged) )
|
||||||
|
table.setIntercellSpacing( oldIntercellSpacing );
|
||||||
|
|
||||||
|
if( watcher != null )
|
||||||
|
watcher.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -467,4 +488,46 @@ public class FlatTableUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class FlatTablePropertyWatcher -------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener that watches for change of some table properties from application code.
|
||||||
|
* This information is used in {@link FlatTableUI#installDefaults()} and
|
||||||
|
* {@link FlatTableUI#uninstallDefaults()} to decide whether FlatLaf modifies those properties.
|
||||||
|
* If they are modified in application code, FlatLaf no longer changes them.
|
||||||
|
*
|
||||||
|
* The listener is added once for each table, but never removed.
|
||||||
|
* So switching Laf/theme reuses existing listener.
|
||||||
|
*/
|
||||||
|
private static class FlatTablePropertyWatcher
|
||||||
|
implements PropertyChangeListener
|
||||||
|
{
|
||||||
|
boolean enabled = true;
|
||||||
|
boolean showHorizontalLinesChanged;
|
||||||
|
boolean showVerticalLinesChanged;
|
||||||
|
boolean intercellSpacingChanged;
|
||||||
|
|
||||||
|
static FlatTablePropertyWatcher get( JTable table ) {
|
||||||
|
for( PropertyChangeListener l : table.getPropertyChangeListeners() ) {
|
||||||
|
if( l instanceof FlatTablePropertyWatcher )
|
||||||
|
return (FlatTablePropertyWatcher) l;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---- interface PropertyChangeListener ----
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void propertyChange( PropertyChangeEvent e ) {
|
||||||
|
if( !enabled )
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch( e.getPropertyName() ) {
|
||||||
|
case "showHorizontalLines": showHorizontalLinesChanged = true; break;
|
||||||
|
case "showVerticalLines": showVerticalLinesChanged = true; break;
|
||||||
|
case "rowMargin": intercellSpacingChanged = true; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.formdev.flatlaf.demo;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
@@ -116,15 +115,16 @@ class DataComponentsPanel
|
|||||||
table1.setGridColor( redGridColorCheckBox.isSelected() ? Color.red : UIManager.getColor( "Table.gridColor" ) );
|
table1.setGridColor( redGridColorCheckBox.isSelected() ? Color.red : UIManager.getColor( "Table.gridColor" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void showHorizontalLinesPropertyChange() {
|
||||||
public void updateUI() {
|
showHorizontalLinesCheckBox.setSelected( table1.getShowHorizontalLines() );
|
||||||
super.updateUI();
|
}
|
||||||
|
|
||||||
EventQueue.invokeLater( () -> {
|
private void showVerticalLinesPropertyChange() {
|
||||||
showHorizontalLinesChanged();
|
showVerticalLinesCheckBox.setSelected( table1.getShowVerticalLines() );
|
||||||
showVerticalLinesChanged();
|
}
|
||||||
intercellSpacingChanged();
|
|
||||||
} );
|
private void intercellSpacingPropertyChange() {
|
||||||
|
intercellSpacingCheckBox.setSelected( table1.getRowMargin() != 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||||
@@ -333,10 +333,10 @@ class DataComponentsPanel
|
|||||||
"Not editable", "Text", "Combo", "Combo Editable", "Integer", "Boolean"
|
"Not editable", "Text", "Combo", "Combo Editable", "Integer", "Boolean"
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Class<?>[] columnTypes = new Class<?>[] {
|
Class<?>[] columnTypes = {
|
||||||
Object.class, Object.class, String.class, String.class, Integer.class, Boolean.class
|
Object.class, Object.class, String.class, String.class, Integer.class, Boolean.class
|
||||||
};
|
};
|
||||||
boolean[] columnEditable = new boolean[] {
|
boolean[] columnEditable = {
|
||||||
false, true, true, true, true, true
|
false, true, true, true, true, true
|
||||||
};
|
};
|
||||||
@Override
|
@Override
|
||||||
@@ -383,6 +383,9 @@ class DataComponentsPanel
|
|||||||
}
|
}
|
||||||
table1.setAutoCreateRowSorter(true);
|
table1.setAutoCreateRowSorter(true);
|
||||||
table1.setComponentPopupMenu(popupMenu2);
|
table1.setComponentPopupMenu(popupMenu2);
|
||||||
|
table1.addPropertyChangeListener("showHorizontalLines", e -> showHorizontalLinesPropertyChange());
|
||||||
|
table1.addPropertyChangeListener("showVerticalLines", e -> showVerticalLinesPropertyChange());
|
||||||
|
table1.addPropertyChangeListener("rowMargin", e -> intercellSpacingPropertyChange());
|
||||||
scrollPane5.setViewportView(table1);
|
scrollPane5.setViewportView(table1);
|
||||||
}
|
}
|
||||||
add(scrollPane5, "cell 1 3 3 1,width 300");
|
add(scrollPane5, "cell 1 3 3 1,width 300");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
JFDML JFormDesigner: "8.0.0.0.194" Java: "17.0.2" encoding: "UTF-8"
|
JFDML JFormDesigner: "8.2.0.0.331" Java: "21" encoding: "UTF-8"
|
||||||
|
|
||||||
new FormModel {
|
new FormModel {
|
||||||
contentType: "form/swing"
|
contentType: "form/swing"
|
||||||
@@ -333,6 +333,9 @@ new FormModel {
|
|||||||
auxiliary() {
|
auxiliary() {
|
||||||
"JavaCodeGenerator.variableLocal": false
|
"JavaCodeGenerator.variableLocal": false
|
||||||
}
|
}
|
||||||
|
addEvent( new FormEvent( "java.beans.PropertyChangeListener", "propertyChange", "showHorizontalLinesPropertyChange", false, "showHorizontalLines" ) )
|
||||||
|
addEvent( new FormEvent( "java.beans.PropertyChangeListener", "propertyChange", "showVerticalLinesPropertyChange", false, "showVerticalLines" ) )
|
||||||
|
addEvent( new FormEvent( "java.beans.PropertyChangeListener", "propertyChange", "intercellSpacingPropertyChange", false, "rowMargin" ) )
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 3 3 1,width 300"
|
"value": "cell 1 3 3 1,width 300"
|
||||||
|
|||||||
Reference in New Issue
Block a user