mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
SwingX: fixed too wide border when using date picker as table cell editor (issue #24)
This commit is contained in:
@@ -11,6 +11,8 @@ FlatLaf Change Log
|
||||
- Fixed selection background of checkbox in table cell.
|
||||
- Fixed jittery submenu rendering on Mac. (issue #10)
|
||||
- Hex color values in `.properties` files now must start with a `#` character.
|
||||
- SwingX: Fixed too wide border when using date picker as table cell editor.
|
||||
(issue #24)
|
||||
- JIDE Common Layer: Fixed `JidePopup` border.
|
||||
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class FlatBorder
|
||||
try {
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
|
||||
boolean isCellEditor = FlatUIUtils.isTableCellEditor( c );
|
||||
boolean isCellEditor = isTableCellEditor( c );
|
||||
float focusWidth = isCellEditor ? 0 : getFocusWidth();
|
||||
float borderWidth = getBorderWidth( c );
|
||||
float arc = isCellEditor ? 0 : getArc();
|
||||
@@ -132,9 +132,13 @@ public class FlatBorder
|
||||
return c.hasFocus();
|
||||
}
|
||||
|
||||
protected boolean isTableCellEditor( Component c ) {
|
||||
return FlatUIUtils.isTableCellEditor( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||
boolean isCellEditor = FlatUIUtils.isTableCellEditor( c );
|
||||
boolean isCellEditor = isTableCellEditor( c );
|
||||
float ow = (isCellEditor ? 0 : getFocusWidth()) + getLineWidth();
|
||||
|
||||
insets = super.getBorderInsets( c, insets );
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.formdev.flatlaf.swingx.ui;
|
||||
|
||||
import java.awt.Component;
|
||||
import javax.swing.JTable;
|
||||
import org.jdesktop.swingx.JXDatePicker;
|
||||
import com.formdev.flatlaf.ui.FlatRoundBorder;
|
||||
|
||||
@@ -35,4 +36,9 @@ public class FlatDatePickerBorder
|
||||
|
||||
return super.isFocused( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTableCellEditor( Component c ) {
|
||||
return c.getParent() instanceof JTable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,10 @@ import java.awt.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
import net.miginfocom.swing.*;
|
||||
import org.jdesktop.swingx.*;
|
||||
import org.jdesktop.swingx.table.DatePickerCellEditor;
|
||||
import com.formdev.flatlaf.testing.FlatTestFrame;
|
||||
import com.formdev.flatlaf.testing.FlatTestPanel;
|
||||
|
||||
@@ -52,6 +54,8 @@ public class FlatSwingXTest
|
||||
|
||||
calendar.set( Calendar.DAY_OF_MONTH, 16 );
|
||||
monthView1.setUnselectableDates( calendar.getTime() );
|
||||
|
||||
table.setDefaultEditor( Date.class, new DatePickerCellEditor() );
|
||||
}
|
||||
|
||||
private void busyChanged() {
|
||||
@@ -64,13 +68,11 @@ public class FlatSwingXTest
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
JLabel label1 = new JLabel();
|
||||
JLabel label3 = new JLabel();
|
||||
JLabel label6 = new JLabel();
|
||||
JLabel datePickerLabel = new JLabel();
|
||||
JXDatePicker xDatePicker1 = new JXDatePicker();
|
||||
JXDatePicker xDatePicker2 = new JXDatePicker();
|
||||
JLabel label4 = new JLabel();
|
||||
JLabel label5 = new JLabel();
|
||||
JXDatePicker xDatePicker3 = new JXDatePicker();
|
||||
JXDatePicker xDatePicker4 = new JXDatePicker();
|
||||
JLabel monthViewLabel = new JLabel();
|
||||
monthView1 = new JXMonthView();
|
||||
monthView2 = new JXMonthView();
|
||||
@@ -98,6 +100,11 @@ public class FlatSwingXTest
|
||||
JXTaskPane xTaskPane6 = new JXTaskPane();
|
||||
JXHyperlink xHyperlink9 = new JXHyperlink();
|
||||
JXHyperlink xHyperlink10 = new JXHyperlink();
|
||||
JXDatePicker xDatePicker2 = new JXDatePicker();
|
||||
JLabel label5 = new JLabel();
|
||||
JXDatePicker xDatePicker4 = new JXDatePicker();
|
||||
JScrollPane scrollPane2 = new JScrollPane();
|
||||
table = new JTable();
|
||||
JLabel headerLabel = new JLabel();
|
||||
JXHeader xHeader1 = new JXHeader();
|
||||
|
||||
@@ -108,12 +115,13 @@ public class FlatSwingXTest
|
||||
"[left]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]0" +
|
||||
"[]" +
|
||||
"[]0" +
|
||||
"[]" +
|
||||
"[top]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
@@ -127,32 +135,23 @@ public class FlatSwingXTest
|
||||
label3.setText("disabled");
|
||||
add(label3, "cell 2 0");
|
||||
|
||||
//---- label6 ----
|
||||
label6.setText("DatePickerCellEditor:");
|
||||
add(label6, "cell 3 0");
|
||||
|
||||
//---- datePickerLabel ----
|
||||
datePickerLabel.setText("JXDatePicker:");
|
||||
add(datePickerLabel, "cell 0 1");
|
||||
add(xDatePicker1, "cell 1 1");
|
||||
|
||||
//---- xDatePicker2 ----
|
||||
xDatePicker2.setEnabled(false);
|
||||
add(xDatePicker2, "cell 2 1");
|
||||
|
||||
//---- label4 ----
|
||||
label4.setText("not editable");
|
||||
add(label4, "cell 1 2");
|
||||
|
||||
//---- label5 ----
|
||||
label5.setText("not editable disabled");
|
||||
add(label5, "cell 2 2");
|
||||
|
||||
//---- xDatePicker3 ----
|
||||
xDatePicker3.setEditable(false);
|
||||
add(xDatePicker3, "cell 1 3");
|
||||
|
||||
//---- xDatePicker4 ----
|
||||
xDatePicker4.setEnabled(false);
|
||||
xDatePicker4.setEditable(false);
|
||||
add(xDatePicker4, "cell 2 3");
|
||||
|
||||
//---- monthViewLabel ----
|
||||
monthViewLabel.setText("JXMonthView:");
|
||||
add(monthViewLabel, "cell 0 4,aligny top,growy 0");
|
||||
@@ -162,7 +161,7 @@ public class FlatSwingXTest
|
||||
monthView1.setShowingLeadingDays(true);
|
||||
monthView1.setShowingTrailingDays(true);
|
||||
monthView1.setShowingWeekNumber(true);
|
||||
add(monthView1, "cell 1 4");
|
||||
add(monthView1, "cell 1 4 2 1");
|
||||
|
||||
//---- monthView2 ----
|
||||
monthView2.setTraversable(true);
|
||||
@@ -170,7 +169,7 @@ public class FlatSwingXTest
|
||||
monthView2.setShowingTrailingDays(true);
|
||||
monthView2.setShowingWeekNumber(true);
|
||||
monthView2.setEnabled(false);
|
||||
add(monthView2, "cell 2 4");
|
||||
add(monthView2, "cell 3 4");
|
||||
|
||||
//---- hyperlinkLabel ----
|
||||
hyperlinkLabel.setText("JXHyperlink:");
|
||||
@@ -178,12 +177,12 @@ public class FlatSwingXTest
|
||||
|
||||
//---- xHyperlink1 ----
|
||||
xHyperlink1.setText("enabled");
|
||||
add(xHyperlink1, "cell 1 5");
|
||||
add(xHyperlink1, "cell 1 5 2 1");
|
||||
|
||||
//---- xHyperlink2 ----
|
||||
xHyperlink2.setText("disabled");
|
||||
xHyperlink2.setEnabled(false);
|
||||
add(xHyperlink2, "cell 2 5");
|
||||
add(xHyperlink2, "cell 3 5");
|
||||
|
||||
//---- label2 ----
|
||||
label2.setText("JXBusyLabel:");
|
||||
@@ -191,18 +190,18 @@ public class FlatSwingXTest
|
||||
|
||||
//---- xBusyLabel1 ----
|
||||
xBusyLabel1.setText("enabled");
|
||||
add(xBusyLabel1, "cell 1 6");
|
||||
add(xBusyLabel1, "cell 1 6 2 1");
|
||||
|
||||
//---- xBusyLabel2 ----
|
||||
xBusyLabel2.setText("disabled");
|
||||
xBusyLabel2.setEnabled(false);
|
||||
add(xBusyLabel2, "cell 2 6,growx");
|
||||
add(xBusyLabel2, "cell 3 6,growx");
|
||||
|
||||
//---- busyCheckBox ----
|
||||
busyCheckBox.setText("busy");
|
||||
busyCheckBox.setMnemonic('Y');
|
||||
busyCheckBox.addActionListener(e -> busyChanged());
|
||||
add(busyCheckBox, "cell 2 6");
|
||||
add(busyCheckBox, "cell 3 6");
|
||||
|
||||
//======== panel2 ========
|
||||
{
|
||||
@@ -296,7 +295,46 @@ public class FlatSwingXTest
|
||||
}
|
||||
panel2.add(scrollPane1, "cell 0 2,width 150,height 350");
|
||||
}
|
||||
add(panel2, "cell 3 0 1 8,aligny top,growy 0");
|
||||
add(panel2, "cell 4 0 1 8,aligny top,growy 0");
|
||||
|
||||
//---- xDatePicker2 ----
|
||||
xDatePicker2.setEnabled(false);
|
||||
add(xDatePicker2, "cell 2 1");
|
||||
|
||||
//---- label5 ----
|
||||
label5.setText("not editable disabled");
|
||||
add(label5, "cell 2 2");
|
||||
|
||||
//---- xDatePicker4 ----
|
||||
xDatePicker4.setEnabled(false);
|
||||
xDatePicker4.setEditable(false);
|
||||
add(xDatePicker4, "cell 2 3");
|
||||
|
||||
//======== scrollPane2 ========
|
||||
{
|
||||
|
||||
//---- table ----
|
||||
table.setModel(new DefaultTableModel(
|
||||
new Object[][] {
|
||||
{new Date(1574636400000L) /* 25.11.2019, 00:00:00 */},
|
||||
{new Date(1517439600000L) /* 01.02.2018, 00:00:00 */},
|
||||
},
|
||||
new String[] {
|
||||
"Date"
|
||||
}
|
||||
) {
|
||||
Class<?>[] columnTypes = new Class<?>[] {
|
||||
Date.class
|
||||
};
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
return columnTypes[columnIndex];
|
||||
}
|
||||
});
|
||||
table.setPreferredScrollableViewportSize(new Dimension(150, 50));
|
||||
scrollPane2.setViewportView(table);
|
||||
}
|
||||
add(scrollPane2, "cell 3 1 1 3,growy");
|
||||
|
||||
//---- headerLabel ----
|
||||
headerLabel.setText("JXHeader:");
|
||||
@@ -306,7 +344,7 @@ public class FlatSwingXTest
|
||||
xHeader1.setTitle("Title");
|
||||
xHeader1.setDescription("Description\nMore description");
|
||||
xHeader1.setIcon(new ImageIcon(getClass().getResource("/org/jdesktop/swingx/plaf/windows/resources/tipoftheday.png")));
|
||||
add(xHeader1, "cell 1 7 2 1,width 200");
|
||||
add(xHeader1, "cell 1 7 3 1,width 200");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
|
||||
xDatePicker1.setDate( new Date() );
|
||||
@@ -321,5 +359,6 @@ public class FlatSwingXTest
|
||||
private JXBusyLabel xBusyLabel1;
|
||||
private JXBusyLabel xBusyLabel2;
|
||||
private JCheckBox busyCheckBox;
|
||||
private JTable table;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ new FormModel {
|
||||
}
|
||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[left][][][fill]"
|
||||
"$rowConstraints": "[]0[][]0[][][][][]"
|
||||
"$columnConstraints": "[left][][][][fill]"
|
||||
"$rowConstraints": "[]0[][]0[top][][][][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
@@ -24,6 +24,12 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label6"
|
||||
"text": "DatePickerCellEditor:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "datePickerLabel"
|
||||
"text": "JXDatePicker:"
|
||||
@@ -35,37 +41,18 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker2"
|
||||
"enabled": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
"text": "not editable"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label5"
|
||||
"text": "not editable disabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 2"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker3"
|
||||
"editable": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker4"
|
||||
"enabled": false
|
||||
"editable": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "monthViewLabel"
|
||||
"text": "JXMonthView:"
|
||||
@@ -82,7 +69,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 4"
|
||||
"value": "cell 1 4 2 1"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXMonthView" ) {
|
||||
name: "monthView2"
|
||||
@@ -95,7 +82,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 4"
|
||||
"value": "cell 3 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "hyperlinkLabel"
|
||||
@@ -107,14 +94,14 @@ new FormModel {
|
||||
name: "xHyperlink1"
|
||||
"text": "enabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 5"
|
||||
"value": "cell 1 5 2 1"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink2"
|
||||
"text": "disabled"
|
||||
"enabled": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 5"
|
||||
"value": "cell 3 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label2"
|
||||
@@ -129,7 +116,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6"
|
||||
"value": "cell 1 6 2 1"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXBusyLabel" ) {
|
||||
name: "xBusyLabel2"
|
||||
@@ -139,7 +126,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 6,growx"
|
||||
"value": "cell 3 6,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "busyCheckBox"
|
||||
@@ -150,7 +137,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "busyChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 6"
|
||||
"value": "cell 3 6"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
@@ -230,7 +217,54 @@ new FormModel {
|
||||
"value": "cell 0 2,width 150,height 350"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 0 1 8,aligny top,growy 0"
|
||||
"value": "cell 4 0 1 8,aligny top,growy 0"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker2"
|
||||
"enabled": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label5"
|
||||
"text": "not editable disabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 2"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker4"
|
||||
"enabled": false
|
||||
"editable": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 3"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane2"
|
||||
add( new FormComponent( "javax.swing.JTable" ) {
|
||||
name: "table"
|
||||
"model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector {
|
||||
add( new java.util.Vector {
|
||||
add( new java.util.Date( 1574636400000l ) )
|
||||
} )
|
||||
add( new java.util.Vector {
|
||||
add( new java.util.Date( 1517439600000l ) )
|
||||
} )
|
||||
}, new java.util.Vector {
|
||||
add( "Date" )
|
||||
}, new java.util.Vector {
|
||||
add( class java.util.Date )
|
||||
}, new java.util.Vector {
|
||||
add( null )
|
||||
}, new java.util.Vector {
|
||||
add( null )
|
||||
} )
|
||||
"preferredScrollableViewportSize": new java.awt.Dimension( 150, 50 )
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 1 1 3,growy"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "headerLabel"
|
||||
@@ -244,7 +278,7 @@ new FormModel {
|
||||
"description": "Description\nMore description"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 0, "/org/jdesktop/swingx/plaf/windows/resources/tipoftheday.png" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7 2 1,width 200"
|
||||
"value": "cell 1 7 3 1,width 200"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
|
||||
Reference in New Issue
Block a user