mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
SwingX: JXHeader support (#8)
This commit is contained in:
@@ -5,6 +5,8 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
- ComboBox: Use small border if used as table editor.
|
- ComboBox: Use small border if used as table editor.
|
||||||
- ToolBar: Disable focusability of buttons in toolbar.
|
- ToolBar: Disable focusability of buttons in toolbar.
|
||||||
|
- SwingX: Support `JXHeader`, `JXHyperlink`, `JXTaskPaneContainer` and
|
||||||
|
`JXTaskPane`. (issue #8)
|
||||||
|
|
||||||
|
|
||||||
## 0.13
|
## 0.13
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 FormDev Software GmbH
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.formdev.flatlaf.swingx.ui;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.LayoutManager;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import org.jdesktop.swingx.JXHeader;
|
||||||
|
import org.jdesktop.swingx.plaf.basic.BasicHeaderUI;
|
||||||
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXHeader}.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatHeaderUI
|
||||||
|
extends BasicHeaderUI
|
||||||
|
{
|
||||||
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
|
return new FlatHeaderUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installComponents( JXHeader header ) {
|
||||||
|
super.installComponents( header );
|
||||||
|
|
||||||
|
scaleLayout( header );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPropertyChange( JXHeader h, String propertyName, Object oldValue, Object newValue ) {
|
||||||
|
super.onPropertyChange( h, propertyName, oldValue, newValue );
|
||||||
|
|
||||||
|
if( "iconPosition".equals( propertyName ) )
|
||||||
|
scaleLayout( h );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scaleLayout( JXHeader header ) {
|
||||||
|
if( UIScale.getUserScaleFactor() == 1f )
|
||||||
|
return;
|
||||||
|
|
||||||
|
LayoutManager layout = header.getLayout();
|
||||||
|
if( !(layout instanceof GridBagLayout) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
GridBagLayout gbl = (GridBagLayout) layout;
|
||||||
|
for( Component c : header.getComponents() ) {
|
||||||
|
GridBagConstraints cons = gbl.getConstraints( c );
|
||||||
|
cons.insets = UIScale.scale( cons.insets );
|
||||||
|
gbl.setConstraints( c, cons );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#---- Header ----
|
||||||
|
|
||||||
|
JXHeader.background=@background
|
||||||
|
JXHeader.startBackground=4c5052
|
||||||
|
|
||||||
|
|
||||||
#---- Hyperlink ----
|
#---- Hyperlink ----
|
||||||
|
|
||||||
Hyperlink.linkColor=589df6
|
Hyperlink.linkColor=589df6
|
||||||
|
|||||||
@@ -16,5 +16,6 @@
|
|||||||
|
|
||||||
#---- UI delegates ----
|
#---- UI delegates ----
|
||||||
|
|
||||||
|
HeaderUI=com.formdev.flatlaf.swingx.ui.FlatHeaderUI
|
||||||
HyperlinkUI=com.formdev.flatlaf.swingx.ui.FlatHyperlinkUI
|
HyperlinkUI=com.formdev.flatlaf.swingx.ui.FlatHyperlinkUI
|
||||||
swingx/TaskPaneUI=com.formdev.flatlaf.swingx.ui.FlatTaskPaneUI
|
swingx/TaskPaneUI=com.formdev.flatlaf.swingx.ui.FlatTaskPaneUI
|
||||||
|
|||||||
@@ -14,6 +14,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#---- Header ----
|
||||||
|
|
||||||
|
JXHeader.background=@background
|
||||||
|
JXHeader.startBackground=ffffff
|
||||||
|
|
||||||
|
|
||||||
#---- Hyperlink ----
|
#---- Hyperlink ----
|
||||||
|
|
||||||
Hyperlink.linkColor=4a78c2
|
Hyperlink.linkColor=4a78c2
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public class FlatSwingXTest
|
|||||||
JXTaskPane xTaskPane6 = new JXTaskPane();
|
JXTaskPane xTaskPane6 = new JXTaskPane();
|
||||||
JXHyperlink xHyperlink9 = new JXHyperlink();
|
JXHyperlink xHyperlink9 = new JXHyperlink();
|
||||||
JXHyperlink xHyperlink10 = new JXHyperlink();
|
JXHyperlink xHyperlink10 = new JXHyperlink();
|
||||||
|
JLabel headerLabel = new JLabel();
|
||||||
|
JXHeader xHeader1 = new JXHeader();
|
||||||
|
|
||||||
//======== this ========
|
//======== this ========
|
||||||
setLayout(new MigLayout(
|
setLayout(new MigLayout(
|
||||||
@@ -69,6 +71,7 @@ public class FlatSwingXTest
|
|||||||
"[]",
|
"[]",
|
||||||
// rows
|
// rows
|
||||||
"[]" +
|
"[]" +
|
||||||
|
"[]" +
|
||||||
"[]"));
|
"[]"));
|
||||||
|
|
||||||
//---- hyperlinkLabel ----
|
//---- hyperlinkLabel ----
|
||||||
@@ -176,6 +179,16 @@ public class FlatSwingXTest
|
|||||||
scrollPane1.setViewportView(xTaskPaneContainer1);
|
scrollPane1.setViewportView(xTaskPaneContainer1);
|
||||||
}
|
}
|
||||||
add(scrollPane1, "cell 1 1,width 150,height 350");
|
add(scrollPane1, "cell 1 1,width 150,height 350");
|
||||||
|
|
||||||
|
//---- headerLabel ----
|
||||||
|
headerLabel.setText("JXHeader:");
|
||||||
|
add(headerLabel, "cell 0 2");
|
||||||
|
|
||||||
|
//---- xHeader1 ----
|
||||||
|
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 2 2 1,width 200");
|
||||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ new FormModel {
|
|||||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "hidemode 3,ltr"
|
"$layoutConstraints": "hidemode 3,ltr"
|
||||||
"$columnConstraints": "[left][][]"
|
"$columnConstraints": "[left][][]"
|
||||||
"$rowConstraints": "[][]"
|
"$rowConstraints": "[][][]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "this"
|
name: "this"
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
@@ -111,6 +111,20 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 1,width 150,height 350"
|
"value": "cell 1 1,width 150,height 350"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
|
name: "headerLabel"
|
||||||
|
"text": "JXHeader:"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 2"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "org.jdesktop.swingx.JXHeader" ) {
|
||||||
|
name: "xHeader1"
|
||||||
|
"title": "Title"
|
||||||
|
"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 2 2 1,width 200"
|
||||||
|
} )
|
||||||
}, 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( 645, 600 )
|
"size": new java.awt.Dimension( 645, 600 )
|
||||||
|
|||||||
@@ -14,6 +14,14 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#---- Header ----
|
||||||
|
|
||||||
|
JXHeader.background=ff8888
|
||||||
|
JXHeader.startBackground=ffcccc
|
||||||
|
JXHeader.titleForeground=0000ff
|
||||||
|
JXHeader.descriptionForeground=ff0000
|
||||||
|
|
||||||
|
|
||||||
#---- Hyperlink ----
|
#---- Hyperlink ----
|
||||||
|
|
||||||
Hyperlink.linkColor=ff0000
|
Hyperlink.linkColor=ff0000
|
||||||
|
|||||||
Reference in New Issue
Block a user