mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
ScrollPane with Table: The border of buttons that are added to one of the four scroll pane corners are now removed if the center component is a table. Also, these corner buttons are made not focusable.
This commit is contained in:
@@ -15,6 +15,9 @@ FlatLaf Change Log
|
|||||||
`JButton.buttonType` to `underline`).
|
`JButton.buttonType` to `underline`).
|
||||||
- Button and TextComponent: Support per component minimum width (set client
|
- Button and TextComponent: Support per component minimum width (set client
|
||||||
property `JComponent.minimumWidth` to an integer).
|
property `JComponent.minimumWidth` to an integer).
|
||||||
|
- ScrollPane with Table: The border of buttons that are added to one of the four
|
||||||
|
scroll pane corners are now removed if the center component is a table. Also,
|
||||||
|
these corner buttons are made not focusable.
|
||||||
|
|
||||||
|
|
||||||
## 0.23.1
|
## 0.23.1
|
||||||
|
|||||||
@@ -25,11 +25,15 @@ import java.awt.event.FocusEvent;
|
|||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JScrollBar;
|
import javax.swing.JScrollBar;
|
||||||
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.ScrollPaneConstants;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicScrollPaneUI;
|
import javax.swing.plaf.basic.BasicScrollPaneUI;
|
||||||
@@ -97,17 +101,35 @@ public class FlatScrollPaneUI
|
|||||||
public void propertyChange( PropertyChangeEvent e ) {
|
public void propertyChange( PropertyChangeEvent e ) {
|
||||||
super.propertyChange( e );
|
super.propertyChange( e );
|
||||||
|
|
||||||
if( FlatClientProperties.SCROLL_BAR_SHOW_BUTTONS.equals( e.getPropertyName() ) ) {
|
switch( e.getPropertyName() ) {
|
||||||
JScrollBar vsb = scrollpane.getVerticalScrollBar();
|
case FlatClientProperties.SCROLL_BAR_SHOW_BUTTONS:
|
||||||
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
|
JScrollBar vsb = scrollpane.getVerticalScrollBar();
|
||||||
if( vsb != null ) {
|
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
|
||||||
vsb.revalidate();
|
if( vsb != null ) {
|
||||||
vsb.repaint();
|
vsb.revalidate();
|
||||||
}
|
vsb.repaint();
|
||||||
if( hsb != null ) {
|
}
|
||||||
hsb.revalidate();
|
if( hsb != null ) {
|
||||||
hsb.repaint();
|
hsb.revalidate();
|
||||||
}
|
hsb.repaint();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScrollPaneConstants.LOWER_LEFT_CORNER:
|
||||||
|
case ScrollPaneConstants.LOWER_RIGHT_CORNER:
|
||||||
|
case ScrollPaneConstants.UPPER_LEFT_CORNER:
|
||||||
|
case ScrollPaneConstants.UPPER_RIGHT_CORNER:
|
||||||
|
// remove border from buttons added to corners
|
||||||
|
Object corner = e.getNewValue();
|
||||||
|
if( corner instanceof JButton &&
|
||||||
|
((JButton)corner).getBorder() instanceof FlatButtonBorder &&
|
||||||
|
scrollpane.getViewport() != null &&
|
||||||
|
scrollpane.getViewport().getView() instanceof JTable )
|
||||||
|
{
|
||||||
|
((JButton)corner).setBorder( BorderFactory.createEmptyBorder() );
|
||||||
|
((JButton)corner).setFocusable( false );
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.awt.datatransfer.StringSelection;
|
|||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.*;
|
import javax.swing.table.*;
|
||||||
|
import com.formdev.flatlaf.icons.FlatMenuArrowIcon;
|
||||||
import net.miginfocom.swing.*;
|
import net.miginfocom.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +71,18 @@ public class FlatComponents2Test
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tableHeaderButtonChanged() {
|
||||||
|
boolean show = tableHeaderButtonCheckBox.isSelected();
|
||||||
|
JButton button = null;
|
||||||
|
if( show ) {
|
||||||
|
button = new JButton( new FlatMenuArrowIcon() );
|
||||||
|
button.addActionListener( e -> {
|
||||||
|
JOptionPane.showMessageDialog( this, "hello" );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
scrollPane5.setCorner( JScrollPane.UPPER_TRAILING_CORNER, button );
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||||
@@ -87,9 +100,10 @@ public class FlatComponents2Test
|
|||||||
JScrollPane scrollPane4 = new JScrollPane();
|
JScrollPane scrollPane4 = new JScrollPane();
|
||||||
tree2 = new JTree();
|
tree2 = new JTree();
|
||||||
JLabel tableLabel = new JLabel();
|
JLabel tableLabel = new JLabel();
|
||||||
JScrollPane scrollPane5 = new JScrollPane();
|
scrollPane5 = new JScrollPane();
|
||||||
table1 = new JTable();
|
table1 = new JTable();
|
||||||
dndCheckBox = new JCheckBox();
|
dndCheckBox = new JCheckBox();
|
||||||
|
tableHeaderButtonCheckBox = new JCheckBox();
|
||||||
|
|
||||||
//======== this ========
|
//======== this ========
|
||||||
setLayout(new MigLayout(
|
setLayout(new MigLayout(
|
||||||
@@ -102,7 +116,7 @@ public class FlatComponents2Test
|
|||||||
"[]" +
|
"[]" +
|
||||||
"[]" +
|
"[]" +
|
||||||
"[::200]" +
|
"[::200]" +
|
||||||
"[::150]" +
|
"[150,grow]" +
|
||||||
"[]"));
|
"[]"));
|
||||||
|
|
||||||
//---- textFieldLabel ----
|
//---- textFieldLabel ----
|
||||||
@@ -293,6 +307,11 @@ public class FlatComponents2Test
|
|||||||
dndCheckBox.setMnemonic('D');
|
dndCheckBox.setMnemonic('D');
|
||||||
dndCheckBox.addActionListener(e -> dndChanged());
|
dndCheckBox.addActionListener(e -> dndChanged());
|
||||||
add(dndCheckBox, "cell 0 4 3 1");
|
add(dndCheckBox, "cell 0 4 3 1");
|
||||||
|
|
||||||
|
//---- tableHeaderButtonCheckBox ----
|
||||||
|
tableHeaderButtonCheckBox.setText("show button in table header");
|
||||||
|
tableHeaderButtonCheckBox.addActionListener(e -> tableHeaderButtonChanged());
|
||||||
|
add(tableHeaderButtonCheckBox, "cell 0 4 3 1");
|
||||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||||
|
|
||||||
((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true );
|
((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true );
|
||||||
@@ -303,8 +322,10 @@ public class FlatComponents2Test
|
|||||||
private JList<String> list2;
|
private JList<String> list2;
|
||||||
private JTree tree1;
|
private JTree tree1;
|
||||||
private JTree tree2;
|
private JTree tree2;
|
||||||
|
private JScrollPane scrollPane5;
|
||||||
private JTable table1;
|
private JTable table1;
|
||||||
private JCheckBox dndCheckBox;
|
private JCheckBox dndCheckBox;
|
||||||
|
private JCheckBox tableHeaderButtonCheckBox;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|
||||||
//---- class DummyTransferHandler -----------------------------------------
|
//---- class DummyTransferHandler -----------------------------------------
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
|
JFDML JFormDesigner: "7.0.0.0.194" Java: "13.0.1" encoding: "UTF-8"
|
||||||
|
|
||||||
new FormModel {
|
new FormModel {
|
||||||
contentType: "form/swing"
|
contentType: "form/swing"
|
||||||
@@ -9,7 +9,7 @@ new FormModel {
|
|||||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||||
"$columnConstraints": "[][200][200]"
|
"$columnConstraints": "[][200][200]"
|
||||||
"$rowConstraints": "[][][::200][::150][]"
|
"$rowConstraints": "[][][::200][150,grow][]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "this"
|
name: "this"
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
@@ -135,6 +135,9 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||||
name: "scrollPane5"
|
name: "scrollPane5"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
add( new FormComponent( "javax.swing.JTable" ) {
|
add( new FormComponent( "javax.swing.JTable" ) {
|
||||||
name: "table1"
|
name: "table1"
|
||||||
"model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector {
|
"model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector {
|
||||||
@@ -282,6 +285,16 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 4 3 1"
|
"value": "cell 0 4 3 1"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "tableHeaderButtonCheckBox"
|
||||||
|
"text": "show button in table header"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tableHeaderButtonChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 4 3 1"
|
||||||
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 790, 715 )
|
"size": new java.awt.Dimension( 790, 715 )
|
||||||
|
|||||||
Reference in New Issue
Block a user